แสดงบทความที่มีป้ายกำกับ Lab 1 แสดงบทความทั้งหมด
แสดงบทความที่มีป้ายกำกับ Lab 1 แสดงบทความทั้งหมด

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

Lab1_Fav_Book_MOVE

Fav. Book(Can be move)

//FAV Book
void setup() {
  int posX=0; //fill value to move(X)
  int posY=0;//fill value to move(Y)
  size(500, 500);
  background(255);//white
  fill(#B3CFF0);//blue
  strokeWeight(8);//thick line
  rect(80+posX, 130+posY, 340, 220);//body of book
  strokeWeight(6);//thin line
  fill(#78B2F7);//dark blue
  rect(230+posX, 130+posY, 40, 220);//spine 
  rect(290+posX, 150+posY, 110, 60);//title's frame
  fill(0);//black
  textSize(30);
  text("Conan", 300+posX, 190+posY);//Title
  strokeWeight(3);//Thinest Line
  line(250+posX, 130+posY, 120+posX, 100+posY);//pages1 r
  line(250+posX, 130+posY, 110+posX, 108+posY);//pages2 r
  line(250+posX, 130+posY, 100+posX, 115+posY);//pages3 r
  line(120+posX, 100+posY, 80+posX, 130+posY);//pages border r
  line(250+posX, 130+posY, 380+posX, 100+posY);//pages1 l
  line(250+posX, 130+posY, 390+posX, 108+posY);//pages2 l
  line(250+posX, 130+posY, 400+posX, 115+posY);//pages3 l
  line(380+posX, 100+posY, 420+posX, 130+posY);//pages border l
}

Lab1_Fav_Song_Move

Fav. Song (Can be move)

//FAV Song MOVE
void setup() {
int posX=0;//fill value to move(X)
int posY=0;fill value to move(Y)
  size(500, 500);
  background(0);//black
  //background's circle
  stroke(255);//black line
  strokeWeight(14);//thick line
  fill(0);//line's color
  ellipse(250+posX, 250+posY, 250, 250);//big circle with nothing  inside of it

  //Linkin Park symbol
  line(260+posX, 125+posY, 185+posX, 290+posY);
  line(185+posX, 290+posY, 325+posX, 290+posY);
  line(325+posX, 290+posY, 275+posX, 180+posY);
  line(275+posX, 180+posY, 195+posX, 360+posY);

  //open the circle
  stroke(0);
  line(258+posX, 100+posY, 238+posX, 140+posY);
  line(215+posX, 350+posY, 200+posX, 380+posY);

  //title
  fill(255);
  textSize(40);
  textAlign(LEFT);
  text("LINKIN PARK", 135+posX, 450+posY);
}

Lab1_Fav_Movie_MOVE

Fav. Movie (Can be move)

//MY FAV MOVIE
void setup() {
  int posX=0;//fill value to move(Horizontal)
  int posY=0;//fill value to move(Vertical)
  size(500, 500);
  stroke(#0054A5);
  strokeWeight(3);
  background(#FACFF4);
  fill(#0005F0);//blue
  textSize(30);
  text("Doraemon : Stand by me", 75, 420);//Title
  fill(#236ED6);//blue
  ellipse(250+posX, 180+posY, 350, 295);//head
  fill(255);//white
  ellipse(250+posX, 210+posY, 250, 205);//face
  ellipse(210+posX, 120+posY, 80, 100);//right hand
  ellipse(290+posX, 120+posY, 80, 100);//left hand
  fill(#F21D1D);//red
  rect(110+posX, 300+posY, 280, 30);//cat collar
  fill(255);//white
  ellipse(120+posX, 300+posY, 60, 60);//right eye
  ellipse(380+posX, 300+posY, 60, 60);//left eye
  fill(#FF292D);//red
  ellipse(250+posX, 175+posY, 45, 40);//nose
  fill(255);//white
  arc(250+posX, 235+posY, 180, 50, 0, PI);//cute smile <3
  fill(#FAD449);//gold or yellow
  ellipse(250+posX, 300+posY, 40, 40);//bell
  fill(#3C60B9);//blue
  ellipse(225+posX, 135+posY, 20, 20);//inner eye(right)
  ellipse(275+posX, 135+posY, 20, 20);//inner eye(left)
  line(250+posX, 194+posY, 250, 260);//mouth (line)
  line(210+posX, 210+posY, 140, 210);// cat's whiskers mid right
  line(290+posX, 210+posY, 360, 210);// cat's whiskers mid left
  line(210+posX, 220+posY, 140, 230);// cat's whiskers below right
  line(290+posX, 220+posY, 360, 230);// cat's whiskers below left
  line(210+posX, 200+posY, 140, 190);// cat's whiskers above right
  line(290+posX, 200+posY, 360, 190);// cat's whiskers mid left
  line(232+posX,290+posY,267,290);//bell line1
  line(210+posX,300+posY,290,300);//bell line2
  strokeWeight(7);
  line(250+posX,302+posY,250,320);//bell line3
  stroke(255);//white line
  fill(255);//white
  ellipse(258+posX, 170+posY, 12, 12);//reflect nose
}

Lab1_Circle's_Calculation

การหาค่าของเส้นรอบวงและพื้นที่ของวงกลม

//Circle's Calculation
void setup() {
  int dm=160 ;//diameter
  float r=dm/2;//radius
  float r_2=r*r;//radius square
  float A=3.14*r_2;//area
  float Cf=2*(3.14)*r;//circumference
  size(500,500);
  //terminal output
  println("Value of circle's area = "+A);
  print("Value of circumference's circle = "+Cf);
  background(#FC66C1);//pink <3
  ellipse(100,100,160,160);//example
  
  //explaining text
  textSize(24);//text size
  text("Circumference's circle = "+Cf+" m.",30,400);
  text("Area's circle = "+A+" m^2.",30,350);
  text("Diameter's circle = "+dm+" m.",30,250);
  text("Radius's circle = "+r+" m.",30,300);
}

Lab1_BMI

การคำนวณหาค่าดัชนีมวลกาย BMI

//BMI
void setup() {
  size(300,300);
  background(#FF8B8B);//pink
  float w=48  ;//Weight
  float h=163  ;//Height
  float h_2=(h/100.0)*(h/100.0);//Height^2
  float BMI=w/h_2;//value of BMI

  //terminal output
  print("Value Of BMI="+BMI);

  //explaining text
  textSize(24);//size of text
  text("Weight = "+w+" Kg.",30,100);
  text("Height = "+h+" cm.",30,140);
  text("BMI="+BMI+"",30,180);
}

Lab1_Battery

วาดรูปแบตเตอรี่โดยใช้ตัวแปรทำให้สามารถเคลื่อนย้ายรูปได้ง่ายโดยการเปลี่ยนค่าที่ตัวแปรที่ประกาศ

void setup() {
  int countX=70;
  int countY=220;
  int space=40;
  int w=180;//width
  int h=90;//height
  size(500, 500);
  background(255);//white
  stroke(#0041E0);//dark blue
  strokeWeight(8);
  fill(#0393FF);//blue

  //big square
  rect(countX, countY, w, h);
  fill(255);//white
  //batt head
  rect(countX+180,countY+35, w/9, h-70);
  fill(#FF0011);//blue

  //battery quntity
  rect(countX, countY, space, h);//#1 batt
  fill(255);//white
  rect(countX+space, countY, space, h);//#2 batt
  rect(countX+space*2, countY, space, h);//#3 batt
  rect(countX+space*3, countY, space, h);//#4 batt
}

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

Lab1_Positive_Sign

เขียนรูปเครื่องหมายบวก โดยใช้การกำหนดตัวแปร

//Positive Sign
void setup() {
  int dX=120;//diameterX
  int dY=160;//diameterY
  int w=100;//weight
  int h=100;//height
  size(500, 500);
  background(#E4DBFF); //blue

  //rectangular area
  stroke(#FF0505);//red
  strokeWeight(0);
  fill(#FF0505);//red
  rect(dX,dY,w*3,h);//horizontal rect
  rect(dX+100,dY-100,w,h*3);//vertical rect
  
  //Title
  textSize(20);
  text("Positive Sign",dX+90,550-dY);
}