Skip to content

Instantly share code, notes, and snippets.

@runemadsen
Last active April 22, 2016 20:55
Show Gist options
  • Save runemadsen/0c7ea5368ea09eb3f938fe27b06e699a to your computer and use it in GitHub Desktop.
Save runemadsen/0c7ea5368ea09eb3f938fe27b06e699a to your computer and use it in GitHub Desktop.
var r = new Rune({
container: "#canvas",
width: 600,
height: 800
});
var poly = r.polygon(r.width/2, r.height/2);
var numPoints = 6;
var degree = 360 / numPoints;
for(var i = 0; i < numPoints; i++) {
var x = Math.cos(Rune.radians(degree * i)) * 200;
var y = Math.sin(Rune.radians(degree * i)) * 200;
poly.lineTo(x, y);
}
for(var i = 1; i < poly.vars.vectors.length; i++) {
var last = poly.vars.vectors[i-1];
var cur = poly.vars.vectors[i];
var diff = cur.sub(last);
var cX = poly.vars.x - 50;
var cY = poly.vars.y - 50;
for(var j = 0; j < 20; j++) {
var btw = diff.multiply(j / 20).add(last);
r.line(cX, cY, poly.vars.x + btw.x, poly.vars.y + btw.y);
}
}
r.draw();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment