Last active
April 22, 2016 20:55
-
-
Save runemadsen/0c7ea5368ea09eb3f938fe27b06e699a to your computer and use it in GitHub Desktop.
This file contains hidden or 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 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