2024年11月18日 星期一

聽均一席話如聽一席話 Week011 11160712

 //week11_01_optical_illusion_ball_analyze

PImage img =loadImage("ball.png");
size(640,569);
background(img);
fill(0);
for(float x=2;x<640;x+=30){
  for(float y=6.3;y<569;y+=13.748){
    ellipse(x,y,11,11);
  }
}
for(float x=2+15;x<640;x+=30){
  for(float y=6.3;y<569;y+=13.748){
    ellipse(x,y,11,11);
  }
}


//week11_02_optical_illusion_draw
size(600,600);
noStroke();
fill(236,152,52);//color1
rect(0,0,300,300);

fill(122,202,249);//color2
rect(300,0,300,300);

fill(129,241,128);//color3
rect(0,300,300,300);

fill(230,95,115);//color4
rect(300,300,300,300);

fill(122,202,249);//color2
for(float y=0;y<300;y+=15){
  for(float x=0;x<300;x+=30){
    ellipse(x+7,y,11,11);
    ellipse(x+22,y+7,11,11);
  }
}

fill(236,152,52);//color1
for(float y=0;y<300;y+=15){
  for(float x=0;x<300;x+=30){
    ellipse(300+x+7,y,11,11);
    ellipse(300+x+22,y+7,11,11);
  }
}

fill(230,95,115);//color4
for(float y=0;y<300;y+=15){
  for(float x=0;x<300;x+=30){
    ellipse(x+7,y+307,11,11);
    ellipse(x+22,y+7+307,11,11);
  }
}

fill(129,241,128);//color3
for(float y=0;y<300;y+=15){
  for(float x=0;x<300;x+=30){
    ellipse(300+x+7,y+307,11,11);
    ellipse(300+x+22,y+7+307,11,11);
  }
}


//week11_03_optical_illusion_draw_better
size(600,600);
noStroke();
fill(236,152,52);//color1
rect(0,0,300,300);

fill(122,202,249);//color2
rect(300,0,300,300);

fill(129,241,128);//color3
rect(0,300,300,300);

fill(230,95,115);//color4
rect(300,300,300,300);

fill(191,156,205);
ellipse(150,150,150,150);
ellipse(450,150,150,150);
ellipse(150,450,150,150);
ellipse(450,450,150,150);

for(float y=0;y<600;y+=15){
  for(float x=0;x<600;x+=30){
    if(x+7<300 && y+7<300)fill(122,202,249);//color2
    else if(x+7>300 && y+7<300)fill(236,152,52);//color1
    else if(x+7<300 && y+7>300)fill(230,95,115);//color4
    else if(x+7>300 && y+7>300)fill(129,241,128);//color3
    ellipse(x+7,y,11,11);
    ellipse(x+22,y+7,11,11);
  }
}

//week11_04_ArrayList_for_loop
ArrayList<Integer>a=new ArrayList<Integer>();

a.add(3);
a.add(5);
a.add(7);
for(Integer i:a){//進階for迴圈
  println(i);
}
for(int i=0;i<a.size();i++){//比較傳統的for迴圈
  println(a.get(i));//你要用.get(i)取出你要的那格
}


//week11_05_ArrayList_class_Card_draw
class Card{
  int x,y;
  void draw(){
    rect(x,y,100,150);
  }
}
Card card1= new Card();
void setup(){
  size(500,400);
  card1.x=100;
  card1.y=100;
}
void draw(){
  card1.draw();
}


//week11_06_ArrayList_class_Card_x_y_draw
class Card{
  int x,y;
  Card(int _x,int _y){
    x= _x;y= _y;
  }
  void draw(){
    rect(x,y,100,150);
  }
}
Card card1= new Card(100,100);
void setup(){
  size(500,400);
}
void draw(){
  card1.draw();
}

沒有留言:

張貼留言