Created
April 9, 2019 19:17
-
-
Save whatl3y/6159c65bd27b2c58d5061769f45ed18d to your computer and use it in GitHub Desktop.
Programmatically draw perfect circles on the following page: http://vladgotlib.com/circular
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 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