2025年3月27日 星期四

12750423_week06

 //week06_1

void setup()

{

  size(500,500,P3D);

}

void draw()

{

  background(142);

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

  

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

  pushMatrix();

//改一下。要按下mouse才轉給你看

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

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

  popMatrix();

}


//week06_2

void setup()

{

  size(500,500,P3D);

}

void draw()

{

  background(142);

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

  

  translate(width/2,height/2);

  pushMatrix();

  

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

    translate(-50,0,0);//把棒子往左移一半,讓右端放在正中心

    box(100,30,30);

  popMatrix();

}

//week06_3

void setup()

{

  size(500,500,P3D);

}

void draw()

{

  background(142);

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

  

  translate(width/2,height/2);

  pushMatrix();

    translate(x,y);

    if(mousePressed && mouseButton==RIGHT)

    {

      rotateZ(radians(frameCount));

    }

    translate(-50,0,0);//把棒子往左移一半,讓右端放在正中心

    box(100,30,30);

  popMatrix();

}

float x = 0,y =0;

void mouseDragged()

{

  x += mouseX - pmouseX; 

  y += mouseY - pmouseY; 

}


//week06_4
void setup()
{
  size(500,400,P3D);  
}
void draw()
{
  background(255);
  translate(width/2,height/2);
  sphere(10);
  
  box(200,50,25);
  
  fill(252,131,77);
  pushMatrix();
    translate(x,y);
    if(mousePressed)rotateZ(radians(frameCount));
    translate(25,0,0);//往右推,讓左端放中心
    box(50,25,50);
  popMatrix();
}
float x = 0,y =0;
void mouseDragged()
{
  x += mouseX - pmouseX; 
  y += mouseY - pmouseY;
  println("x:"+x+"y:"+y);
}




//week06_5
void setup()
{
  size(500,400,P3D);  
}
void draw()
{
  background(255);
  translate(width/2,height/2);
  sphere(10);
  
  fill(252,131,77);
  pushMatrix();
    translate(x,y);
    box(200,50,25);

    pushMatrix();
      translate(100,0);
      rotateZ(radians(frameCount));
      translate(25,0,0);//往右推,讓左端放中心
      box(50,25,50);
    popMatrix();
   popMatrix();
}
float x = 0,y =0;
void mouseDragged()
{
  x += mouseX - pmouseX; 
  y += mouseY - pmouseY;
  println("x:"+x+"y:"+y);
}



//week06_6

void setup()

{

  size(500,400,P3D);  

}

void draw()

{

  background(255);

  translate(width/2,height/2);

  sphere(10);

  

  fill(252,131,77);

  pushMatrix();

    box(50,200,25);

    pushMatrix();

      translate(x,y);

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

      translate(100,0);

      box(200,50,25);

  

      pushMatrix();

        translate(100,0);

        rotateZ(radians(frameCount));

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

        box(50,25,50);

      popMatrix();

     popMatrix();

  popMatrix();   

}

float x = 0,y =0;

void mouseDragged()

{

  x += mouseX - pmouseX; 

  y += mouseY - pmouseY;

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

}




//week06_7

void setup()

{

  size(500,800,P3D);  //step00;把視窗變長一點,看比較完整

}

void draw()

{

  background(255);

  translate(width/2,height/2);

  sphere(10);//黑球是中心

  

  fill(252,131,77);

  pushMatrix();//step01:要先往上抬升,把關節到中心

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

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

    translate(x,y);

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

    pushMatrix();

        translate(0,-100);//掛在手臂上面,觀察到0,-100

        rotateZ(radians(frameCount));//step00:把if(mousePressed)刪掉,讓它一直旋轉

        translate(100,0);

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

  

      pushMatrix();

        translate(100,-0);

        rotateZ(radians(frameCount));

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

        box(50,25,50);

      popMatrix();

     popMatrix();

  popMatrix();   

}

float x = 0,y =0;

void mouseDragged()

{

  x += mouseX - pmouseX; 

  y += mouseY - pmouseY;

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

}









沒有留言:

張貼留言