點刮
PImage imgBG;
PImage imgBlack;
void setup() {
size(800, 600);
imgBG=loadImage("imgBG.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);
}
}


沒有留言:
張貼留言