互動技術概論
week8
重點語法:
找畫面像素點
pixels[]
舉例:
找像素是pink的向素點
color pink = color(255, 102, 204);
loadPixels();
for (int i = 0; i < (width*height/2)-width/2; i++) {
pixels[i] = pink;
}
updatePixels();
舉例:
點選畫面區塊,顯示點選顏色
PImage img;
color nowColor;
void setup() {
size(300, 200);
img=loadImage("cloud.png");
}
void draw() {
image(img,0,0);
fill(nowColor);
rect(0,0,30,30);
}
void mouseMoved(){
loadPixels();
int now = width * mouseY + mouseX;
nowColor = pixels[now];
}


沒有留言:
張貼留言