2013年9月15日 星期日

week02


1.processing啟動

2.試 for迴圈

執行結果:

void setup(){
    size(600,400);
}

void draw(){
    for(int x=0;x<=600;x+=100){
      for(int y=0;y<=400;y+=100){
        rect(x,y,100,100);
       // ellipse(x+50,y-50,55,55);
      }
    }
}
------------------------------------------------------------------------------------------------------------
課堂作業01 畫出不同的圖形
執行結果:


void setup(){
    size(600,400);
}

void draw(){
    for(int x=0;x<=600;x+=100){
      for(int y=0;y<=400;y+=100){
        rect(x,y,100,100);
        ellipse(x+50,y-50,55,55);
        triangle(x,y,x+100,y,x+50,y+100);
      }
    }
}
------------------------------------------------------------------------------------------------------------
課堂作業02 使用顏色fill()
執行結果:

void setup(){
    size(600,400);
}

void draw(){
    for(int x=0;x<=600;x+=100){
      for(int y=0;y<=400;y+=100){
        fill(0,0,255);
        rect(x,y,100,100);
        fill(255,255,0);
        ellipse(x+50,y-50,55,55);
        fill(255,0,0);
        triangle(x,y,x+100,y,x+50,y+100);
      }
    }
}
------------------------------------------------------------------------------------------------------------
課堂作業03 加入滑鼠互動
執行結果:












void setup(){
    size(600,400);
}

void draw(){
    for(int x=0;x<=600;x+=100){
      for(int y=0;y<=400;y+=100){
        fill(mouseY,0,mouseX);
        rect(x,y,100,100);
        fill(255,255,0,dist(x,y,mouseX, mouseY));
        ellipse(x+50,y-50,50,50);
        fill(255,0,0);
        triangle(x,y,x+100,y,x+50,y+100);
      }
    }
}
------------------------------------------------------------------------------------------------------------
課堂作業04 加入隨機變數的應用
執行結果:
void setup(){
    size(600,400);
}

void draw(){
    for(int x=0;x<=600;x+=100){
      for(int y=0;y<=400;y+=100){
        fill(mouseY,0,mouseX);
        rect(x,y,100,100);
        fill(255,255,0,dist(x,y,mouseX, mouseY));
        ellipse(x+50,y-50,random(50),50);
        fill(255,0,0);
        triangle(x,y,x+100,y,x+50,y+100);
      }
    }
}

沒有留言:

張貼留言