Created
October 2, 2010 03:26
-
-
Save swanson/607245 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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); | |
| } |
Author
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
first attempt at a 'floating particle' display
plug into http://raphaeljs.com/playground.html and click Run