Skip to content

Instantly share code, notes, and snippets.

@swanson
Created October 2, 2010 03:26
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save swanson/607245 to your computer and use it in GitHub Desktop.
Save swanson/607245 to your computer and use it in GitHub Desktop.
function get_random_color() {
var letters = '0123456789ABCDEF'.split('');
var color = '#';
for (var i = 0; i < 6; i++ ) {
color += letters[Math.round(Math.random() * 15)];
}
return color;
}
function getRandomArbitary (min, max) {
return Math.random() * (max - min) + min;
}
function a(foo, rot, z, zz, sp) {
foo.animate({rotation: rot, x:foo.attr("x") + z, y:foo.attr("y") + zz, fill:get_random_color()}, sp, function(){b(foo, rot*-1, z*-1, zz*-1, sp)} );
}
function b(foo, rot, z, zz, sp) {
foo.animate({rotation: rot, x:foo.attr("x") + z, y:foo.attr("y") + zz, fill:get_random_color()}, sp, function(){a(foo, rot*-1, z*-1, zz*-1, sp)} );
}
paper.rect(0, 0, 640, 480, 10).attr({fill: "black"});
for (var i=0; i<150; i++){
var size = getRandomArbitary(40, 80);
var rot = getRandomArbitary(-360, 360);
var speed = getRandomArbitary(4000, 6000);
var x = paper.rect(getRandomArbitary(10,630), getRandomArbitary(10,470), size, size).attr({fill: get_random_color(), stroke: "#000", "stroke-width": 5, "stroke-opacity": 1});
a(x, rot, getRandomArbitary(-150, 150), getRandomArbitary(-150, 150), speed);
}
@swanson
Copy link
Author

swanson commented Oct 2, 2010

first attempt at a 'floating particle' display

plug into http://raphaeljs.com/playground.html and click Run

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment