วันอาทิตย์ที่ 30 สิงหาคม พ.ศ. 2558

Lab 3 : Calculate grade from score

float score=65.8;
void setup() {
  size(300, 300);
}
void draw() {
  show_score(5,100);
  calculate_grade(70,200);
}
void show_score(int x,int y){
  fill(0);
  textSize(30);
  text("YOUR SCORE : "+score,x,y);
}
void calculate_grade(int x,int y) {
  fill(0);
  textSize(30);
  if (score >= 80 && score <= 100) {
    text("YOU GET A",x,y);
  } else if (score >= 70 && score <= 79) {
    text("YOU GET B",x,y);
  } else if (score >= 60 && score <= 69) {
    text("YOU GET C",x,y);
  } else if (score >= 50 && score <= 69) {
    text("YOU GET D",x,y);
  } else if (score >= 0 && score <= 49) {
    text("YOU GET F",x,y);
  } else {
    text("NOT WORKING...",x,y);
  }
}


Lab 3 : Balloon

void setup(){
  size(300,300);
}
void draw() {
  background(#BFEBF0);
  int x = mouseX;
  int y = mouseY;
  draw_balloon(x, y);
  if (y < 100) {
    fill(#DD0000);     //red
  }else if(y > 100 && y < 200){
    fill(#FFF300);     //yellow
  }
  else{
    fill(#00DD00);     //green
  }
}
void draw_balloon(int x, int y) {
  int radius = 100;
  int string_length = 150;
  line(x, y, x, y + string_length);
  ellipse(x, y, radius, radius);
}



Lab 2 : Syntax error

1. Missing a semicolon
     สาเหตุ ลืมใส่สัญลักษณ์ semicolon (;) ด้านหลังคำสั่ง
     วิธีแก้ ใส่ semicolon (;) ตรงที่มีแจ้งเตือนแถบสีเหลือง

2. The variable "..." does not exist
     สาเหตุ ใส่ชื่อตัวแปรไม่ตรงตามที่เราได้กำหนดไว้
                ประกาศตัวแปรแบบ local ทำให้ฟังก์ชันที่ต้องใช้ค่าตัวแปรหาค่าตัวแปรไม่เจอ
     วิธีแก้ แก้ไขชื่อตัวแปรให้ตรงกัน
              แก้ไขการประกาศตัวแปรเป็นแบบ global

3. The function "..." does not exist 
     สาเหตุ ใส่ชื่อฟังก์ชันไม่ตรงตามชื่อฟังก์ชันของ System function
     วิธีแก้ แก้ไขชื่อฟังก์ชันให้ถูกต้อง


Lab 2 : Calculate body mass index (BMI) (function)


  float weight;
  float Hcm;
  float Hm;
  float bmi;
void setup() {
  size(300, 300);
  background(255);
  //setting variable
  weight=39;         //weight-kilogram
  Hcm=151;           //height-centimeter
  //calculate
  Hm=Hcm/100;
  bmi=weight/(Hm*Hm);
  //function call
  calculate_bmi(5,20);

}
void calculate_bmi(int x,int y) {
  //result
  fill(0);
  textSize(20);
  text("Weight : "+weight,x,y);
  text("Height(centimeter) : "+Hcm,x,y+30);
  text("BMI : "+bmi,x,y+60);
}


Lab 2 : Calculate circumference and area of a circle (function)

int dia;
float area;
int rad;
float cir;
void setup() {
  size(300, 300);
  background(255);
  //setting variable
  dia=50;     //diameter
  //calculate
  rad=dia/2;
  area=3.14*rad*rad;
  cir=3.14*dia;
  //function call
  calculate_circle(5, 20);
}
  void calculate_circle(int x, int y) {
  //result
  fill(0);
  textSize(20);
  text("Diameter : "+dia, x, y);
  text("Area : "+area, x, y+30);
  text("Circumference : "+cir, x, y+60);
}


Lab 2 : Digital Clock

void setup() {
  size(300, 300);
}
void draw() {
  draw_clock();
}
void draw_clock() {
  background(200);
  fill(100);
  textSize(85);
  text("CLOCK", 0, 100);
  fill(0);
  textSize(75);
  text(hour()+":"+minute()+":"+second(), 0, 200);
  fill(255);
  textSize(20);
  text("hour      minute     second", 30, 250);
}


Lab 2 : My favorite musics (animetion)

int moveX=0;
int moveY=0;
int count=2;
int result;
void setup() {
  size(600, 350);
}
void draw() {
  frameRate(2);
  result=count%2;
  count=count+1;
  draw_FerrisWheel();
  if (result==0) {
    fill(0);
    text_PASSENGER();
    fill(#7a92be);
    text_LetHerGo();
  }
  if (result==1) {
    fill(#7a92be);
    text_PASSENGER();
    fill(0);
    text_LetHerGo();
  }
}
void draw_FerrisWheel() {
  background(#7a92be);
  //Ferris wheel
  fill(#7a92be);
  stroke(255);
  strokeWeight(3);
  //wheel_1
  ellipse(100+moveX, 100+moveY, 200, 200);
  //wheel_2
  ellipse(100+moveX, 100+moveY, 180, 180);
  //wheel_3
  ellipse(100+moveX, 100+moveY, 100, 100);
  //wheel_4
  fill(255);
  ellipse(100+moveX, 100+moveY, 30, 30);
  //bench
  noStroke();
  //benchPink
  fill(#fabeca);
  ellipse(50+moveX, 20+moveY, 10, 10);
  ellipse(50+moveX, 40+moveY, 40, 40);
  //benchYellow
  fill(#fff3a9);
  ellipse(180+moveX, 50+moveY, 10, 10);
  ellipse(180+moveX, 70+moveY, 40, 40);
  //benchViolet
  fill(#cbb1ce);
  ellipse(160+moveX, 175+moveY, 10, 10);
  ellipse(160+moveX, 195+moveY, 40, 40);
  //benchGreen
  fill(#b5efd6);
  ellipse(20+moveX, 150+moveY, 10, 10);
  ellipse(20+moveX, 170+moveY, 40, 40);
  //pole
  stroke(255);
  strokeWeight(6);
  //poleL
  line(85+moveX, 100+moveY, 0+moveX, 350+moveY);
  //poleR
  line(115+moveX, 100+moveY, 200+moveX, 350+moveY);
}
void text_PASSENGER() {
  //text"PASSENGER"
  textSize(60);
  text("PASSENGER", 210+moveX, 70+moveY);
}
void text_LetHerGo() {
  textSize(100);
  //text"LET"
  text("LET", 400+moveX, 170+moveY);
  //text"HER"
  text("HER", 300+moveX, 250+moveY);
  //text"GO"
  text("GO", 200+moveX, 330+moveY);
}



Lab 2 : My favorite books (animetion)

int wide=0;
int high=0;
int start=50;
void setup() {
  size(350, 450);
}
void draw() {
  draw_wolf();
  frameRate(10);
  wide=(wide+10)%width;

}
void draw_wolf() {
  background(#a19d8c);
  //WHITE_FANG
  fill(#2f4940);
  textSize(80);
  //text-WHITE
  text("WHITE", 40, 75);
  //text-FANG
  text("FANG", 60, 150);
  //JACK_LONDON
  textSize(30);
  //text-JACK LONDON
  text("JACK LONDON", 70, 425);
  //frame
  noStroke();
  //frame-1
  fill(#2f4940);
  rect(40, 170, 270, 225);
  //frame-2
  fill(#a19d8c);
  rect(45, 175, 260, 215);
  //frame-3
  fill(#2f4940);
  rect(50, 180, 250, 205);
  //wolf :  begin at left to right
  fill(#d5cfb7);
  beginShape();
  vertex(50+wide-start, 345);   //01-no move
  //over
  vertex(120+wide-start, 276);  //02
  vertex(214+wide-start, 254);  //03
  vertex(238+wide-start, 230);  //04
  vertex(229+wide-start, 198);  //05
  vertex(245+wide-start, 210);  //06
  vertex(240+wide-start, 197);  //07
  vertex(255+wide-start, 210);  //08
  vertex(289+wide-start, 180);  //09
  //under
  vertex(293+wide-start, 190+high);  //10
  vertex(285+wide-start, 220+high);  //11
  vertex(297+wide-start, 207+high);  //12
  vertex(300+wide-start, 215+high);  //13
  vertex(280+wide-start, 240+high);  //14
  vertex(245+wide-start, 322+high);  //15
  vertex(248+wide-start, 355+high);  //16
  vertex(265+wide-start, 368+high);  //17
  vertex(250+wide-start, 370+high);  //18
  vertex(237+wide-start, 348+high);  //19
  vertex(240+wide-start, 370+high);  //20
  vertex(255+wide-start, 385+high);  //21
  vertex(240+wide-start, 385+high);  //22
  vertex(215+wide-start, 325+high);  //23
  vertex(155+wide-start, 315+high);  //24
  vertex(135+wide-start, 330+high);  //25
  vertex(135+wide-start, 347+high);  //26
  vertex(155+wide-start, 360+high);  //27
  vertex(135+wide-start, 360+high);  //28
  vertex(125+wide-start, 330+high);  //29
  vertex(110+wide-start, 340+high);  //30
  vertex(105+wide-start, 365+high);  //31
  vertex(120+wide-start, 377+high);  //32
  vertex(105+wide-start, 378+high);  //33
  vertex(95+wide-start, 340+high);   //34
  vertex(100+wide-start, 330+high);  //35
  endShape();
}




Lab 2 : My favorite movies (animetion)

int swW=0;
int swH=0;
int moveX=0;
int moveY=0;
void setup() {
  size(450, 300);
}
void draw() {
  background(#ffd800);
  text_BILL();
  draw_sword();
  text_KILL();
  //text_BILL();
  frameRate(20);
  moveX=(moveX-10)%width;
}
void draw_sword() {
  //sword
  noStroke();
  fill(0);
  //black0-1
  rect(350+moveX, 0+moveY, 50+swW, 140+swH);
  //black0-2
  rect(348+moveX, 140+moveY+swH, 54+swW, 30+swH);
  //black0-3
  rect(330+moveX, 170+moveY+swH, 90+swW, 8+swH);
  //black0-4
  rect(348+moveX, 178+moveY+swH, 54+swW, 3+swH);
  //white0-5
  fill(255);
  rect(350+moveX, 181+moveY+swH+swH, 50+swW, 10+swH);
  //black0-6
  fill(0);
  rect(348+moveX, 191+moveY+swH, 54+swW, 3+swH);
  //black0-7
  rect(350+moveX, 194+moveY+swH, 50+swW, 106+swH);
  //shadow
  //white1-1
  fill(255);
  rect(350+moveX, 0+moveY, 30+swW, 140+swH);
  //white1-2
  triangle(360+moveX, 194+swH+moveY, 390+swW+moveX, 194+swH+moveY, 375+moveX+(swW/2), 204+swH+moveY);
  //white1-3
  quad(360+moveX, 219+swH+moveY, 375+(swW/2)+moveX, 209+swH+moveY, 390+swW+moveX, 219+swH+moveY, 375+moveX, 229+swH+moveY);
  //white1-4
  quad(360+moveX, 244+swH+moveY, 375+(swW/2)+moveX, 234+swH+moveY, 390+swW+moveX, 244+swH+moveY, 375+moveX, 254+swH+moveY);
  //white1-5
  quad(360+moveX, 269+swH+moveY, 375+(swW/2)+moveX, 259+swH+moveY, 390+swW+moveX, 269+swH+moveY, 375+moveX, 279+swH+moveY);
  //white1-6
  quad(360+moveX, 294+swH+moveY, 375+(swW/2)+moveX, 284+swH+moveY, 390+swW+moveX, 294+swH+moveY, 375+moveX, 304+swH+moveY);
}
void text_KILL() {
  textSize(150);
  //text-KILL
  fill(#ca0101);
  text("KILL", 10, 140);
}
void text_BILL() {
  textSize(150);
  fill(0);
  text("BILL", 10, 270);
  //cut
  stroke(#ffd800);
  strokeWeight(3);
  line(0, 260, 330, 180);
}



Lab 2 : Battery (mouseClicked)

int energy=255;
void setup() {
  size(300, 300);
}
void draw() {
  background(255);
  //function call
  draw_battery(70, 50);
  draw_positive(245, 60);
  draw_minus(5, 75);
  if (energy == 255) {
    textSize(40);
    text("ENERGY : 0%", 5, 250);
  } else {
    textSize(40);
    text("ENERGY : 100%", 5, 250);
  }
}
void draw_battery(int x, int y) {
  float batW=150;
  float batH=batW/2;
  //battery
  fill(energy);
  rect(x, y, batW, batH);
  //battery's polar
  fill(0);
  rect(batW+x, (batH/3)+y, 10, batH/3);
}
void draw_positive(int x, int y) {
  float sizePosi;
  //setting variable
  sizePosi=50;
  //positive
  fill(0);
  //vertical
  rect(x+(sizePosi/3), y, sizePosi/3, sizePosi);
  //horizon
  rect(x, y+(sizePosi/3), sizePosi, sizePosi/3);
}
void draw_minus(int x, int y ) {
  int sizeMinus = 50;
  fill(0);
  rect(x, y, sizeMinus, sizeMinus/3);
}
void mouseClicked() {
  if (energy == 255) {
    energy = #00FF00;
  } else {
    energy = 255;
  }
}


Lab 2 : Positive sign (animetion)

int y=0;
void setup() {
  size(100, 300);
}
void draw() {
  background(255);
  frameRate(10);
  //function call
  draw_positive(25, y);
  y=(y+10)%height;
}
void draw_positive(int x, int y) {
  float sizePosi;
  //setting variable
  sizePosi=50;
  //positive
  fill(0);
  //vertical
  rect(x+(sizePosi/3), y, sizePosi/3, sizePosi);
  //horizon
  rect(x, y+(sizePosi/3), sizePosi, sizePosi/3);
}


วันอาทิตย์ที่ 23 สิงหาคม พ.ศ. 2558

Lab 1 : My favorite musics (Variable-move)

void setup() {
  size(600, 350);
  background(#7a92be);
  int moveX;
  int moveY;
  //setting variable
  moveX=0;
  moveY=0;
  //Ferris wheel
  fill(#7a92be);
  stroke(255);
  strokeWeight(3);
    //wheel_1
  ellipse(100+moveX, 100+moveY, 200, 200);
    //wheel_2
  ellipse(100+moveX, 100+moveY, 180, 180);
    //wheel_3
  ellipse(100+moveX, 100+moveY, 100, 100);
    //wheel_4
  fill(255);
  ellipse(100+moveX, 100+moveY, 30, 30);
  //bench
  noStroke();
    //benchPink
  fill(#fabeca);
  ellipse(50+moveX, 20+moveY, 10, 10);
  ellipse(50+moveX, 40+moveY, 40, 40);
    //benchYellow
  fill(#fff3a9);
  ellipse(180+moveX, 50+moveY, 10, 10);
  ellipse(180+moveX, 70+moveY, 40, 40);
    //benchViolet
  fill(#cbb1ce);
  ellipse(160+moveX, 175+moveY, 10, 10);
  ellipse(160+moveX, 195+moveY, 40, 40);
    //benchGreen
  fill(#b5efd6);
  ellipse(20+moveX, 150+moveY, 10, 10);
  ellipse(20+moveX, 170+moveY, 40, 40);
  //pole
  stroke(255);
  strokeWeight(6);
    //poleL
  line(85+moveX, 100+moveY, 0+moveX, 350+moveY);
    //poleR
  line(115+moveX, 100+moveY, 200+moveX, 350+moveY);
  //text
  fill(0);
    //text"PASSENGER"
  textSize(60);
  text("PASSENGER", 210+moveX, 70+moveY);
    //text"LET HER GO"
  textSize(100);
      //text"LET"
  text("LET", 400+moveX, 170+moveY);
      //text"HER"
  text("HER", 300+moveX, 250+moveY);
      //text"GO"
  text("GO", 200+moveX, 330+moveY);
}

Lab 1 : My favorite books (Variable-resize)

void setup() {
  size(350, 450);
  background(#a19d8c);
  int wide;
  int high;
  //setting variable
  wide=0;
  high=0;
  //WHITE_FANG
  fill(#2f4940);
  textSize(80);
    //text-WHITE
  text("WHITE", 40, 75);
    //text-FANG
  text("FANG", 60, 150);
  //JACK_LONDON
  textSize(30);
    //text-JACK LONDON
  text("JACK LONDON", 70, 425);
  //frame
  noStroke();
    //frame-1
  fill(#2f4940);
  rect(40, 170, 270+wide, 225+high);
    //frame-2
  fill(#a19d8c);
  rect(45, 175, 260+wide, 215+high);
    //frame-3
  fill(#2f4940);
  rect(50, 180, 250+wide, 205+high);
  //wolf :  begin at left to right
  fill(#d5cfb7);
  beginShape();
  vertex(50, 345);   //01-no move
    //over
  vertex(120+wide, 276);  //02
  vertex(214+wide, 254);  //03
  vertex(238+wide, 230);  //04
  vertex(229+wide, 198);  //05
  vertex(245+wide, 210);  //06
  vertex(240+wide, 197);  //07
  vertex(255+wide, 210);  //08
  vertex(289+wide, 180);  //09
    //under
  vertex(293+wide, 190+high);  //10
  vertex(285+wide, 220+high);  //11
  vertex(297+wide, 207+high);  //12
  vertex(300+wide, 215+high);  //13
  vertex(280+wide, 240+high);  //14
  vertex(245+wide, 322+high);  //15
  vertex(248+wide, 355+high);  //16
  vertex(265+wide, 368+high);  //17
  vertex(250+wide, 370+high);  //18
  vertex(237+wide, 348+high);  //19
  vertex(240+wide, 370+high);  //20
  vertex(255+wide, 385+high);  //21
  vertex(240+wide, 385+high);  //22
  vertex(215+wide, 325+high);  //23
  vertex(155+wide, 315+high);  //24
  vertex(135+wide, 330+high);  //25
  vertex(135+wide, 347+high);  //26
  vertex(155+wide, 360+high);  //27
  vertex(135+wide, 360+high);  //28
  vertex(125+wide, 330+high);  //29
  vertex(110+wide, 340+high);  //30
  vertex(105+wide, 365+high);  //31
  vertex(120+wide, 377+high);  //32
  vertex(105+wide, 378+high);  //33
  vertex(95+wide, 340+high);   //34
  vertex(100+wide, 330+high);  //35
  endShape();
}

Lab 1 : My favorite movies (Variable)

void setup() {
  size(450, 300);
  background(#ffd800);
  int swW;
  int swH;
  int moveX;
  int moveY;
  //setting variable
  swW=0;
  swH=0;
  moveX=0;
  moveY=0;
  //sword
  noStroke();
  fill(0);
     //black0-1
  rect(350+moveX, 0+moveY, 50+swW, 140+swH);
     //black0-2
  rect(348+moveX, 140+moveY+swH, 54+swW, 30+swH);
     //black0-3
  rect(330+moveX, 170+moveY+swH, 90+swW, 8+swH);
     //black0-4
  rect(348+moveX, 178+moveY+swH, 54+swW, 3+swH);
     //white0-5
  fill(255);
  rect(350+moveX, 181+moveY+swH+swH, 50+swW, 10+swH);
     //black0-6
  fill(0);
  rect(348+moveX, 191+moveY+swH, 54+swW, 3+swH);
     //black0-7
  rect(350+moveX, 194+moveY+swH, 50+swW, 106+swH);
  //shadow
     //white1-1
  fill(255);
  rect(350+moveX, 0+moveY, 30+swW, 140+swH);
  //white1-2
  triangle(360+moveX, 194+swH+moveY, 390+swW+moveX, 194+swH+moveY, 375+moveX+(swW/2), 204+swH+moveY);
  //white1-3
  quad(360+moveX, 219+swH+moveY, 375+(swW/2)+moveX, 209+swH+moveY, 390+swW+moveX, 219+swH+moveY, 375+moveX, 229+swH+moveY);
  //white1-4
  quad(360+moveX, 244+swH+moveY, 375+(swW/2)+moveX, 234+swH+moveY, 390+swW+moveX, 244+swH+moveY, 375+moveX, 254+swH+moveY);
  //white1-5
  quad(360+moveX, 269+swH+moveY, 375+(swW/2)+moveX, 259+swH+moveY, 390+swW+moveX, 269+swH+moveY, 375+moveX, 279+swH+moveY);
  //white1-6
  quad(360+moveX, 294+swH+moveY, 375+(swW/2)+moveX, 284+swH+moveY, 390+swW+moveX, 294+swH+moveY, 375+moveX, 304+swH+moveY);
  //text
  textSize(150);
     //text-KILL
  fill(#ca0101);
  text("KILL", 10+moveX, 140+moveY);
     //text-BILL
  fill(0);
  text("BILL", 10+moveX, 270+moveY);
  //cut
  stroke(#ffd800);
  strokeWeight(3);
  line(0+moveX, 260, 330+moveX, 180+moveY);
}

Lab 1 : Battery

void setup() {
  size(300, 300);
  float batW;
  float batH;
  float powW;
  int energy;
  int moveX;
  int moveY;
  //setting variable
  moveX=30;
  moveY=30;
  batW=200;
  batH=batW/2;
  energy=70;
  powW=(batW*energy)/100;
  //result
     //battery
  noFill();
  rect(moveX, moveY, batW, batH);
     //energy
  noStroke();
  fill(#00FF00);
  rect(moveX, moveY, powW, batH);
     //battery's polar
  fill(0);
  rect(batW+moveX, (batH/3)+moveY, 10, batH/3);
     //show your energy
  textSize(30);
  text("Energy "+energy, 50, 250);
}

Lab 1 : Positive sign

void setup() {
  float sizePosi;
  int moveX;
  int moveY;
  size(300, 300);
  //setting variable
  sizePosi=100;
  moveX=0;
  moveY=0;
  //result
  fill(0);
     //vertical
  rect(moveX+(sizePosi/3), moveY, sizePosi/3, sizePosi);
     //horizon
  rect(moveX, moveY+(sizePosi/3), sizePosi, sizePosi/3);
}

Lab 1 : Calaulate body mass index (BMI)

void setup() {
  float weight;        //น้ำหนัก
  float Hcm;           //ความสูงในหน่วยเซนติเมตร
  float Hm;             //ความสูงในหน่วยเมตร
  float bmi;
  //setting variable
  weight=39;          //weight-kilogram
  Hcm=151;           //height-centimeter
  //calculate
  Hm=Hcm/100;
  bmi=weight/(Hm*Hm);
  //result
  println("Weight : "+weight);
  println("Height(centimeter) : "+Hcm);
  println("BMI : "+bmi);
}

Lab 1 : Calculate circumference and area of a circle

void setup() {
  int dia;
  float area;
  int rad;
  float cir;
  size(200, 200);
  //setting variable
  dia=50;                 //diameter
  //calculate
  rad=dia/2;
  area=3.14*rad*rad;
  cir=3.14*dia;
  //result
  println("Diameter : "+dia);
  println("Area : "+area);
  println("Circumference : "+cir);
}

วันอาทิตย์ที่ 16 สิงหาคม พ.ศ. 2558

Lab 0 : My favorite musics

void setup() {
  size(600, 350);
  background(#7a92be);
  fill(#7a92be);
  stroke(255);
  strokeWeight(3);
  ellipse(100, 100, 200, 200);        //wheel_1
  ellipse(100, 100, 180, 180);        //wheel_2
  ellipse(100, 100, 100, 100);        //wheel_3
  fill(255);
  ellipse(100, 100, 30, 30);          //wheel_4
  noStroke();
  fill(#fabeca);                      //benchPink
  ellipse(50, 20, 10, 10);
  ellipse(50, 40, 40, 40);
  fill(#fff3a9);                      //benchYellow
  ellipse(180, 50, 10, 10);
  ellipse(180, 70, 40, 40);
  fill(#cbb1ce);                      //benchViolet
  ellipse(160, 175, 10, 10);
  ellipse(160, 195, 40, 40);
  fill(#b5efd6);                      //benchGreen
  ellipse(20, 150, 10, 10);
  ellipse(20, 170, 40, 40);
  stroke(255);
  strokeWeight(6);
  line(85, 100, 0, 350);              //poleL
  line(115, 100, 200, 350);           //poleR
  fill(0);
  textSize(60);
  text("PASSENGER", 210, 70);        //text"PASSENGER"
  textSize(100);
  text("LET", 400, 170);             //text"LET"
  text("HER", 300, 250);             //text"HER"
  text("GO", 200, 330);              //text"GO"
}

Lab 0 : My favorite books

void setup() {
  size(350, 450);
  background(#a19d8c);
  fill(#2f4940);                 //WHITE_FANG
  textSize(80);
  text("WHITE", 40, 75);              //text-WHITE
  text("FANG", 60, 150);              //text-FANG
  textSize(30);                  //JACK_LONDON
  text("JACK LONDON", 70, 425);       //text-JACK LONDON
  noStroke();                    //frame
  fill(#2f4940);                      //frame-1
  rect(40, 170, 270, 225);
  fill(#a19d8c);                      //frame-2
  rect(45, 175, 260, 215);
  fill(#2f4940);                      //frame-3
  rect(50, 180, 250, 205);
  fill(#d5cfb7);                 //wolf :  begin at left to right
  beginShape();
  vertex(50, 345);      //01
  vertex(120, 276);     //02
  vertex(214, 254);     //03
  vertex(238, 230);     //04
  vertex(229, 198);     //05
  vertex(245, 210);     //06
  vertex(240, 197);     //07
  vertex(255, 210);     //08
  vertex(289, 180);     //09
  vertex(293, 190);     //10
  vertex(285, 220);     //11
  vertex(297, 207);     //12
  vertex(300, 215);     //13
  vertex(280, 240);     //14
  vertex(245, 322);     //15
  vertex(248, 355);     //16
  vertex(265, 368);     //17
  vertex(250, 370);     //18
  vertex(237, 348);     //19
  vertex(240, 370);     //20
  vertex(255, 385);     //21
  vertex(240, 385);     //22
  vertex(215, 325);     //23
  vertex(155, 315);     //24
  vertex(135, 330);     //25
  vertex(135, 347);     //26
  vertex(155, 360);     //27
  vertex(135, 360);     //28
  vertex(125, 330);     //29
  vertex(110, 340);     //30
  vertex(105, 365);     //31
  vertex(120, 377);     //32
  vertex(105, 378);     //33
  vertex(95, 340);      //34
  vertex(100, 330);     //35
  endShape();
}

วันพุธที่ 12 สิงหาคม พ.ศ. 2558

Lab 0 : My favorite movies

void setup() {
  size(450, 300);
  background(#ffd800);
  noStroke();
  fill(0);                              //sword
  rect(350, 0, 50, 140);                           //black0-1
  rect(348, 140, 54, 30);                          //black0-2
  rect(330, 170, 90, 8);                           //black0-3
  rect(348, 178, 54, 3);                           //black0-4
  fill(255);
  rect(350, 181, 50, 10);                          //white0-5
  fill(0);
  rect(348, 191, 54, 3);                           //black0-6
  rect(350, 194, 50, 106);                         //black0-7
  fill(255);                            //shadow
  rect(350, 0, 30, 140);                           //white1-1
  triangle(360, 194, 390, 194, 375, 204);          //white1-2
  quad(360, 219, 375, 209, 390, 219, 375, 229);    //white1-3
  quad(360, 244, 375, 234, 390, 244, 375, 254);    //white1-4
  quad(360, 269, 375, 259, 390, 269, 375, 279);    //white1-5
  quad(360, 294, 375, 284, 390, 294, 375, 304);    //white1-6
  textSize(150);                       //text
  fill(#ca0101);
  text("KILL", 10, 140);                           //text-KILL
  fill(0);
  text("BILL", 10, 270);                           //text-BILL
  stroke(#ffd800);                     //cut
  strokeWeight(3);
  line(0, 260, 330, 180);
}