Rotating Lines Around A circle

Hello,
I am trying to rotate 15 lines around the center point of a circle in unison. The lines start at the correct positions, but they rotate at different speeds. Thanks for any help!

// GLOBAL VARIABLES
final int SUN_DIAMETER = 150;
final int NUMBER_OF_RAYS = 15;
float angle = TWO_PI/NUMBER_OF_RAYS;
float RING_OF_LINES = SUN_DIAMETER*.5 + 30;



// SETUP

void setup(){
   size(600,400);
}

//DRAW

void draw(){
  background(51);
  translate(width/2,height/2);
  
  noFill();
  stroke(255);
  ellipse(0,0,SUN_DIAMETER,SUN_DIAMETER);
  
  
  for(int i = 0; i < NUMBER_OF_RAYS; i++){
    line(RING_OF_LINES,0,RING_OF_LINES+40,0);
    rotate(angle);
  }
  angle += .001;
}

Check the changes.

Kf

// GLOBAL VARIABLES
final int SUN_DIAMETER = 150;
final int NUMBER_OF_RAYS = 15;
float angle = TWO_PI/NUMBER_OF_RAYS;
float RING_OF_LINES = SUN_DIAMETER*.5 + 30;



// SETUP

void setup() {
  size(600, 400);
}

//DRAW

void draw() {
  background(51);
  translate(width/2, height/2);

  noFill();
  stroke(255);
  ellipse(0, 0, SUN_DIAMETER, SUN_DIAMETER);


  for (int i = 0; i < NUMBER_OF_RAYS; i++) {
    pushMatrix();
    rotate(angle +i*TWO_PI/NUMBER_OF_RAYS    );
    line(RING_OF_LINES, 0, RING_OF_LINES+40, 0);
    popMatrix();
  }
  angle += .001;
}

1 Like