2012年10月2日 星期二

Week04,HW04

void setup(){
  size(500,400);
  fill(255,0,0);
  rect(0,0,50,50);
  fill(0,255,0);
  rect(0,50,50,50);
  fill(255,255,0);
  rect(0,100,50,50);
  fill(255,255,255);
  rect(0,150,50,50);
  fill(0,0,0);
  rect(0,200,50,50);
  fill(255,255,255);
  rect(0,250,50,50);
  fill(255,255,255);
  rect(0,300,50,50);
  fill(255,255,255);
  rect(450,0,50,50);
  fill(255,255,255);
  rect(450,50,50,50);
}
int w=5;
void draw(){
  if(mousePressed && mouseX<50 && mouseY<50) stroke(255,0,0);
  else if(mousePressed && mouseX<50 && mouseY<100) stroke(0,255,0);
  else if(mousePressed && mouseX<50 && mouseY<150) stroke(255,255,0);
  else if(mousePressed && mouseX<50 && mouseY<200) stroke(255,255,255);
  else if(mousePressed && mouseX<50 && mouseY<250) stroke(0,0,0);
  else if(mousePressed && mouseX<50 && mouseY<300) save("bbb.png");
  else if(mousePressed && mouseX<50 && mouseY<350){
  PImage file=loadImage("bbb.png");
  image(file,0,0,500,400);
   }
  else if(mousePressed && mouseX>450 && mouseY<50){
    strokeWeight(++w);
  }
  else if(mousePressed && mouseX>450 && mouseY<1000){
    strokeWeight(--w);
    if(w<2)w=2;
  }
  else if(mousePressed)  line(mouseX, mouseY, pmouseX, pmouseY);
}


 

1 則留言: