2020年3月27日 星期五

暴躁滷肉飯

Week04-


1.將圖片匯入Processing當背景
2如何一直有圓圈出現
3.如何讓圈圈變大
4.如何讓圈圈每點一次,顏色就不一樣
5.使用陣列填顏色




1.將圖片匯入Processing當背景




選一張自己喜歡的圖片另存後開啟小畫家
之後會發現下方有一個像素
將數字填入size(一定要填正確 ! 不然程式會當掉 !)










接著做出圓圈  能做出5個圈圈






















以上是能讓圈圈像氣球一樣上升


2.如何一直有圓圈出現





















以上是圈圈一直替換,雖然只有5個,但當按完5個卻不會當機。


PImage imgBG;
int []x={0,0,0,0,0};
int []y={0,0,0,0,0};
int n=0;
void setup(){
   size( 191,264);
   imgBG=loadImage("BG.jpg");
}
void draw(){
   background(imgBG);
   for(int i=0;i<5;i++){
   circle( x[i], y[i], 40);
   y[i]--;
   }
}
void mousePressed(){
   x[n]=mouseX;
   y[n]=mouseY;
   n = (n+1)%5;
}













int []a={1,1,1,0};
size(400,100);
for(int i=0;i<4;i++)
{
   if(a[i]==1) fill(255,0,0);
   else fill(128);
   rect(i*100,0,100,100);
}











int [][]a={
  {1,1,1,0},
  {0,1,0,1},
  {0,0,1,1},
  {1,1,0,1},
};
size(400,400);
for(int i=0;i<4;i++)
{
  for(int j=0;j<4;j++)
  {
   if(a[i][j]==1) fill(255,0,0);
   else fill(128);
   rect(j*100,i*100,100,100);
  }
}
PImage imgBG;
int []x={0,0,0,0,0};
int []y={0,0,0,0,0};
int []r={5,5,5,5,5};
int n=0;
void setup(){
   size( 191,264);
   imgBG=loadImage("BG.jpg");
}
void draw(){
   background(imgBG);
   for(int i=0;i<5;i++){
   circle( x[i], y[i], r[i]);
   }
   if(mousePressed) r[now]++;
}
int now=0;
void mousePressed(){
   x[n]=mouseX;
   y[n]=mouseY;
   r[n]=5;
   now=n;
   n = (n+1)%5;
}



PImage imgBG;
int []x=new int[1000];
int []y=new int[1000];
int []r=new int[1000];
color []c=new color[1000];
int n=0;
void setup(){
   size( 191,264);
   imgBG=loadImage("BG.jpg");
}
void draw(){
   background(imgBG);
   for(int i=0;i<n;i++){
     fill(c[i]);
     circle( x[i], y[i], r[i]);
     y[i]--;
   }
   if(mousePressed) r[now]+=2;
}
int now=0;
void mousePressed(){
   x[n]=mouseX;
   y[n]=mouseY;
   r[n]=10;
   c[n]=color( random(255),random(255),random(255));
   now=n;
   n ++;
}

沒有留言:

張貼留言