Skip to content

Instantly share code, notes, and snippets.

@FredrikMeyer
Last active May 30, 2019 19:40
Show Gist options
  • Save FredrikMeyer/e5dae395e545e4bb12aa69795be16834 to your computer and use it in GitHub Desktop.
Save FredrikMeyer/e5dae395e545e4bb12aa69795be16834 to your computer and use it in GitHub Desktop.
float centerx;
float centery;
void setup() {
size(900, 900);
centerx = width/2;
centery = height/2;
}
void draw() {
background(255);
stroke(0, 50);
strokeWeight(1);
spiral();
System.out.println("DONE");
noLoop();
}
void mouseClicked() {
saveFrame("spiral.png");
}
float radius(float theta) {
return 12*(float)Math.sqrt(theta);
}
void spiral() {
float px = centerx;
float py = centery;
for (float theta = 0; theta < 1000 * PI; theta = theta + 0.001) {
float cx = centerx + radius(theta)*((float)Math.cos(theta));
float cy = centery + radius(theta)*((float)Math.sin(theta));
line(px, py, cx, cy);
px = cx;
py = cy;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment