constrain arc size
in
Programming Questions
•
2 years ago
hi- getting confused over which value(s) i need to constrain in order to stop the segment sizes exceeding specified length.,.
- float[][] ang;
- color[] colors;
- float rad= 120;
- int ind;
- void setup() {
- size(300, 300);
- smooth();
- fill(255, 0, 0);
- colors =new color[] {
- color(255, 0, 0, 140),
- color(0, 0, 255, 140),
- color(0, 220, 0, 140),
- color(80, 0, 105, 140)
- };
- ang = new float[][]
- {
- {
- 0, HALF_PI
- }
- ,
- {
- HALF_PI, PI
- }
- ,
- {
- PI+HALF_PI, TWO_PI
- }
- ,
- {
- PI, PI+HALF_PI
- }
- };
- }
- void draw() {
- ind = 0;
- float mx = mouseX-width*.5;
- float my = mouseY-height*.5;
- background(255);
- translate(width*.5, height*.5);
- fill(230);
- strokeWeight(2);
- ellipse(0, 0, 120, 120);
- fill(0, 100, 0, 100);
- if (mousePressed) {
- strokeWeight(2);
- fill (230);
- arc(0, 0, rad, rad, 0, HALF_PI);
- fill (230);
- arc(0, 0, rad, rad, HALF_PI, PI);
- fill (230);
- arc(0, 0, rad, rad, PI+HALF_PI, TWO_PI);
- fill (230);
- arc(0, 0, rad, rad, PI, PI+HALF_PI);
- if (my < 0) ind+=2;
- if (mx < 0) ind++;
- float rad = dist(0, 0, mx, my)*2;
- fill(colors[ind]);
- arc(0, 0, rad, rad, ang[ind][0], ang[ind][1]);
- }
- }
1