2019年9月19日 星期四

06160805的課堂筆記

2019互動技術概論week02

注意:
size(w,h); //頁面大小
line(x,y,x,y); //線
rect(x,y,w,h); //矩形
circle(x,y,r); //圓形
ellipse(x,y,w,h); //橢圓
fill(R,G,B); //在矩形,圓形...等裡面的顏色
background(R,G,B); //頁面背景的顏色



打開processing

改字體大小:文件→偏好設定→編輯器字體大小


程式碼

void setup(){ //start()
  size(800,300);
}
void draw(){ //update()
  rect(mouseX,mouseY,50,20); //滑鼠到任何一個位置,畫50x20的矩形
}


畫出很多30x16的矩形

void setup(){//start()
  size(800,300);
}
void draw(){//update()
 for(int x=0;x<800;x+=16){
      for(int y=0;y<300;y+=30){
          rect(x,y,16,30);
      }
  }
}


將滑鼠放上去,就能用黑色將框框填滿

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(){//update()
  int nowX=mouseX/16*16,nowY=mouseY/30*30; //為了將數字找到正確的位置
  fill(0); //黑色
  rect(nowX,nowY,16,30);
}



要按滑鼠才會出現顏色,不會自動有顏色

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(){//update()
  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);
  }
}



顯示圖片

PImage img;
void setup(){
  size(500,500);
  img=loadImage("dora.jpg");
}
void draw(){
  image(img,0,0,300,300);
}



畫影像

PImage img;
void setup(){
  size(500,500);
  img=loadImage("dora.jpg");
}
void draw(){
  image(img,mouseX,mouseY,300,300); //可以畫出很多圖片
}


開始打洞

PImage imgBG;
int [][] table=new int[45][10];
void setup(){
  size(711,377);
  imgBG=loadImage("card.jpg.jpg");
}
void draw(){
  background(imgBG);
  int nowI=mouseX/16,nowJ=mouseY/30;
  if(mousePressed && mouseButton==LEFT){
    table[nowI][nowJ]=1;
  }
  else if(mousePressed && mouseButton==RIGHT){
    table[nowI][nowJ]=0;
  }
  for(int i=0;i<45;i++){
      for(int j=0;j<10;j++){
          fill(0);
          if(table[i][j]==1)rect(i*16,j*30,16,30);
      }
  }
}




















沒有留言:

張貼留言

alanhc 互動技術-week17 [final]

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