[ Launch: bugs2 ] 6480514 by georules
[ Launch: bugs2 ] 6480451 by georules
[ Launch: bugs ] 6334228 by georules
-
-
Save georules/6480514 to your computer and use it in GitHub Desktop.
bugs2
This file contains 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
{"description":"bugs2","endpoint":"","display":"svg","public":true,"require":[],"fileconfigs":{"inlet.js":{"default":true,"vim":false,"emacs":false,"fontSize":12},"_.md":{"default":true,"vim":false,"emacs":false,"fontSize":12},"config.json":{"default":true,"vim":false,"emacs":false,"fontSize":12}},"fullscreen":false,"play":true,"loop":true,"restart":false,"autoinit":true,"pause":true,"loop_type":"period","bv":false,"nclones":15,"clone_opacity":0.4,"duration":3000,"ease":"linear","dt":0.01,"thumbnail":"http://i.imgur.com/c4fkC8T.gif"} |
This file contains 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
/* | |
<--------- CLICK OVER THERE TO MAKE BUGS | |
*/ | |
var svg = d3.select('svg'); | |
function getRandomColor() { | |
return d3.scale.category20(); | |
} | |
function handleBBClick() { | |
svg.append("circle").attr({ | |
"cx":event.offsetX, | |
"cy":event.offsetY, | |
"r":10}).style({fill:getRandomColor()}) | |
} | |
var moveit = function() { | |
d3.selectAll("circle").attr({ | |
"cx":function() { | |
v1 =10; | |
v2 = v1/2 | |
dv = Math.floor(Math.random()*v1)-v2+0.5 | |
v = this.cx.baseVal.value + dv; | |
if(v > tributary.sw) v = tributary.sw | |
if(v < 0) v = 0 | |
return v; | |
}, | |
"cy":function() { | |
v1 =10; | |
v2 = v1/2 | |
dv = Math.floor(Math.random()*v1)-v2+0.5 | |
v = this.cy.baseVal.value + dv; | |
if(v > tributary.sh) v = tributary.sw | |
if(v < 0) v = 0 | |
return v; | |
}, | |
"r":function() { | |
v = this.r.baseVal.value + Math.random()*1-0.5 | |
if (v < 5) v = 5 | |
return v | |
} | |
}) | |
} | |
svg.on('click',handleBBClick) | |
tributary.run = function(g,t) { | |
moveit() | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment