Skip to content

Instantly share code, notes, and snippets.

@biovisualize
Created February 15, 2013 04:36
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 biovisualize/4958599 to your computer and use it in GitHub Desktop.
Save biovisualize/4958599 to your computer and use it in GitHub Desktop.
Heart for Alexandra
{"description":"Heart for Alexandra","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":"period","bv":false,"nclones":15,"clone_opacity":0.4,"duration":3000,"ease":"linear","dt":0.01}
var w = 400,
h = 400;
var data = d3.range(360).map(function(d, i){
var t = d/180*Math.PI;
var x = 16*Math.pow(Math.sin(t),3);
var y = 13*Math.cos(t)-5*Math.cos(2*t)-2*Math.cos(3*t)-Math.cos(4*t);
return {x: x, y: y};
});
var x = d3.scale.linear().range([0, w/50]),
y = d3.scale.linear().range([h/50, 0]);
var line = d3.svg.line()
.x(function(d) { return x(d.x); })
.y(function(d) { return y(d.y); })(data);
var svg = d3.select("svg")
.attr({width: w, height: h});
var g = svg.append('g')
.attr({transform: 'translate('+w/2+','+h/2+')'});
g.append("path")
.attr({d: line})
.style({
fill: 'red',
stroke: 'pink',
'stroke-width': 10+'px',
'stroke-linejoin': 'round'
});
g.append('text')
.style({
'font-size': 50+'px',
'text-anchor': 'middle',
fill: 'pink'
})
.text('Alexandra');
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment