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

Balloon

void setup(){
  size(500,500);
}
 void draw(){
   background(160,231,231);
   int X = 250;
   int Y = mouseY;
 
   if(Y<50){
     Y = 50;
   fill(225,0,0);
   }else{
     fill(0,225,0);
   }
   draw_balloon(X,Y);
 }
 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);
}

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

Lab 1 possitive (resize)

int resizing = 50;
void setup(){
size(500,500);
//frameRate(3);
}
void draw() {
background(128,0,128);
fill(255,255,255);
noStroke();
rect(160,290,300-resizing,100-resizing);
rect(260,200, 100- resizing,300- resizing);
  resizing = ( resizing + 1)%width;
}

ปัญหา error



สาเหตุ : ในการประกาศชื่อตัวแปรห้ามเว้นตัวอักษร
วิธีการแก้ไข : 1. พิมพ์ชื่อตัวแปรให้ติดกัน
                       2. ใช้ underscore ( _ ) แทนการเว้นวรรคของคำนั้นๆ

Lab 2 Calculation of BMI

void setup(){
  float weight = 50;
  float heightCentimeter = 169;
  float bmi = cal_bmi(weight,heightCentimeter);
  println("bmi="+bmi);
  println("weight="+weight);
  println("height="+heightCentimeter);
}
float cal_bmi(float weight, float heightCentimeter)
{
  float heightMeter;      //ความสูง(เมตร)
  float bmi;          //ค่าดัชนีมวล

  heightMeter = heightCentimeter/100;
  bmi = weight/(heightMeter*heightMeter);
  return bmi;
}

Lab 2 Calculation of Cricle

void setup()
{
  float area = calculation_area(15); // เส้นรอบวง
  float circumference  = calculation_circumference(15);     // พื้นที่
  float diameter = calculation_diameter(15);     // เส้นผ่านศูนย์กลาง
  println("area="+area);
  println("circumference="+circumference);
  println("diameter="+diameter);
}
float calculation_area(float raidus){
  float area;
  area = PI*(raidus*raidus);
  return area;
}
float calculation_circumference(float raidus){
  float circumference;
  circumference = 2*PI*raidus;
  return circumference;
}
float calculation_diameter(float raidus){
  float diameter;
  diameter = 2*raidus;
  return diameter;
}

Lab 2 Battery

int space = 5;
int space2 = 5;
int posY=2;
void setup(){
size(500,500);

}
void draw(){
  background(0,0,0);
fill(225,225,225);
strokeWeight(5);
stroke(255,255,255);
rect(150,80,200,380);
rect(190,20,40,60);
rect(270,20,40,60);
fill(0,255,0);
rect(152,85,195,370);
  fill(0,0,0);
  rect(152,85,195,4+space);
  space = (space + 1 )%width;
  if( space>=368){
    space = (space - 1)%width;
  fill(0,225,0);
  stroke(255,255,255);
  rect(152,455-posY,195,2+space2);
  if(space2<370){
    space2=(space2 +1)%width;
    posY=(posY+1)%width;

}
}
}

Lab 2 clock

void setup() {
  size(500,500);

}

void draw()
{
digital_clock();
}
void digital_clock()
{
    background(0,0,0);
    int posX=130;
    int posY=250;
    int sec = second();
    int min = minute();
    int hr = hour();
   
   fill(41,225,66);
 
   textSize(50);
   text(hr+":",posX,posY);
 
     textSize(50);
   text(min+":",posX+80,posY);
 
     textSize(50);
   text(sec,posX+160,posY);
   }
   

Lab 2 music(moving)

int posX = 10;
void setup () {
size(500,500);
}
void draw(){
background(255,255,255);
fill(44,235,16);
stroke(255,255,255);
  rect(25-posX, 25, 450, 450);//Green
stroke(255,255,255);
fill(255,255,255);
  ellipse(255-posX, 220, 360, 300);//circle
stroke(255,255,255);
  triangle(190-posX, 430, 340-posX, 340, 200-posX, 250);//triangle
fill(44,235,16);
stroke(255,255,255);
  rect(120-posX, 135,15, 140);//little L
fill(44,235,16);
stroke(44,235,16);
  rect(121-posX,270,45,15);//little L
  rect(180-posX,136,15,150);//little I
  rect(210-posX,136,15,150);//little N
  rect(280-posX,136,15,150);//little N
  quad(215-posX,136, 230-posX, 136, 280-posX, 250, 280-posX, 285);//little N
  rect(310-posX,136,15,150);//little E
  rect(310-posX,136,60,15);//little E
  rect(310-posX,200,60,15);//little E
  rect(310-posX,274,60,15);//little E
fill(0,0,0);
textSize(18);
text("shu thag line - timethai Feat.kratae R siam  ",60-posX,450);
posX++;
if(posX > 500){
posX = -501;
}
}

Lab 2 movies(moving)

int posY = 50;
void setup () {
size(500,500);
}
void draw(){
background(255,255,0);
fill(0,0,0);
  ellipse(130, 190+posY, 150, 150);
fill(0,0,0);
  ellipse(370, 190+posY, 150, 150);
fill(255,255,255);
  ellipse(130, 190+posY, 140, 140);
fill(255,255,255);
  ellipse(370, 190+posY, 140, 140);
fill(0,0,0);
  rect(100,50+posY,10,70);
  rect(125,50+posY,10,70);
  rect(150,50+posY,10,70);
  rect(350,50+posY,10,70);
  rect(370,50+posY,10,70);
  rect(390,50+posY,10,70);
stroke(0,255,255);
fill(0,255,255);
  ellipse(130,190+posY,90,120);
  ellipse(370,190+posY,90,120);
fill(0,0,0);
  ellipse(130,200+posY,50,50);
  ellipse(370,200+posY,50,50);
fill(255,128,0);
stroke(0,0,0);
  ellipse(250,370+posY,400,60);
stroke(0,0,0);
line(100, 370+posY, 400, 370+posY);
posY++;
if(posY > 500){
posY = -501;
}
}

Lab 2 book(moving)

int posY = 90;
void setup () {
size(500,500);
}
void draw(){
background(255,0,128);
fill(255,255,255);
textSize(70);
text(" Siam Sport ",60,100-posY );
stroke(255,255,255);
fill(255,255,255);
  ellipse(150,295-posY ,250,250);
stroke(0,0,0);
fill(0,0,0);
  ellipse(160,210-posY ,60,60);
  ellipse(90,255-posY ,60,60);
  ellipse(190,285-posY ,60,60);
  ellipse(120,350-posY ,60,60);
textSize(60);
text(" Maxmagazine ",55,170-posY );
fill(255,255,255);
stroke(255,255,255);
  ellipse(350,350-posY,100,100);
  posY ++;
if(posY  > 500){
posY  = -501;
}
}

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

Lab 2 Battery (moving)

int space=75;
int move =0;
void setup(){
size(500,500);
}
void draw(){
background(0,0,0);
strokeWeight(5);
stroke(255,255,255);
rect(150+move,80,200,380);//ตัวแบตเตอร์รีี่
rect(190+move,20,40,60);//ขั้วแบต
rect(270+move,20,40,60);//ขั้วแบต
fill(0,255,0);


rect(152+move,85,195,70);//ขีดแบตก่อนที่1


rect(152+move,85+space,195,70);//ขีดแบตก่อนที่2


rect(152+move,85+space*2,195,70);//ขีดแบตก่อนที่3


rect(152+move,85+space*3,195,70);//ขีดแบตก่อนที่4


rect(152+move,85+space*4,195,70);//ขีดแบตก่อนที่5
fill(255,255,255);
textSize(20);
text("Battery",225+move,485);//word " Battery "

fill(255,0,0);
textSize(30);
text("100%",270+move,130);// 100 %

fill(255,0,0);
textSize(30);
text("80%",285+move,130+space);// 80%

fill(255,0,0);
textSize(30);
text("40%",285+move,130+space*2);//40 %

fill(255,0,0);
textSize(30);
text("20%",285+move,130+space*3);//20 %
fill(255,0,0);
textSize(30);
text("0%",285+move,130+space*4);// 0 %
move++;
if(move > 500){
move = -192;
}
}

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

Lab 2 Possitive(moving)

int space = 90 ;
void setup(){
size(500,500);
//frameRate(3);
}
void draw() {
background(128,0,128);
fill(255,255,255);
noStroke();
rect(space,220,300,100);
rect(90+space,130, 100,300);
space = (space + 2)%width; 

}

