2020年3月27日 星期五

小插曲 背景的格式大小要一樣~


PImage imgBG;
void setup()
{
  size(768,1280);
  imgBG=loadImage("background.jpg");
}
void draw()
{
  background(imgBG);

}
void mousePressed()
{
  x[0] = mouseX;
  y[0] = mouseY;
}

PImage imgBG;
int []x={0,0,0,0,0};
int []y={0,0,0,0,0};
int n=0;
void setup()
{
  size(768,1280);
  imgBG=loadImage("background.jpg");
}
void draw()
{
  background(imgBG);
  for(int i=0;i<5;i++)
  {
    circle(x[i], y[i] ,40);
  }
}
void mousePressed()
{
  if(n>=5)return;
  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);
  }
}


沒有留言:

張貼留言