Skip to content

Instantly share code, notes, and snippets.

@ukris
Created May 2, 2014 03:59
Show Gist options
  • Save ukris/5010ff193ab5434ab5dd to your computer and use it in GitHub Desktop.
Save ukris/5010ff193ab5434ab5dd to your computer and use it in GitHub Desktop.
FAMO.US - NOOB Example using Modifier and Transform
define(function(require, exports, module) {
var matrix;
var x,y,rot,scale;
function confetti() {
for (var i=1;i<=colors.length;i++) {
x = Math.floor(Math.random() * 15) + 1
y = Math.floor(Math.random() * 10) + 1
rot = Math.floor(Math.random() * 10) + 1
scale = Math.floor(Math.random() *2 ) + 1
matrix = Transform.multiply(
Transform.translate(60*x, 60*y, 0),
Transform.rotate(0.0, 0.0,15*rot)
)
matrix = Transform.multiply(matrix,Transform.scale(scale,scale,0))
_smod[i-1].setTransform(
matrix,
{ duration : 500, curve: 'easeInOut' }
);
}
}
var Engine = require('famous/core/Engine');
var Surface = require('famous/core/Surface');
var Transform = require('famous/core/Transform');
var Modifier = require('famous/core/Modifier');
var Timer = require('famous/utilities/Timer');
var _ctx = Engine.createContext();
var colors = ['red','blue','violet','green','yellow','aqua'];
var _surface = [];
var _smod = [];
for (var i=0;i<colors.length;i++) {
_surface[i] = new Surface({
size: [50, 50],
properties: {
backgroundColor: colors[i],
opacity:0.5
}
});
_smod[i] = new Modifier();
_ctx.add(_smod[i]).add(_surface[i]);
}
Timer.setInterval(confetti,20)
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment