[ Launch: Tributary inlet ] 9868590 by poezn
-
-
Save poezn/9868590 to your computer and use it in GitHub Desktop.
Spiky circle
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":"Spiky circle","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":false,"restart":true,"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/MtfkxqO.png","inline-console":true} |
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
var segments = 100; | |
var inner = .91 ; | |
var arr = d3.range(0, 2*Math.PI, 2*Math.PI / segments); | |
var r = 100; | |
tributary.init = function(g) { | |
g.selectAll("path") | |
.data([arr, arr, arr]) | |
.enter().append("path") | |
.attr({ | |
"d": function(d, i) { | |
var rad = r * (Math.random() + 0.5); | |
var string = "M" | |
+ _.map(d, function(d, i) { | |
var radius = ((i % 2) ? rad * inner : rad); | |
return Math.sin(d)*radius + " " + Math.cos(d)*radius; | |
} ).join(",") | |
+ "Z" | |
return string; | |
} | |
}) | |
.style({ | |
"stroke": "#000", | |
"fill": "transparent" | |
}) | |
} | |
var speeds = [120, 30, 10]; | |
tributary.run = function(g, t) { | |
g.selectAll("path") | |
.attr({ | |
"transform": function(d, i) { | |
return "translate(" + (2.4*i*r + r) + " " + r + ") rotate(" + (t*speeds[i] % 360) + ")" | |
} | |
}) | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment