Skip to content

Instantly share code, notes, and snippets.

@whatl3y
Created April 9, 2019 19:17
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 whatl3y/6159c65bd27b2c58d5061769f45ed18d to your computer and use it in GitHub Desktop.
Save whatl3y/6159c65bd27b2c58d5061769f45ed18d to your computer and use it in GitHub Desktop.
Programmatically draw perfect circles on the following page: http://vladgotlib.com/circular
var perfection = {
pointsToDraw: 8000,
radius: 600,
x: 800,
y: 650,
go() {
this.startDraw(this.x, this.y);
this.drawCircle((xStep, yStep) => {
this.drawPoints(this.x + (xStep * this.radius), this.y + (yStep * this.radius))
})
// finished
CIRC.drawing = false;
},
drawCircle(foo) {
const start = 0
const end = 2 * Math.PI
const step = end / this.pointsToDraw
for (var radians = start; radians < end; radians += step) {
foo(Math.cos(radians), Math.sin(radians))
}
},
startDraw(xStart, yStart, step) {
CIRC.drawing = true;
CIRC.xOffset = $('#grid').position().left;
CIRC.yOffset = $('#grid').position().top;
// CIRC.draw.circle(CIRC.pointRadius).move(xStart-CIRC.xOffset-CIRC.pointRadius/2, yStart-CIRC.yOffset-CIRC.pointRadius/2).fill('#7B92ED');
// CIRC.pointsArray.push([xStart, yStart]);
},
drawPoints(x, y) {
CIRC.draw.circle(CIRC.pointRadius).move(x-CIRC.xOffset-CIRC.pointRadius/2, y-CIRC.yOffset-CIRC.pointRadius/2).fill('#7B92ED');
CIRC.pointsArray.push([x, y]);
}
}
perfection.go()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment