week02
註冊中央氣象署網站
輸入資料
物體左右晃動
加上上下晃動
float [] HLE = { -1042, -3479.7, 1003.7, -1669, -1639.6, -14219, -3655.1, -4917, 9363.2, -4271.8, -24, 681};
float [] HLN = { -17090, -13711, -22888, -19631, -23818, -18573, -19636, -15648, -18256, -15721, -17776, -15581};
int N = 12;
void setup(){
size(500,500);
frameRate(10);
}
void draw(){
background(#FFFFF2);
float dx = HLE[frameCount%N]/100;
float dy = HLN[frameCount%N]/100;
rect(200+dx,300+dy, 100,100);
}
讀入一張圖片
PImage img = loadImage("chair.jpg");
size(300,300);
image(img, 0, 0);
PImage img = loadImage("chair.jpg");
size(300,300);
image(img, 0, 0, 100, 100);
拉動圖片
PImage img ;
void setup(){
size(600,600);
img = loadImage("chair.jpg");
}
void draw(){
image(img, mouseX, mouseY, 300, 300);
}
PImage img, imgBox ;
void setup(){
size(600,600);
img = loadImage("p5.jpg");
imgBox = loadImage("Box.png");
}
void draw(){
imageMode(CENTER);
if(mousePressed){
image(imgBox, mouseX, mouseY);
}else{
image(img, 300, 300, 200, 200);
}
}









沒有留言:
張貼留言