float radius = 50;
void setup() {
size(200, 200);
noFill();
stroke(0);
}
void draw() {
background(255);
translate(100, 100);
dashedCircle(50, 6, 4);
}
void dashedCircle(float radius, int dashWidth, int dashSpacing) {
int steps = 200;
int dashPeriod = dashWidth + dashSpacing;
boolean lastDashed = false;
for(int i = 0; i < steps; i++) {
boolean curDashed = (i % dashPeriod) < dashWidth;
if(curDashed && !lastDashed) {
beginShape();
}
if(!curDashed && lastDashed) {
endShape();
}
if(curDashed) {
float theta = map(i, 0, steps, 0, TWO_PI);
vertex(cos(theta) * radius, sin(theta) * radius);
}
lastDashed = curDashed;
}
if(lastDashed) {
endShape();
}
}