2025年3月27日 星期四

12751100張恩豪-week06

 week06


//week06-1-ellipse-translate-push-rotate-box-pop

void setup(){

  size(500,500,P3D);

}

void draw(){

 background(142);

 ellipse(width/2,height/2,200,200);

 

 translate(width/2,height/2);//把東西,放到畫面中心

 pushMatrix();//第5周教的Matrix保護

   if(mousePressed) rotateZ(radians(frameCount));//對著下面中心旋轉

   box(100,30,30);//橫的棒子

 popMatrix();//第5周教的Matrix保護

}


//week06-2-ellipse-translate-push-rotate-box-pop

void setup(){

  size(500,500,P3D);

}

void draw(){

 background(142);

 ellipse(width/2,height/2,200,200);

 

 translate(width/2,height/2);//把東西,放到畫面中心

 pushMatrix();//第5周教的Matrix保護

   if(mousePressed) rotateZ(radians(frameCount));//對著下面中心旋轉

   translate(-50,0,0);//把棒子左移

   box(100,30,30);//橫的棒子

 popMatrix();//第5周教的Matrix保護

}


//week06-3-push-traslate-rotate-translate-box-pop

void setup(){

  size(500,500,P3D);

}

void draw(){

 background(142);

 ellipse(width/2,height/2,200,200);

 translate(width/2,height/2);//把東西,放到畫面中心

 pushMatrix();//第5周教的Matrix保護

   if(mousePressed && mouseButton==RIGHT){ 

     rotateZ(radians(frameCount));//對著下面中心旋轉

   }

   translate(-50,0,0);//把棒子左移

   box(100,30,30);//橫的棒子

 popMatrix();//第5周教的Matrix保護

}

float x = 0, y = 0;

void mouseDragged(){

  x += mouseX - pmouseX;

  y += mouseY - pmouseY;

}


//week06-4-sphere

void setup(){

  size(500,400,P3D);

}

void draw(){

  background(255);//step00

  translate(width/2,height/2);//step00

  sphere(10);//step04 放個圓球,當世界中心參考

  

  box(200,50,25);//手肘

  fill(252,131,77);

  pushMatrix();//step03

    if(mousePressed) rotateZ(radians(frameCount));//step03

    translate(25,0,0);//step02 往右推,讓左端放中心

    box(50,50,50);//step01 小手腕

  popMatrix();//step03

}

float x = 0, y = 0;

void mouseDragg(){

  x += mouseX - pmouseX;

  y += mouseY - pmouseY;

  println("x:"+x+"y:"+y);

}


//week06-5-sphere

void setup(){

  size(500,400,P3D);

}

void draw(){

  background(255);//step00

  translate(width/2,height/2);//step00

  sphere(10);//step04 放個圓球,當世界中心參考

  

  

  fill(252,131,77);

  pushMatrix();//step03

    translate(x,y);

    //if(mousePressed)

    box(200,50,25);//手肘

    pushMatrix();

      translate(100,0);

      rotateZ(radians(frameCount));//step03

      translate(25,0,0);//step02 往右推,讓左端放中心

      box(50,25,50);//step01 小手腕

     popMatrix();

  popMatrix();//step03

}

float x = 0, y = 0;

void mouseDragged(){

  x += mouseX - pmouseX;

  y += mouseY - pmouseY;

  println("x:"+x+"y:"+y);

}


//week06-6-sphere

void setup(){

  size(500,400,P3D);

}

void draw(){

  background(255);//step00

  translate(width/2,height/2);//step00

  sphere(10);//step04 放個圓球,當世界中心參考

  

  

  fill(252,131,77);

  pushMatrix();//step03

    //if(mousePressed)

    box(50,200,25);//手肘

    pushMatrix();

      translate(x,y);

      if(mousePressed) rotateZ(radians(frameCount));

      translate(100,0);

      box(200,50,25);//step01 小手腕

      pushMatrix();

      translate(100,0);

      rotateZ(radians(frameCount));

      translate(25,0,0);

      box(50,20,50);

      popMatrix();

     popMatrix();

  popMatrix();//step03

}

float x = 0, y = 0;

void mouseDragged(){

  x += mouseX - pmouseX;

  y += mouseY - pmouseY;

  println("x:"+x+"y:"+y);

}




//week06-7-sphere

void setup(){

  size(500,800,P3D);

}

void draw(){

  background(255);//step00

  translate(width/2,height/2);//step00

  sphere(10);//step04 放個圓球,當世界中心參考

  

  

  fill(252,131,77);

  pushMatrix();//step03

    if(mousePressed && mouseButton==RIGHT) rotateZ(radians(frameCount));

    translate(x,y);

    box(50,200,25);//手肘

    pushMatrix();

      translate(0,-100);

      //if(mousePressed) 

      rotateZ(radians(frameCount));

      translate(100,0);

      box(200,50,25);//step01 小手腕

      

      pushMatrix();

        translate(100,0);

        rotateZ(radians(frameCount));

        translate(25,0,0);

        box(50,25,50);

      popMatrix();

     popMatrix();

  popMatrix();//step03

}

float x = 0, y = 0;

void mouseDragged(){

  x += mouseX - pmouseX;

  y += mouseY - pmouseY;

  println("x:"+x+"y:"+y);

}



































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































沒有留言:

張貼留言