Skip to content

Instantly share code, notes, and snippets.

@gelicia
Created May 5, 2013 17:32
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 gelicia/5521497 to your computer and use it in GitHub Desktop.
Save gelicia/5521497 to your computer and use it in GitHub Desktop.
zzz
{"description":"zzz","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,"thumbnail":"http://i.imgur.com/MHuHT6q.png"}
var svg = d3.select('svg');
var startPoint = {x: 349, y: 40};
var size = 231;
var id = 0;
var pointAngle = 36;
var insideAngle = 108; //this will change
var halfsiesAngle= (180-pointAngle)/2;
var star = [{x: startPoint.x, y: startPoint.y},
{x: startPoint.x + (size * Math.cos(halfsiesAngle * (Math.PI/180))),
y: startPoint.y + (size * Math.sin(halfsiesAngle * (Math.PI/180)))}];
star.push({x: star[1].x + (size * Math.cos(0 * (Math.PI/180))),
y: star[1].y + (size * Math.sin(0 * (Math.PI/180)))});
star.push({x: star[2].x - (size * Math.cos(pointAngle * (Math.PI/180))),
y: star[2].y + (size * Math.sin(pointAngle * (Math.PI/180)))});
star.push({x: star[3].x - (size * Math.cos((180-halfsiesAngle) * (Math.PI/180))),
y: star[3].y + (size * Math.sin((180-halfsiesAngle) * (Math.PI/180))) });
star.push({x: star[4].x - (size * Math.cos(pointAngle * (Math.PI/180))),
y: star[4].y - (size * Math.sin(pointAngle * (Math.PI/180)))});
star.push({x: star[5].x - (size * Math.cos(pointAngle * (Math.PI/180))),
y: star[5].y + (size * Math.sin(pointAngle * (Math.PI/180))) });
star.push({x: star[6].x + (size * Math.cos(halfsiesAngle * (Math.PI/180))),
y: star[6].y - (size * Math.sin(halfsiesAngle * (Math.PI/180)))});
star.push({x: star[7].x + (size * Math.cos((180-pointAngle) * (Math.PI/180))),
y: star[7].y - (size * Math.sin((180-pointAngle) * (Math.PI/180)))});
star.push({x: star[8].x + (size * Math.cos(0 * (Math.PI/180))),
y: star[8].y - (size * Math.sin(0 * (Math.PI/180)))});
var offset = 0;
star[1].x = star[1].x + offset;
star[1].y = star[1].y - offset;
star[3].x = star[3].x + offset;
star[3].y = star[3].y + offset;
//star[5].x = star[5].x + offset;
star[5].y = star[5].y + offset;
star[7].x = star[7].x - offset;
star[7].y = star[7].y + offset;
star[9].x = star[9].x - offset;
star[9].y = star[9].y - offset;
svg.selectAll("polygon #star" + id)
.data([star])
.enter().append("polygon")
.attr({
points: function(d) {
return d.map(function(d) { return [d.x,d.y].join(","); }).join(" ");},
// fill: 'black',
'stroke-width':1,
'stroke': 'black',
//'fill-opacity':'0.1',
id: 'star' + id
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment