2021年10月21日 星期四

week 5. basic form and rotation

1. form: point, line, polygon, arc, eclipse, rect,...
2. noLoop();  / redraw();

void setup(){
  size(640, 360);
  background(0);
}

int gridSize = 40;

void draw() {
background(0); 
stroke(200);
noFill();
for (int x = gridSize; x <= width - gridSize; x += gridSize) {
  for (int y = gridSize; y <= height - gridSize; y += gridSize) {
  
   rotateShape(x, y);
  
  }
}

}

void rotateShape(int xloc, int yloc) {
  pushMatrix();
  translate(xloc, yloc);
 // rotate((frameCount / 8.0)+xloc+yloc+mouseX);
 rotate((mouseX/100)*frameCount / 8.0+xloc+yloc);
 rect(-10, -10, 20, 20);
 line(-10, -10, 10, 10);
  popMatrix();


}


References:
https://processing.org/examples/star.html



example #2:

void setup(){
  size(640, 360);
  background(0);
}

int gridSize = 40;

void draw() {
background(0); 
stroke(200);
noFill();
for (int x = gridSize; x <= width - gridSize; x += gridSize) {
  for (int y = gridSize; y <= height - gridSize; y += gridSize) {
   
   rotateShape(x, y);
   
  }
}

}

void rotateShape(int xloc, int yloc) {
  pushMatrix();
  translate(xloc, yloc);
 rotate((frameCount / 8.0)+xloc+yloc);
 //rotate((mouseX/100)*frameCount / 8.0+xloc+yloc);
 beginShape();
vertex(-10, -10);
vertex(0, -10);
vertex(0, 0);
vertex(10, 0);
vertex(10, 10);
vertex(-10, 10);
endShape(CLOSE);
 //rect(-10, -10, 20, 20);
// line(-10, -10, 10, 10);
  popMatrix();


}





沒有留言:

張貼留言