2012年9月23日 星期日

HW03



哈哈哈!我學會做小畫家了!第一個眼球會動的程式我還特地做的範例顏色一模一樣......害我做了好久。
我認真覺得我的「增」寫得非常有個性!

第一題程式碼:
void setup(){
  smooth();
  noStroke();
size(800,600);

}
void draw(){
background(180);
for (int y = 100; y <= 600; y +=200 ) {
for (int x = 100; x <= 800; x +=200) {
  fill(246,148,123);
ellipse(x,y,200,200);
fill(54,157,202);
ellipse(x+(mouseX-400)/20,y+(mouseY-300)/20,100,100);
fill(0);
ellipse(x+(mouseX-400)/8,y+(mouseY-300)/8,40,40);
}
}
}


第二題:

void setup(){
size(500,400);
background(255);
fill(255,0,0);
rect(0, 0, 50, 50);
fill(0,255,0);
rect(0, 50, 50, 50);
fill(0,0,255);
rect(0, 100, 50, 50);
fill(0);
rect(0, 150, 50, 50);
fill(143);
rect(0,200,50,50);
strokeWeight(8);
smooth();

}

void draw(){

  if (mousePressed == true) {
    if(mouseX<=50 && mouseY<=50)
    {
      stroke(255,0,0);
    }
     if(mouseX<=50 && mouseY>50&& mouseY<=100)
    {
      stroke(0,255,0);
    }
    if(mouseX<=50 && mouseY>100 && mouseY<=150)
    {
      stroke(0,0,255);
    }
    if(mouseX<=50 && mouseY>150 && mouseY<=200)
    {
      stroke(0);
    }
    if(mouseX<=50 && mouseY>200 && mouseY<=250)
    {
      stroke(143);
    }
   if(!(mouseX<=50+10&&mouseY<=250+10))
   line(mouseX,mouseY,pmouseX,pmouseY);
  }

}

沒有留言:

張貼留言