Changing color in a spiral gradually from center out to the edges.

Hello good people, As my username states already i am new to programming, and to be honest i'm having a hard time since its not my favorie field but i gotta do it for my Uni course, so i'd be happy about every tip or advice you can give me.

int myRotation = 0;
int col;

void setup() {
  size(800,800);
  strokeWeight(1);
  stroke(255);
  noFill();

}


void draw()  {
  background(0);

  noFill();

 translate(400,400);

  for(int i = 0; i < 500; i++) {
    myRotation = myRotation + 20;
    mousePressed()

    pushMatrix();

   rotate(radians(myRotation));
    translate(25+i,0);
   // scale(0.05*i);
    quad(0, -100, 50, 50, 0, 100, -50, 50);

    popMatrix();


  }
}

this is my code and what i'd like to do is to change the colors gradually from the center to the outside in the Rainbow color spectrum... with a mouseclick interaction would be cool as well...

Any help is appreciated.

thank you

Tagged:

Answers

  • Answer ✓

    https://forum.processing.org/two/discussion/15473/readme-how-to-format-code-and-text

    We can't help you if we can't stand to look at your code.

  • edited December 2017
    int myRotation = 0;
    int col;
    
    void setup() {
      size(800, 800);
      strokeWeight(1);
      stroke(255);
      noFill();
    }
    
    
    void draw() {
      background(0);
    
      noFill();
    
      translate(400, 400);
    
      for (int i = 0; i < 500; i++) {
        myRotation = myRotation + 20;
       // mousePressed()
    
          pushMatrix();
    
        rotate(radians(myRotation));
        translate(25+i, 0);
        // scale(0.05*i);
        quad(0, -100, 50, 50, 0, 100, -50, 50);
    
        popMatrix();
      }
    }
    
  • how about now ? thanks for the tip

  • Answer ✓
    int myRotation = 0;
    float offset = 0;
    
    void setup() {
      size(800, 800);
      colorMode(HSB,500);
      noFill();
    } 
    
    void draw() {
      background(0);
      noFill();
      translate(400, 400);
      if( mousePressed ){
        offset = map(mouseX,0,width,0,500);
      }
      for (int i = 0; i < 500; i++) {
        myRotation = myRotation + 20;
        pushMatrix();
        rotate(radians(myRotation));
        translate(25+i, 0);
        stroke((i+offset)%500,500,500);
        quad(0, -100, 50, 50, 0, 100, -50, 50);
        popMatrix();
      }
    }
    
  • thank you a lot this is very helpful

Sign In or Register to comment.