Skip to content

Instantly share code, notes, and snippets.

@poezn
Created March 30, 2014 06:31
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 poezn/9868590 to your computer and use it in GitHub Desktop.
Save poezn/9868590 to your computer and use it in GitHub Desktop.
Spiky circle
{"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}
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