Last active
August 29, 2015 14:12
-
-
Save fiskurgit/80fc7d4892f430bd2711 to your computer and use it in GitHub Desktop.
Processing.org - plot a circle.
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
//Plotting a circle | |
int cx, cy; | |
int segmentCount = 100; | |
int step = 0; | |
float plotDiameter, plotRadius; | |
void setup(){ | |
size(500, 500); | |
cx = width/2; | |
cy = height/2; | |
plotDiameter = width * .75; | |
plotRadius = plotDiameter/2; | |
frameRate(20); | |
background(80); | |
noStroke(); | |
fill(255); | |
} | |
void draw(){ | |
float theta = step * TWO_PI / segmentCount; | |
float x = cx + cos(theta) * plotRadius; | |
float y = cy + sin(theta) * plotRadius; | |
ellipse(x, y, 10, 10); | |
if(step == segmentCount){ | |
background(80); | |
step = -1; | |
} | |
step++; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment