size(800, 600);
background(200, 125, 0);
rect(50,50,700,500);
PImage img1=loadImage("http://dreamself.me/profile/h8vS.png");
PImage img2 =loadImage("http://dreamself.me/profile/ihcN.png");
image(img1, 51, 51, 165, 240);
image(img2, 585, 310, 165, 240);
上面是一般簡易基礎寫法。
下面這種是比較正確的方式寫法。
PImage imgBTS, imgCCA;
void setup() {
size(800, 600);
imgBTS=loadImage("http://dreamself.me/profile/h8vS.png");
imgCCA =loadImage("http://dreamself.me/profile/ihcN.png");
imageMode(CENTER);
}
void draw() {
background(200, 125, 0);
rect(50,50,700,500);
image(imgBTS, 156, 191, 165, 240);
image(imgCCA, mouseX, mouseY, 165, 240);
}
loadImage("http://dreamself.me/profile/ihcN.png");可以直接連結到網路上的圖片。
imageMode(CENTER); 使圖片位置為圖片中心。
並讓其中一張圖的座標位置可隨滑鼠位置移動。
沒有留言:
張貼留言