2023年9月21日 星期四

學校滑鼠有夠爛 - Week02 - 互動技術🦆

 Week02

https://gdms.cwa.gov.tw/





float [] HLE={-1042, -3479.7, 1003.7, -1669, -1639.6, -14219, -3655.1, -4917, 9363.2, -4271.8, -24, 681}
int N = 12;
void setup(){
  size(500,500);
}
void draw(){
  background(#FFFFF2);
  float dx = HLE[frameCount%N]/100;
  rect(200+dx,200,100,100);
}



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);
}


圖片命名chair,檔案為jpg
要把圖片拉進程式碼
PImage img=loadImage("chair.jpg");
size(300,300);
image(img,0,0);





滑鼠在視窗中移動,圖片也會跟著動
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("girl.png");
  imgBox = loadImage("back.png");
}

void draw() {
  imageMode(CENTER);
  if (mousePressed) {
    image(imgBox, mouseX, mouseY);
  } else {
    image(img, 300, 300, 220, 300);
  }
}


沒有留言:

張貼留言