lab 1 ( BMI Calculation )

void setup() {
  size(500, 500);
  background(220,132,55);
}
void draw() {
  float high=169;//high(Cm.)
  float weight=51;//weight(kg.)
  float High=high/100;//High(m.)
  float bmi;//BMI
   bmi=weight/(High*High);//calcutate
   fill(255,255,255);
   textSize(40);
  text("Calculate", 180, 50);
  fill(19,63,236);
  textSize(25);
  text("High="+high+"cm", 80, 150);
  textSize(25);
  text("Weight="+weight+"kg", 80, 250);
  textSize(25);
  text("BMI="+bmi, 80, 350);
  }

Lab 1 (circle calculation)

void setup() {
  size(500, 500);
  background(105,211,162);
}
void draw() {
  float diameter=30;
  float area;
  float circumference;
  //calculate
  area=PI*(diameter/2)*(diameter/2);
  circumference=(2*PI)*(diameter/2);
  //show
  fill(0,0,0);
  textSize(25);
  text("Diameter="+diameter, 150, 100);
  textSize(20);
  text("circumference = "+circumference, 10, 150);
  textSize(20);
  text("area = "+area, 10, 200);

 }

Lab 1 RESIZE2

void setup () {
int resize = 20
size(500,500);
background(255,0,128);
fill(255,255,255);
textSize(70-resize);
text(" Siam Sport ",60,100);
stroke(255,255,255);
fill(255,255,255);
ellipse(150,295,250-resize,250-resize);
stroke(0,0,0);
fill(0,0,0);
ellipse(160,210,60-resize,60-resize);
ellipse(90,255,60-resize,60-resize);
ellipse(190,285,60-resize,60-resize);
ellipse(120,350,60-resize,60-resize);
textSize(60-resize);
text(" Maxmagazine ",95,170);
fill(255,255,255);
stroke(255,255,255);
ellipse(350,350,100-resize,100-resize);

}

Lab 1 RESIZE

void setup () {
int resize = 5
size(500,500);
background(255,255,0);
fill(0,0,0);
ellipse(130, 190, 150+resize, 150+resize);
fill(0,0,0);
ellipse(370, 190, 150+resize, 150+resize);
fill(255,255,255);
ellipse(130, 190, 140+resize, 140+resize);
fill(255,255,255);
ellipse(370, 190, 140+resize, 140+resize);
fill(0,0,0);
rect(100,50,10+resize,70+resize);
rect(125,50,10+resize,70+resize);
rect(150,50,10+resize,70+resize);
rect(350,50,10+resize,70+resize);
rect(370,50,10+resize,70+resize);
rect(390,50,10+resize,70+resize);
stroke(0,255,255);
fill(0,255,255);
ellipse(130,190,90+resize,120+resize);
ellipse(370,190,90+resize,120+resize);
fill(0,0,0);
ellipse(130,200,50+resize,50+resize);
ellipse(370,200,50+resize,50+resize);
fill(255,128,0);
stroke(0,0,0);
ellipse(250,370,400+resize,60+resize);
stroke(0,0,0);
line(100, 370, 400, 370);
}

Lab 1 MOVE

void setup () {
int move = 50;
size(500,500);
background(255,255,255);
fill(44,235,16);
stroke(255,255,255);
rect(25+move, 25+move, 450, 450);//Green
stroke(255,255,255);
fill(255,255,255);
ellipse(255+move, 220+move, 360, 300);//circle
stroke(255,255,255);
triangle(190+move, 430+move, 340+move, 340+move, 200+move, 250+move);//triangle
fill(44,235,16);
stroke(255,255,255);
rect(120+move, 135+move,15, 140);//little L
fill(44,235,16);
stroke(44,235,16);
rect(121+move,270+move,45,15);//little L
rect(180+move,136+move,15,150);//little I
rect(210+move,136+move,15,150);//little N
rect(280+move,136+move,15,150);//little N
quad(215+move,136+move, 230+move, 136+move, 280+move, 250+move, 280+move, 285+move);//little N
rect(310+move,136+move,15,150);//little E
rect(310+move,136+move,60,15);//little E
rect(310+move,200+move,60,15);//little E
rect(310+move,274+move,60,15);//little E


fill(0,0,0);
textSize(18);
text("shu thag line - timethai Feat.kratae R siam  ",60+move,450+move);
}

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

Possitive

void setup(){
int Width1 = 300;
int Width2 = 100;
int Height1 = 100;
int Height2 = 300 ;
size(500,500);
background(128,0,128);
noStroke();
fill(255,255,255);
rect(90,220,Width1,Height1);
rect(195,130, Width2,Height2);


}

BATTERY

void setup(){
int space=75
size(500,500);
background(0,0,0);
strokeWeight(5);
stroke(255,255,255);
rect(150,80,200,380);//ตัวแบตเตอร์รีี่
rect(190,20,40,60);//ขั้วแบต
rect(270,20,40,60);//ขั้วแบต
fill(0,255,0);


rect(152,85,195,70);//ขีดแบตก่อนที่1


rect(152,85+space,195,70);//ขีดแบตก่อนที่2


rect(152,85+space*2,195,70);//ขีดแบตก่อนที่3


rect(152,85+space*3,195,70);//ขีดแบตก่อนที่4


rect(152,85+space*4,195,70);//ขีดแบตก่อนที่5
fill(255,255,255);
textSize(20);
text("Battery",225,485);//word " Battery "

fill(255,0,0);
textSize(30);
text("100%",270,130);// 100 %

fill(255,0,0);
textSize(30);
text("80%",285,130+space);// 80%

fill(255,0,0);
textSize(30);
text("40%",285,130+space*2);//40 %

fill(255,0,0);
textSize(30);
text("20%",285,130+space*3);//20 %
fill(255,0,0);
textSize(30);
text("0%",285,130+space*4);// 0 %
}

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

MY BOOK

void setup () {
size(500,500);
background(255,0,128);
fill(255,255,255);
textSize(70);
text(" Siam Sport ",60,100);
stroke(255,255,255);
fill(255,255,255);
ellipse(150,295,250,250);
stroke(0,0,0);
fill(0,0,0);
ellipse(160,210,60,60);
ellipse(90,255,60,60);
ellipse(190,285,60,60);
ellipse(120,350,60,60);
textSize(60);
text(" Maxmagazine ",95,170);
fill(255,255,255);
stroke(255,255,255);
ellipse(350,350,100,100);

}

MY MOVIES

void setup () {
size(500,500);
background(255,255,0);
fill(0,0,0);
ellipse(130, 190, 150, 150);
fill(0,0,0);
ellipse(370, 190, 150, 150);
fill(255,255,255);
ellipse(130, 190, 140, 140);
fill(255,255,255);
ellipse(370, 190, 140, 140);
fill(0,0,0);
rect(100,50,10,70);
rect(125,50,10,70);
rect(150,50,10,70);
rect(350,50,10,70);
rect(370,50,10,70);
rect(390,50,10,70);
stroke(0,255,255);
fill(0,255,255);
ellipse(130,190,90,120);
ellipse(370,190,90,120);
fill(0,0,0);
ellipse(130,200,50,50);
ellipse(370,200,50,50);
fill(255,128,0);
stroke(0,0,0);
ellipse(250,370,400,60);
stroke(0,0,0);
line(100, 370, 400, 370);
}

MY MUSIC

void setup () {
size(500,500);
background(255,255,255);
fill(44,235,16);
stroke(255,255,255);
rect(25, 25, 450, 450);//Green
stroke(255,255,255);
fill(255,255,255);
ellipse(255, 220, 360, 300);//circle
stroke(255,255,255);
triangle(190, 430, 340, 340, 200, 250);//triangle
fill(44,235,16);
stroke(255,255,255);
rect(120, 135,15, 140);//little L
fill(44,235,16);
stroke(44,235,16);
rect(121,270,45,15);//little L
rect(180,136,15,150);//little I
rect(210,136,15,150);//little N
rect(280,136,15,150);//little N
quad(215,136, 230, 136, 280, 250, 280, 285);//little N
rect(310,136,15,150);//little E
rect(310,136,60,15);//little E
rect(310,200,60,15);//little E
rect(310,274,60,15);//little E


fill(0,0,0);
textSize(18);
text("shu thag line - timethai Feat.kratae R siam  ",60,450);
}