自製小畫家
刮畫版本1
刮畫版本2
小畫家
void setup(){
size(800,600);
background(#074308);
}
float myshishi=1;
color myStroke=color(0);
void draw(){
stroke(0); strokeWeight(1);
fill(255,0,0);rect(0,0,80,80);
fill(0,255,0);rect(0,80,80,80);
fill(0,0,255);rect(0,160,80,80);
fill(0,0,0);rect(0,240,80,80);
stroke(myStroke); strokeWeight(myshishi);
}
void mousePressed(){
if(mouseX<80 && mouseY<80){myStroke=color(255,0,0);}
if(mouseX<80 && mouseY>80 && mouseY<160){myStroke=color(0,255,0);}
if(mouseX<80 && mouseY>160 && mouseY<240){myStroke=color(0,0,255);}
if(mouseX<80 && mouseY>240 && mouseY<320){myStroke=color(0,0,0);}
if(mouseX>700) myshishi=mouseY/50;
}
void mouseDragged(){
line(mouseX,mouseY,pmouseX,pmouseY);
}
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();
}
刮畫2
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);
}
}




沒有留言:
張貼留言