2019年9月19日 星期四

week02-2019/09/19

Week02-9:00到學校沒遲到٩(๑❛ᴗ❛๑)۶


----------------------------------------------------------------------------------------------------------------------
前置作業:
→到https://processing.org/ 下載程式(Processing)

●Step01-滑鼠移到哪 殘影移到哪
《程式碼》
void seupt(){//start()//開始設定
        size(800,300);}//跑出800*300的視窗
  void draw(){//Updata()//開始畫
        rect(mouseX,mouseY,50,20);
  }



●Step02-製作讀卡機(滑鼠移到哪,就做到哪)
《程式碼》
void setup(){//start()
  size(800,300);
  for(int x=0;x<800;x+=16){
      for(int y=0;y<300;y+=30){
          rect(x,y,16,30);
      }
  }
}
  void draw(){
    int nowX=mouseX/16*16, nowY=mouseY/30*30;  
    fill(0);
    rect(nowX,nowY,16,30);
  }
 

●Step03-製作讀卡機(按滑鼠左鍵跑出黑色格子,按右鍵跑出白色格子)
《程式碼》
void setup(){//start()
  size(800,300);
  for(int x=0;x<800;x+=16){
      for(int y=0;y<300;y+=30){
          rect(x,y,16,30);
      }
  }
}
  void draw(){
    int nowX=mouseX/16*16, nowY=mouseY/30*30;  
    if(mousePressed && mouseButton==LEFT){
    fill(0);
    rect(nowX,nowY,16,30);
  }else if(mousePressed && mouseButton==RIGHT){
    fill(255);
    rect(nowX,nowY,16,30);
      }
  }



●Step04-放入圖片1(簡單版-直接放入)
>>先到網路上找一張想要的照片,在圖片上按右鍵【複製圖片位置】


《程式碼》
PImage img=loadImage("https://d9nvuahg4xykp.cloudfront.net/-7024076502908423744/7019484979666254369.jpg");
image( img,0,0,100,100);



●Step05-放入圖片2(將視窗放大)
《程式碼》
size(500,500);
PImage img=loadImage("https://d9nvuahg4xykp.cloudfront.net/-7024076502908423744/7019484979666254369.jpg");
image( img,0,0,100,100);





●Step06-放入圖片3(將照片放大)
《程式碼》
size(500,500);
PImage img=loadImage("https://d9nvuahg4xykp.cloudfront.net/-7024076502908423744/7019484979666254369.jpg");
image( img,0,0,400,500);




●Step07-放入圖片4(畫出照片,滑鼠移到哪就畫到哪)
《程式碼》
PImage img;//declare outside
void setup(){//start()
  size(500,500);
img=loadImage("https://d9nvuahg4xykp.cloudfront.net/-7024076502908423744/7019484979666254369.jpg");
    }
  void draw(){
  image( img,mouseX,mouseY,200,200);
      }



●Step08-放入圖片5( 畫出照片,滑鼠移到哪就畫到哪-從電腦拉圖片而非用網址拉)
>在網路上先下載想要的圖片

>>在 速寫本>打開程序目錄 >data資料夾(沒有就自己新增>將照片放入data資料夾內


《程式碼》
PImage img;//declare outside
void setup(){//start()
  size(500,500);
  img=loadImage("RJ.jpg");
}
  void draw(){
  image( img,mouseX,mouseY,200,200);
  }



●Step09-做出懷舊復古Punch card

>先到網路上找Punch Card


>>將照片放入data資料夾內



>>>因為視窗大小跟圖片大小要一樣大,可以使用【小畫家】找圖片長寬


《程式碼》
PImage imgBG;
int [][] table = new int[150][30];
void setup() {
  size(1200,540);
  imgBG=loadImage("punch card.png");
}
void draw() {
  background(imgBG);
  int nowI=mouseX/10, nowJ=mouseY/20;
  if (mousePressed && mouseButton == LEFT) {
    table[nowI][nowJ]=1;
  } else if (mousePressed && mouseButton == RIGHT) {
    table[nowI][nowJ]=0;
  }
  for (int i=0; i<150; i++) {
    for (int j=0; j<30; j++) {
      fill(0);
      if (table[i][j]==1) rect(i*10, j*20, 10, 20);
    }
  }
}







沒有留言:

張貼留言

alanhc 互動技術-week17 [final]

回顧這學期的作品:  期中作業:LANDING:PLANET 賣點&特點: 炫麗的特效 物理(星球重力及降落)及粒子系統(噴射) 世界地圖可根據視角縮放 困難點: 重寫3次最終改寫成物件導向的CLASS寫法...