Skip to content

Instantly share code, notes, and snippets.

@tsulej
Last active August 29, 2015 14:12
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save tsulej/09742bafce721a9540f2 to your computer and use it in GitHub Desktop.
Save tsulej/09742bafce721a9540f2 to your computer and use it in GitHub Desktop.
Vertex circles
size(1000,1000);
background(20);
smooth(8);
noFill();
stroke(240);
strokeWeight(0.7);
// outer circle
ellipse(500,500,900,900);
// middle circle
// very small steps are needed with vertex
// experiment with step eg. float step = TWO_PI/50.0;
float step = TWO_PI/(4.0*360.0);
float r = 400.0;
float ang = 0;
beginShape();
while(ang<TWO_PI) {
float x = cos(ang) * r;
float y = sin(ang) * r;
vertex(x+500,y+500);
ang+=step;
}
endShape(CLOSE);
// inner circle
ang = 0;
r = 350;
// experiment with step eg. step = TWO_PI/5;
step = TWO_PI/17;
beginShape();
// here we need to overlap curveVertexes to close circle change following '3' to '2' to see what happen
while(ang<=TWO_PI+3*step) {
float x = cos(ang) * r;
float y = sin(ang) * r;
curveVertex(x+500,y+500);
ang+=step;
}
endShape(); // do not close, just overlap curveVertexes.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment