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

Syntax error

Syntax error
ปัญหา : functionชื่อไม่ตรงกัน
วิธีแก้ : เช็คชื่อ function ให้ตรงกัน

ปัญหา : ไม่มีเครื่องหมาย semicolon(;)
วิธีแก้ :  ใส่เครื่องหมาย (;)

ปัญหา : ไม่มีปีกกา ({_})
วิธีแก้ : ใส่ปีกกาปิด (})

ปัญหา : ชื่อตัวแปรไม่ ตรงกัน
วิธีแก้ :  เช็คชื่อตัวแปรให้ตรงกัน



วันเสาร์ที่ 29 สิงหาคม พ.ศ. 2558

Lab2-calCA


void setup(){
    size(600,100);
    int diameter=10;
    fill(#690181);
    textSize(40);
    text("Circumference is "+circumference(diameter),20,50);
    text("Area is "+Area(diameter),20,100);
      }
        float circumference(float d){
        //Method C=Pi*d//
        float c;
        c=PI*d;
        return c;
      }

        float Area(float d){
        //Area=PI*r//
        float a;
        d=d/2;
        a=PI*d;
        return a;
      }

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

Lab2-Digital Clock


void setup(){
 size(400,250);
}
void draw() {
  background(204);
  fill(0,0,0);
  rect(0,0,400,250,15);
  fill(255);
  rect(20,20,360,210,8);
  fill(0,0,0);
  textSize(100);
  text(":",120,125);
  text(":",240,125);
  textSize(80);
  text(second(),265,127);
  text(minute(),145,127);
  text(hour(),25,127);
  textSize(25);
  text("Date",120,200);
  text("/",230,200);
  text("/",270,200);
  textSize(15);
  text(year(),190,200);
  text(month(),250,200);
  text(day(),285,200);
}

digital clock


int count=0 ;
int sec=0;
int min=0;
int hour=0;
void setup(){
  size(300,300);
 
}
void draw(){
  background(0,0,0);
  count++;
  println("count"+count);
  if (count==20){
    count=0;
    println("sec"+sec);
    sec=sec+1;
   
    if(sec==10){
      sec=0;
      println("min"+min);
      min=min+1;
      if(min==5){
        min=0;
        println("hour"+hour);
        hour++;
        if(hour==2){
        count=0 ;
        sec=0;
        min=0;
        hour=0;
        }
      }
    }
  }
 
 textSize(50);

 text(sec,200,100);
 text(min,120,100);
 text(hour,40,100);
 textSize(70);
 text(":",180,100);
 text(":",100,100);

}

วันจันทร์ที่ 24 สิงหาคม พ.ศ. 2558

Lab2-calBMI


void setup(){
 float finalAnswer = BMI(84,184);//Body mass index
 println(finalAnswer);
 fill(#2F640C);
 textSize(40);
 text("BMI is "+finalAnswer,100,50);
}
float BMI(float weight,float hight){
  size(600,100);
  float BMI;
  hight = hight/100;
  BMI=weight/(hight*hight);
  return BMI;

}

Lab2-Music


int moveX;
int moveY;
void setup(){
 
size(500,550);
}
void draw(){
 music();
}
void music(){
int posx=25;
int posy=7;
 moveX=(moveX+1)%4;
 moveY=(moveY+1)%4;
 rect(0, 0, 499, 549);
  //left heart
stroke(#000000);
strokeWeight(10);
 line(246-posx+moveX, 85-posy, 190-posx+moveX, 15-posy); //1
 line(190-posx+moveX, 15-posy, 90-posx+moveX, 130-posy); //2
 line(90-posx+moveX, 130-posy, 246-posx+moveX, 321-posy); //3
 line(246-posx+moveX, 321-posy, 246-posx+moveX, 150-posy); //4
 line(246-posx+moveX, 150-posy, 155-posx+moveX, 150-posy); //5
stroke(#F23383);
strokeWeight(7.5);
 line(246, 85+moveY, 190, 15+moveY); //1
 line(190, 15+moveY, 90, 130+moveY); //2
 line(90, 130+moveY, 246, 321+moveY); //3
 line(246, 321+moveY, 246, 150+moveY); //4
 line(246, 150+moveY, 155, 150+moveY); //5
 //right heart
stroke(#000000);
strokeWeight(10);
 line(262+posx+moveX, 85-posy,318+posx+moveX, 15-posy); //1
 line(318+posx+moveX, 15-posy, 418+posx+moveX, 130-posy);  //2
 line(418+posx+moveX, 130-posy, 262+posx+moveX, 321-posy); //3
 line(262+posx+moveX, 321-posy, 262+posx+moveX, 150-posy); //4
 line(262+posx+moveX, 150-posy, 353+posx+moveX, 150-posy); //5
stroke(#F23383);
strokeWeight(7.5);
  line(262, 85+moveY,318, 15+moveY); //1
 line(318, 15+moveY, 418, 130+moveY);  //2
 line(418, 130+moveY, 262, 321+moveY); //3
 line(262, 321+moveY, 262, 150+moveY); //4
 line(262, 150+moveY, 353, 150+moveY); //5
//Heart WAVE
strokeWeight(1);
 line(150, 370+moveY,185, 370+moveY);
 line(185, 370+moveY, 202, 344+moveY);
 line(202, 345+moveY, 202, 370+moveY);
 line(202, 370+moveY, 217, 344+moveY);
 line(217, 345+moveY, 217, 385+moveY);
 line(217, 385+moveY, 234, 357+moveY);
 line(234, 357+moveY, 244, 357+moveY);
 line(244, 357+moveY, 244, 370+moveY);
 line(244, 370+moveY, 259, 370+moveY);

 line(259, 370+moveY, 276, 344+moveY);
 line(276, 344+moveY, 276, 370+moveY);
 line(276, 370+moveY, 292, 344+moveY);
 line(292, 344+moveY, 292, 384+moveY);
 line(292, 384+moveY, 309, 357+moveY);
 line(309, 357+moveY, 319, 357+moveY);
 line(319, 357+moveY, 319, 370+moveY);
 line(319, 370+moveY, 354, 370+moveY);
 fill(#F23383);
 ellipse(354, 370+moveY, 3, 3);

    textSize(90);
    fill(#F23383);
    text("G",130+moveX,478+moveY);
    fill(#FFA5CB);
    textSize(40);
    text("irls",191,445);
    textSize(40);
    text("eneration",189,478);
    fill(#FFFFFF);
  println("My faverite Music is ");
  println ("Girlsgeneration");
  println(moveX);
}

Lab2-Movie


int resize;
void setup(){
size(600, 600);
}
void draw(){
  movie();
}

 void movie(){
 int posx=50;
 resize=(resize+1)%20;
 background(#778899);
  fill(#FAEBD7);
  stroke(#000000);
  strokeWeight(5);
   ellipse(300, 300, 300, 400); //face

 stroke(#000000);
 strokeWeight(5);
  line(300, 98, 300,  50); //hair 1
  line(295, 98, 280,  60); //hair 2
  line(305, 98, 320,  60); //hair 3


   //Nose
  fill(#CC0000);
  strokeWeight(5);
   ellipse(mouseX, 350, 70+resize, 65+resize); //nose
  fill(#FF0000);
  stroke(#FF0000);
  strokeWeight(1);
   ellipse(mouseX, 350, 59+resize, 55+resize); //nose red
  fill(#FF4500);
  stroke(#FF4500);
  strokeWeight(1);
   ellipse(mouseX, 350, 48+resize, 45+resize); //nose orange
  fill(#FFA500);
  stroke(#FFA500);
  strokeWeight(1);
   ellipse(mouseX, 350, 37+resize, 35+resize); //nose yellow


  fill(#000000);
  stroke(#000000);
   quad(posx+210, 250, posx+230, 200, posx+250, 250, posx+230, 300); //left tatto

  fill(#F8F8FF);
  strokeWeight(2);
   ellipse(posx+230, 250, 80+resize, 30+resize); //left eye
   ellipse(posx+370, 250, 80+resize, 30+resize); //right eye
   fill(#CC0000);
   stroke(#CC0000);
   strokeWeight(1);
    ellipse(posx+230, 250, 10+resize, 26+resize); //left small eye
    ellipse(posx+370, 250, 10+resize, 26+resize); //right small eye
    fill(#FF0000);
    stroke(#FF0000);
    strokeWeight(1);
     ellipse(posx+230, 250, 2+resize, 2+resize); //left very small eye
     ellipse(posx+370, 250, 2+resize, 2+resize); //right very small eye
 
   println("My Movie is Batman");
   println("This is JOKER");
   println(resize);
}

Lab2-book


int moveY;
void setup(){
size(550,700);
}
void draw(){
 book();
}
void book(){
 int posy=50;
  moveY=(moveY+1)%(100);
  fill(#D8BABA);
  rect(0, 0, 549, 699);
  fill(#FFFFFF);
  rect(0, 0, 55, 699);
  textSize(40);
      fill(#000000);
     text("1",15,50);
      textSize(20);
      text("45B",8,660);
  fill(#FF9966);
  rect(60, 5, 485, 450);
//////////////////Body/////////////////
  fill(#000000);
  strokeWeight(4);

  ellipse(300, posy+250-moveY, 240, 250);//face back
  fill(#FFFFFF);
  rect(165, posy+251-moveY, 30, 40);//left ear
  rect(405, posy+251-moveY, 30, 40);//right ear
  ellipse(300, posy+254-moveY, 238, 245);
  fill(#FDFF40);//face front
     ellipse(360, posy+245-moveY, 70, 80);//right eye
     ellipse(240, posy+245-moveY, 70, 80);//left eye
  strokeWeight(2);
  fill(#000000);
   triangle(300, posy+275-moveY, 285,posy+100-moveY, 315, posy+100-moveY);  //crest
  textSize(70);
      fill(#000000);
     text("The",100,530);
      textSize(60);
     text("Ultraman",250,530);
      textSize(40);
     text("Original",380,580);
 
  println("My faverite book is ");
  println ("ultranma");
  println(-moveY);

}

Lab2-battery(+/-)


int resize;
void setup(){
  size(600,450);
}
void draw(){
 background(#EAE49C);
 draw_battery();
 draw_positionSign(15,3);
 draw_negativeSign(260);
 println(resize);
}
void draw_battery(){
 resize=(resize+3)%180;
 fill(#EAE49C);
 stroke(#384D12);
 strokeWeight(5);
 rect(220, 175, 200, 75, 7); //case
 fill(#384D12);
 //depolarized
 rect(210, 190, 10, 45, 2);
 //in case
 rect(411-resize, 184, 0+resize, 58, 1);
}
void draw_positionSign(int resizew,int resizeh){

 fill(#ED0C0C);
 stroke(#ED0C0C);
 rect(175, 209, resizew, resizeh);//horizontal
 rect(181, 203, resizeh, resizew);//vertical
}
void draw_negativeSign(int posx){
 fill(#ED0C0C);
 stroke(#ED0C0C);
 rect(175+posx, 203+6, 15, 3);//horizontal
}

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

Lab2-function positive


int resize;
void setup(){
  size(500,500);
}
void draw(){
  background(#000000);
  draw_positionSign();
}
void draw_positionSign(){
 resize=(resize+1)%100;
 fill(#ED0C0C);
 stroke(#ED0C0C);

 rect(100-resize/2, 200-resize/2, resize+300, resize+100);
 rect(200-resize/2, 100-resize/2, resize+100, resize+300);
 println(resize);
}

Lab1-GG



void setup(){
int posx=25;
int posy=7;
 size(500,550);
 background(#FFFFFF);
 rect(0, 0, 499, 549);
  //left heart
stroke(#000000);
strokeWeight(10);
 line(246-posx, 85-posy, 190-posx, 15-posy); //1
 line(190-posx, 15-posy, 90-posx, 130-posy); //2
 line(90-posx, 130-posy, 246-posx, 321-posy); //3
 line(246-posx, 321-posy, 246-posx, 150-posy); //4
 line(246-posx, 150-posy, 155-posx, 150-posy); //5
stroke(#F23383);
strokeWeight(7.5);
 line(246, 85, 190, 15); //1
 line(190, 15, 90, 130); //2
 line(90, 130, 246, 321); //3
 line(246, 321, 246, 150); //4
 line(246, 150, 155, 150); //5
 //right heart
stroke(#000000);
strokeWeight(10);
 line(262+posx, 85-posy,318+posx, 15-posy); //1
 line(318+posx, 15-posy, 418+posx, 130-posy);  //2
 line(418+posx, 130-posy, 262+posx, 321-posy); //3
 line(262+posx, 321-posy, 262+posx, 150-posy); //4
 line(262+posx, 150-posy, 353+posx, 150-posy); //5
stroke(#F23383);
strokeWeight(7.5);
  line(262, 85,318, 15); //1
 line(318, 15, 418, 130);  //2
 line(418, 130, 262, 321); //3
 line(262, 321, 262, 150); //4
 line(262, 150, 353, 150); //5
//Heart WAVE
strokeWeight(1);
 line(150, 370,185, 370);
 line(185, 370, 202, 344);
 line(202, 345, 202, 370);
 line(202, 370, 217, 344);
 line(217, 345, 217, 385);
 line(217, 385, 234, 357);
 line(234, 357, 244, 357);
 line(244, 357, 244, 370);
 line(244, 370, 259, 370);

 line(259, 370, 276, 344);
 line(276, 344, 276, 370);
 line(276, 370, 292, 344);
 line(292, 344, 292, 384);
 line(292, 384, 309, 357);
 line(309, 357, 319, 357);
 line(319, 357, 319, 370);
 line(319, 370, 354, 370);
 fill(#F23383);
 ellipse(354, 370, 3, 3);

    textSize(90);
    fill(#F23383);
    text("G",130,478);
    fill(#FFA5CB);
    textSize(40);
    text("irls",191,445);
    textSize(40);
    text("eneration",189,478);

  println("My faverite Music is ");
  print ("Girlsgeneration");
}

Lab1-ultranma



void setup(){
int posy=50;
  size(550,700);
  fill(#D8BABA);
  rect(0, 0, 549, 699);
  fill(#FFFFFF);
  rect(0, 0, 55, 699);
  textSize(40);
      fill(#000000);
     text("1",15,50);
      textSize(20);
      text("45B",8,660);
  fill(#FF9966);
  rect(60, 5, 485, 450);

  fill(#000000);
  strokeWeight(4);

  ellipse(300, posy+250, 240, 250);//face back
  fill(#FFFFFF);
  rect(165, posy+251, 30, 40);//left ear
  rect(405, posy+251, 30, 40);//right ear
  ellipse(300, posy+254, 238, 245);
  fill(#FDFF40);//face front
     ellipse(360, posy+245, 70, 80);//right eye
     ellipse(240, posy+245, 70, 80);//left eye
  strokeWeight(2);
  fill(#000000);
   triangle(300, posy+275, 285, 100, 315, 100);  //crest
  textSize(70);
      fill(#000000);
     text("The",100,530);
      textSize(60);
     text("Ultraman",250,530);
      textSize(40);
     text("Original",380,580);
 
  println("My faverite book is ");
  print ("ultranma");

}

Lab1 - joker



void setup(){
int posx=50;
 size(600, 600);
 background(#778899);
  fill(#FAEBD7);
  strokeWeight(5);
   ellipse(300, 300, 300, 400); //face

 stroke(#000000);
 strokeWeight(5);
  line(300, 98, 300,  50); //hair 1
  line(295, 98, 280,  60); //hair 2
  line(305, 98, 320,  60); //hair 3


   //Nose
  fill(#CC0000);
  strokeWeight(5);
   ellipse(posx+300, 350, 70, 65); //nose
  fill(#FF0000);
  stroke(#FF0000);
  strokeWeight(1);
   ellipse(posx+303, 350, 59, 55); //nose red
  fill(#FF4500);
  stroke(#FF4500);
  strokeWeight(1);
   ellipse(posx+306, 350, 48, 45); //nose orange
  fill(#FFA500);
  stroke(#FFA500);
  strokeWeight(1);
   ellipse(posx+309, 350, 37, 35); //nose yellow
 
 
  fill(#000000);
  stroke(#000000);
   quad(posx+210, 250, posx+230, 200, posx+250, 250, posx+230, 300); //left tatto
 
  fill(#F8F8FF);
  strokeWeight(2);
   ellipse(posx+230, 250, 80, 30); //left eye
   ellipse(posx+370, 250, 80, 30); //right eye
   fill(#CC0000);
   stroke(#CC0000);
   strokeWeight(1);
    ellipse(posx+230, 250, 10, 26); //left small eye
    ellipse(posx+370, 250, 10, 26); //right small eye
    fill(#FF0000);
    stroke(#FF0000);
    strokeWeight(1);
     ellipse(posx+230, 250, 2, 2); //left very small eye
     ellipse(posx+370, 250, 2, 2); //right very small eye
   
   println("My Movie is Batman");
   print("This is JOKER");
}

Lab1-BMI




void setup(){
float BMI;//Body mass index
float weight;
float hight;
  size(600,100);

  weight = 84;
  hight = 184;
  hight = hight/100;
  BMI=weight/(hight*hight);

 println("Weight = "+weight);
 print("Hight = ");
 println(hight);
 println("BMI = "+BMI);
 fill(#2F640C);
 textSize(40);
 text("BMI is "+BMI,100,50);
}

วันจันทร์ที่ 17 สิงหาคม พ.ศ. 2558

Lab-Circle




void setup(){
float c;//Circrumference
float d;//Diameter of the circle
float r;//radiuns
float a;//area
  size(620,120);
  println("Circumference of a Circle");
  println("Method C=Pi*d ");
  d=10;
  c=PI*d;
  r=d/2;
  println("r is "+r);//print Diameter
  println("d is "+d);//print Diameter
  println("Pi is "+PI);// Pi=3.1415927
  println("C is "+c);

  a=PI*(r*r);
  println("A is "+a);
  fill(#690181);
  textSize(40);
  text("circumference is "+c,20,50);
  text("Area is "+a,20,100);
}

Lab1-Battery


void setup(){
 size(600,450);
 background(#EAE49C);
 fill(#EAE49C);
 stroke(#384D12);
 strokeWeight(5);
 rect(220, 175, 200, 75, 7); //case
 fill(#384D12);
 //depolarized
 rect(210, 190, 10, 45, 2);
 //in case
 rect(392, 184, 19, 58, 1);
 triangle(389, 188, 389, 242, 345, 242);
 

}

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

Lab1-Positive sign



void setup(){
int pos=100;
 size(500,500);
 background(#000000);
 fill(#ED0C0C);
 stroke(#ED0C0C);
 rect(100, pos+100, 300, 100);
 rect(pos+100, 100, 100, 300);
}

touch typing


Lab0-GG


void setup(){
 size(500,550);
 background(#FFFFFF);
 rect(0, 0, 499, 549);
  //left heart
stroke(#000000);
strokeWeight(10);
 line(246, 85, 190, 15); //1
 line(190, 15, 90, 130); //2
 line(90, 130, 246, 321); //3
 line(246, 321, 246, 150); //4
 line(246, 150, 155, 150); //5
stroke(#F23383);
strokeWeight(7.5);
 line(246, 85, 190, 15); //1
 line(190, 15, 90, 130); //2
 line(90, 130, 246, 321); //3
 line(246, 321, 246, 150); //4
 line(246, 150, 155, 150); //5
 //left heart
stroke(#000000);
strokeWeight(10);
 line(262, 85,318, 15); //1
 line(318, 15, 418, 130);  //2
 line(418, 130, 262, 321); //3
 line(262, 321, 262, 150); //4
 line(262, 150, 353, 150); //5
stroke(#F23383);
strokeWeight(7.5);
  line(262, 85,318, 15); //1
 line(318, 15, 418, 130);  //2
 line(418, 130, 262, 321); //3
 line(262, 321, 262, 150); //4
 line(262, 150, 353, 150); //5
//Heart WAVE
strokeWeight(1);
 line(150, 370,185, 370);
 line(185, 370, 202, 344);
 line(202, 345, 202, 370);
 line(202, 370, 217, 344);
 line(217, 345, 217, 385);
 line(217, 385, 234, 357);
 line(234, 357, 244, 357);
 line(244, 357, 244, 370);
 line(244, 370, 259, 370);

 line(259, 370, 276, 344);
 line(276, 344, 276, 370);
 line(276, 370, 292, 344);
 line(292, 344, 292, 384);
 line(292, 384, 309, 357);
 line(309, 357, 319, 357);
 line(319, 357, 319, 370);
 line(319, 370, 354, 370);
 fill(#F23383);
 ellipse(354, 370, 3, 3);

    textSize(90);
    fill(#F23383);
    text("G",130,478);
    fill(#FFA5CB);
    textSize(40);
    text("irls",191,445);
    textSize(40);
    text("eneration",189,478);
 
  println("My faverite Music is ");
  print ("Girlsgeneration");
}

Lab0-ultraman


void setup(){
  size(550,700);
  fill(#D8BABA);
  rect(0, 0, 549, 699);
  fill(#FFFFFF);
  rect(0, 0, 55, 699);
  textSize(40);
  fill(#000000);
  text("1",15,50);
  textSize(20);
  text("45B",8,660);
  fill(#FF9966);
  rect(60, 5, 485, 450)
  fill(#000000);
  strokeWeight(4);
  ellipse(300, 250, 240, 250);//face back
  fill(#FFFFFF);
  rect(165, 251, 30, 40);//left ear
  rect(405, 251, 30, 40);//right ear
  ellipse(300, 254, 238, 245);
  fill(#FDFF40);//face front
  ellipse(360, 245, 70, 80);//right eye
  ellipse(240, 245, 70, 80);//left eye
  strokeWeight(2);
  fill(#000000);
  triangle(300, 275, 285, 100, 315, 100);  //crest
  textSize(70);
  fill(#000000);
  text("The",100,530);
  textSize(60);
  text("Ultraman",250,530);
  textSize(40);
  text("Original",380,580);
  println("My faverite book is ");
  print ("ultranma");

}

วันพฤหัสบดีที่ 13 สิงหาคม พ.ศ. 2558

Lab 0 - Joker

void setup(){
 size(600, 600);
 background(#778899);
  fill(#FAEBD7);
  strokeWeight(5);
   ellipse(300, 300, 300, 400); //face

 stroke(#000000);
 strokeWeight(5);
  line(300, 98, 300,  50); //hair 1
  line(295, 98, 280,  60); //hair 2
  line(305, 98, 320,  60); //hair 3


   //Nose
  fill(#CC0000);
  strokeWeight(5);
   ellipse(300, 350, 70, 65); //nose
  fill(#FF0000);
  stroke(#FF0000);
  strokeWeight(1);
   ellipse(303, 350, 59, 55); //nose red
  fill(#FF4500);
  stroke(#FF4500);
  strokeWeight(1);
   ellipse(306, 350, 48, 45); //nose orange
  fill(#FFA500);
  stroke(#FFA500);
  strokeWeight(1);
   ellipse(309, 350, 37, 35); //nose yellow
 
 
  fill(#000000);
  stroke(#000000);
   quad(210, 250, 230, 200, 250, 250, 230, 300); //left tatto
 
  fill(#F8F8FF);
  strokeWeight(2);
   ellipse(230, 250, 80, 30); //left eye
   ellipse(370, 250, 80, 30); //right eye
   fill(#CC0000);
   stroke(#CC0000);
   strokeWeight(1);
    ellipse(230, 250, 10, 26); //left small eye
    ellipse(370, 250, 10, 26); //right small eye
    fill(#FF0000);
    stroke(#FF0000);
    strokeWeight(1);
     ellipse(230, 250, 2, 2); //left very small eye
     ellipse(370, 250, 2, 2); //right very small eye
   
   println("My Movie is Batman");
   print("This is JOKER");
}