Pie graph help

hi i want to add this pie graph that turns into an circle into my main sketch but i want to be able to click once and the pie graph turns into a circle and when i put it it doesn't work. Could someone pls help me put this into my main sketch and tell me how to use the mousePressed function so that i click once and the graph turns into a circle
thanks

int arcsize=600;
int shrinkorgrow;

 int diameter = 300;
 int[] angle2 = {70,60,100,60,70};
  float lastangle2 = 0;
int i=0;
void setup(){
  size(1000,1000);
  frameRate(5);
}



void draw() {
  //check the size of arc
  if(arcsize>299){
    shrinkorgrow=0;
  }else if (arcsize<101){
    shrinkorgrow=1;
  }arc(width/2, height/2, diameter, diameter, lastangle2, lastangle2+radians(angle2[i]));
 lastangle2 += radians(angle2[i]);  
  fill(9,123,178) ;
      }
Tagged:

Answers

  • Answer ✓

    this reacts on mousePressed

    int arcsize=600;
    int shrinkorgrow;
    
    int diameter = 300;
    int[] angle2 = {70, 60, 100, 60, 70};
    float lastangle2 = 0;
    int i=0;
    
    boolean circleOn=true; 
    
    void setup() {
      size(1000, 1000);
      frameRate(5);
      background(111);
    }
    
    void draw() {
    
    
    
      fill(9, 123, 178) ;
    
    
      if (circleOn) 
      {
        background(111); 
        fill(222, 2, 2); 
        ellipse ( width/2, height/2, diameter, diameter);
      } else {
    
        //check the size of arc
        if (arcsize>299) {
          shrinkorgrow=0;
        } else 
        if (arcsize<101) {
          shrinkorgrow=1;
        }
    
        arc(width/2, height/2, diameter, diameter, lastangle2, lastangle2+radians(angle2[i]));
        lastangle2 += radians(angle2[i]);
      }
    }
    
    void mousePressed() {
      circleOn=!circleOn;
      background(111);
    }
    //
    
Sign In or Register to comment.