[Solved]how to rotate an arc about one end ?

edited March 2014 in Questions about Code

Can anyone suggest me how to rotate the arc about the red dot ? Run it your would see the red dot

void setup() {
  size(400, 400);
}
int i=0;
void draw() {
  background(-1);
  // ellipseMode(RADIUS);
  translate(mouseX, mouseY);
  noFill();
  stroke(0);  
  strokeWeight(20);
  rotate(radians(i));
  arc(0, 0, 100, 100, 0, PI-PI/9);
  fill(255, 0, 0);
  noStroke();
  ellipse(50, 0, 10, 10);
  i++;
}
Tagged:

Answers

  • Answer ✓

    Just add translate(-50, 0); before the call to arc().

  • int angle=0;
    
    void setup() {
      size(400, 400);
    }
    
    void draw() {
      background(255);
    
      translate(mouseX, mouseY);
    
      noFill();
      stroke(0);  
      strokeWeight(20);
      rotate(radians(angle));
      arc(0, 0, 100, 100, 0, PI-PI/9);
    
      fill(255, 0, 0);
      noStroke();
      ellipse(0, 0, 10, 10);
    
      angle++;
    }
    
  • Thanks PhiLho :)

Sign In or Register to comment.