Test 1
PImage img;
size(640,433);
img = loadImage("image.png");
image(img,0,0)
下載完圖檔後,直接放入Processing
進階
在圖片上再加圖片
PImage img;
PImage img2;
size(640,433);
img = loadImage("image.png");
img2 = loadImage("img2.jpg");
image(img,0,0);
image(img2,50,50,200,150); ////從座標(50,50)開始畫 大小為200x150
Test2
PImage img;
PImage img2;
void setup()
{
size(640,223);
img = loadImage("map.png");
img2 = loadImage("pic1.png");
}
int x=0;
void draw()
{
if(mouseX>320) x--; ///當鼠標超過,圖片往右移動
image(img,x,0);
image(img2,mouseX-50/2,mouseY-50/2,54,49);
float x=250,y=200;
float vx=1.0,vy=2.5;
void setup()
{
size(500,400);
}
void draw()
{
ellipse(x,y,10,10);
x+=vx;
y+=vy;
if(x>500 || x<0) vx = -vx; ////碰到邊界折返
if(y>400 || y<0) vy = -vy; ////碰到邊界折返
}
Test4
float x=250,y=200;
float vx=0,vy=0;
void setup()
{
size(500,400);
}
void draw()
{
background(255);
if(mousePressed) line(mouseX,mouseY,x,y);
ellipse(x,y,10,10);
ellipse(mouseX,mouseY,10,10);
x+=vx;
y+=vy;
if(x>500 || x<0) vx = -vx;
if(y>400 || y<0) vy = -vy;
}
void mouseReleased()
{
vx = x-mouseX;
vy = y-mouseY;
}





沒有留言:
張貼留言