Skip to content

Instantly share code, notes, and snippets.

@runemadsen
Created November 11, 2016 16:45
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 runemadsen/374289bc0f866908f1c34e4d1d08bb80 to your computer and use it in GitHub Desktop.
Save runemadsen/374289bc0f866908f1c34e4d1d08bb80 to your computer and use it in GitHub Desktop.
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