2015年9月21日 星期一

Week02_02160571_黃冠瑛

小畫家

void setup(){
  size(800, 600);
}
void draw(){
  line(mouseX, mouseY, pmouseX, pmouseY);
}
void setup(){
  size(800, 600);
  background(#9A80F0);//背景顏色
}
void draw(){
  if(mousePressed)//滑鼠按壓
  line(mouseX, mouseY, pmouseX, pmouseY);
}


void setup(){
  size(800, 600);//視窗大小
  background(255);//背景顏色
  stroke(0);//筆刷顏色
}
void draw(){
  fill(0,255,0);rect(0,0,100,100);//更改顏色格子
  fill(0,0,255);rect(0,100,100,100);
  fill(255,255,0);rect(0,200,100,100);
  fill(255,0,0);rect(0,300,100,100);
  fill(0,0,0);rect(0,400,100,100);
}
void mouseDragged(){
  line(mouseX, mouseY, pmouseX, pmouseY);
}
void mousePressed(){
  if(mouseX <100 && mouseY<100)//綠色
  {stroke(0,255,0);}
  else if(mouseX <100 && mouseY<200)//藍色
  {stroke(0,0,255);}
  else if(mouseX <100 && mouseY<300)//黃色
  {stroke(255,255,0);}
  else if(mouseX <100 && mouseY<400)//紅色
  {stroke(255,0,0);}
  else if(mouseX <100 && mouseY<500)//黑色
  {stroke(0,0,0);}
}
background


PImage imgBG;
PImage imgBlack;
void setup(){
  size(800, 600);
  imgBG=loadImage("colorBG.jpg");
  imgBlack=createImage(800, 600,ARGB);
 
  imgBlack.loadPixels();
  for(int i=0; i<imgBlack.pixels.length; i++){
    imgBlack.pixels[i]=color(0,0,0,255);
  }
  imgBlack.updatePixels();
}
void draw(){
  image(imgBG, 0, 0, width, height);
  image(imgBlack, 0, 0, width, height);
}
void mouseDragged(){
  imgBlack.loadPixels();
  imgBlack.pixels[mouseX+mouseY*width]= color(0, 0, 0, 0);
  imgBlack.updatePixels();
}
 
void setup(){
  size(800, 600);
  colorMode(HSB, 800);
  background(0);
  strokeWeight(2);
}
void draw(){
  if(mousePressed){
    stroke(mouseX, mouseY, 800);
    line(mouseX, mouseY, pmouseX, pmouseY);
  }
}


沒有留言:

張貼留言