2012年9月23日 星期日

HW03

HW03-A
HW03-B
(A)
// Circle follows the cursor (the cursor position is
 // implied by the crosshairs around the illustration)
 void setup() {
   size(800, 600);
   smooth();
   noStroke();
 }
 void draw() {
   background(126);
   for(int i=100;i<=800;i+=200)
{
   
  for(int j=100;j<=600;j+=200)
  {
   fill(215,185,200);
    ellipse(i, j,200,195);  // Bottom circle
   fill(255,255,255);
   ellipse(i+(mouseX-400)/20,j+(mouseY-300)/20, 150,140);  // Middle circle
   fill(0,0,0);
   ellipse(i+(mouseX-400)/10,j+(mouseY-300)/10, 50, 45);
 }
 }
 }

(B)

// Draw a line between the current and previous positions
  void setup() {
    size(500, 400);
    fill(255,0,0);
    rect(0,0,50,50);
    fill(255,255,128);
    rect(0,50,50,50);
    fill(128,255,255);
    rect(0,100,50,50);
    fill(255,128,255);
    rect(0,150,50,50);
    fill(255,128,0);
    rect(0,200,50,50);


    strokeWeight(8);
    smooth();
  }
  void draw() {
    //background(204);
    if (mousePressed == true&&mouseButton == LEFT)
    {
    line(mouseX, mouseY, pmouseX, pmouseY);
    {
    if(mouseX>0&&mouseY>0&&mouseX<50&&mouseY<50)
    stroke(255,0,0);
    if(mouseX>0&&mouseY>50&&mouseX<50&&mouseY<100)
    stroke(255,255,128);
    if(mouseX>0&&mouseY>100&&mouseX<50&&mouseY<150)
    stroke(128,255,255);
    if(mouseX>0&&mouseY>150&&mouseX<50&&mouseY<200)
    stroke(255,128,255);
    if(mouseX>0&&mouseY>200&&mouseX<50&&mouseY<250)
    stroke(255,128,0);
    if(!(mouseX<50+10&&mouseY<250+10))
    line(mouseX, mouseY, pmouseX, pmouseY);
 
    }
    }
  }

心得:
小畫家初嘗試,覺得很好玩,自己也可以寫一個簡易版的小畫家
位置的控制要多注意
跟滑鼠的配合也是

沒有留言:

張貼留言