[ Launch: atom ] 69159627c9f6f4e0cac9 by omniwired
[ Launch: atom ] f88367fa08647a14a8ad by omniwired
-
-
Save omniwired/69159627c9f6f4e0cac9 to your computer and use it in GitHub Desktop.
atom2
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
{"description":"atom2","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":false,"loop":false,"restart":false,"autoinit":true,"pause":true,"loop_type":"pingpong","bv":false,"nclones":15,"clone_opacity":0.4,"duration":3000,"ease":"linear","dt":0.01,"ajax-caching":true,"thumbnail":"http://i.imgur.com/UHrRS9t.png"} |
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
var svg = d3.select("svg") | |
var radius = 33; | |
var translate = 'translate (0, 0)'; | |
var n = 8 | |
var centroid = [tributary.sw/2,tributary.sh/2]; | |
var outr = 222; | |
var color = d3.scale.category20(); | |
var afterColor = d3.scale.linear() | |
.range(['#5bb5ff', 'hsl(356,100%,67%)']) | |
setInterval(function() { | |
var svg = d3.select("svg") | |
svg.append('circle') | |
.attr({ | |
cx: centroid[0], | |
cy: centroid[1], | |
r: 4, | |
fill: '#ff283e' | |
}).transition().duration(746) | |
.attr({ | |
fill: '#9a47ff', | |
r: radius | |
}).remove(); | |
},300); | |
svg.on('mousewheel', function(e) { | |
n = n + d3.event.wheelDelta / 120; | |
if (n < 0) { | |
n = 0; | |
} | |
}); | |
svg.on('mousemove', function(e) { | |
var coords = d3.mouse(this); | |
for(var i=0; i<n; i++) { | |
console.log('drawing'); | |
var omega = Math.atan2(coords[0] - centroid[0], coords[1] - centroid[1]); | |
var nx = outr * Math.sin(omega); | |
var ny = outr * Math.cos(omega); | |
svg.append('circle') | |
.attr({ | |
stroke: color(i * coords[0] * coords[1]), | |
'stroke-dasharray': 5, | |
cx: centroid[0] +nx *i/10, | |
cy: centroid[1] +ny *i/10, | |
r: radius*2, | |
fill: 'none', | |
transform: translate | |
}).transition().duration(2000) | |
.delay(1000) | |
.attr({ | |
r: radius*10 | |
}).transition().duration(1000) | |
.attr({ | |
r: radius/4, | |
cx: centroid[0], | |
cy: centroid[1] | |
}) | |
.remove(); | |
} | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment