Drawing continuum lines

I want to draw with 6 rotacional simetry axis. I have acomplished it; however, the drawed line only seems continuum where it is drawed, and in the other five simetries looks fragmented.

Here's the code:

float xPos;
float yPos;
float Cx=width/2;
float Cy=height/2;
float alfa=PI/3;
int frame;
int mycolor;
int sumacolor;

void setup(){
  size(800, 600);
  smooth();
  background(0);
  frame=0;
  mycolor=60;
  sumacolor=1;

}

void draw (){ //vanish lines

 if (frame%20==0){
  fill(0,60);
  noStroke();
  rect(0,0,800,600);

  }
  frame++;

 translate(width/2,height/2);

 for (int a=0; a<7; a++) {       //rotational axis


     rotate(mouseX*alfa*a);
     rotate(mouseY*alfa*a);
     rotate(pmouseX*alfa*a);
     rotate(pmouseY*alfa*a);


     colorMode(HSB,360);  //change color of lines
     strokeWeight(1); 
     stroke(mycolor,mycolor,mycolor);
     mycolor+=sumacolor;
     if (mycolor==320){
       sumacolor=-1;
     }

    if (mycolor==61){
       sumacolor=+1;
     }



     line(mouseX-400,mouseY-300,pmouseX-400,pmouseY-300);

}  
}




}

Answers

  • Answer ✓

    there are two things wrong:

    rotate(variable) doesn't rotate the variable, it rotates the entire screen by the variable. so replace

     rotate(mouseX*alfa*a);
     rotate(mouseY*alfa*a);
     rotate(pmouseX*alfa*a);
     rotate(pmouseY*alfa*a);
    

    with

     rotate(alfa * a);
    

    also, rotation is accumulative. so you need pushMatrix(); as the first line of your for loop and popMatrix(); as the last

  • Answer ✓

    (also, line 63 is extraneous)

  • THANK YOU.

Sign In or Register to comment.