Skip to content

Instantly share code, notes, and snippets.

@manoloide
Created August 27, 2018 17:45
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 manoloide/9a47f16b8c9058bdc4996e8db9e8279d to your computer and use it in GitHub Desktop.
Save manoloide/9a47f16b8c9058bdc4996e8db9e8279d to your computer and use it in GitHub Desktop.
void arc2(float x, float y, float s1, float s2, float a1, float a2, int col, float alp1, float alp2) {
float r1 = s1*0.5;
float r2 = s2*0.5;
float amp = (a2-a1);
float ma = map(amp, 0, TWO_PI, 0, 1);
int cc = max(2, int(max(r1, r2)*PI*ma));
float da = amp/cc;
for (int i = 0; i < cc; i++) {
float ang = a1+da*i;
beginShape();
fill(col, alp1);
vertex(x+cos(ang)*r1, y+sin(ang)*r1);
vertex(x+cos(ang+da)*r1, y+sin(ang+da)*r1);
fill(col, alp2);
vertex(x+cos(ang+da)*r2, y+sin(ang+da)*r2);
vertex(x+cos(ang)*r2, y+sin(ang)*r2);
endShape(CLOSE);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment