Created
November 11, 2016 16:45
-
-
Save runemadsen/374289bc0f866908f1c34e4d1d08bb80 to your computer and use it in GitHub Desktop.
This file contains 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: 800, | |
height: 600 | |
}); | |
var myPoly = r.polygon(400, 200) | |
.lineTo(0, 0) | |
.lineTo(200, 50) | |
.lineTo(250, 60) | |
.lineTo(200, 150) | |
.lineTo(-200, 150) | |
.lineTo(-250, 60) | |
.lineTo(-200, 50) | |
// shifmanns code | |
var circles = []; | |
for(var x = 0; x < r.width; x += 20) { | |
for(var y = 0; y < r.height; y += 20) { | |
var myCircle = r.circle(x, y, 10) | |
circles.push(myCircle) | |
} | |
} | |
for(var i = 0; i < circles.length; i++) { | |
if(myPoly.contains(circles[i].state.x, circles[i].state.y)) { | |
circles[i].fill(0, 255, 0) | |
} else { | |
circles[i].fill(0, 0, 255) | |
} | |
} | |
myPoly.removeParent(); | |
r.draw(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment