Skip to content

Instantly share code, notes, and snippets.

@fiskurgit
Last active August 29, 2015 14:12
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 fiskurgit/80fc7d4892f430bd2711 to your computer and use it in GitHub Desktop.
Save fiskurgit/80fc7d4892f430bd2711 to your computer and use it in GitHub Desktop.
Processing.org - plot a circle.
//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