love

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

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

Lab1-Circle Calculation

//K. Thanapat
void setup(){
    size(500 ,500);
    background(0);
//ใส่สีให้วงกลม
    fill(255 ,255 ,255);
//ประกาศตัวแปร
    int radius ,diameter ,area ,circumferrence;
//กำหนดค่าคงที่ให้เส้นผ่าศูนย์กลาง
    diameter = 200;
//คำนวณ
    radius = diameter/2;
    area = PI*(radius*radius);
    circumferrence = 2*(PI*radius);
//สร้างวงกลม
    ellipse( 250 ,250 ,diameter ,diameter);
//ตัวอักษร
    fill(255 ,0 ,0);
    textSize(20);
    text("Circumferrence =" +circumferrence ,130 ,465 );
    text("Area =" +area , 130 ,490);
}

Lab1-BMI

//K. Thanapat
void setup(){
    size(400 ,200);
    background(0 ,0 ,255);
//ประกาศตัวแปร
    float bmi ,weight ,height ,meterHeight;
//กำหนดค่าให้ตัวแปร และ คำนวณค่าตัวแปร
    weight = 53;
    height = 170;
    meterHeight = height/100;
    bmi = weight/(meterHeight*meterHeight);
//ตัวอักษร
    textSize(25);
    text("Your Height = " +height ,50 ,50);
    text("Your Weight =" +weight ,50 ,110);
    text("Your BMI =" +bmi ,5 ,170);
  
    } 

Lab1-Music Book (Move and Resize)

//K. Thanapat
void setup(){
    size(500 ,650);
    background(0);
//ประกาศตัวแปร x y s
    int x ,y ,s;
//กำหนดค่าตัวแปร x (แนวนอน)
    x = 0;
//กำหนดค่าตัวแปร y (แนวตั้ง)
    y = 0;
//กำหดค่าตัวแปร s(ขนาด)
    s = 0;
//สร้างหน้าหนังสือโดยใช้สี่เหลี่ยม
    fill(255 ,219 ,183);
    noStroke();
    quad(0-s+x ,0-s+y ,500+s+x ,0-s+y ,500+s+x ,650+s+y ,0-s+x ,650+s+y);
    noStroke();
//สร้างสี่เหลี่ยมสีฟ้า
    fill(128 ,255 ,255);
    quad(0-s+x ,60-s+y ,500+s+x ,60-s+y ,500+s+x ,270-s+y ,0-s+x ,270-s+y);
//สร้างสี่เหลี่ยมสีเหลือง
    fill(249 ,253 ,74);
    quad(250+x ,0-s+y ,50-s+x ,0-s+y ,50-s+x ,650+s+y ,250+x ,650+s+y);
//ตัวอักษร
    textSize(70+s);
    fill(200 ,68 ,4);
    text("Chord" ,280+x+s ,120+y);
    text("&" ,440+x+s ,190+y);
    text("TAB" ,350+x+s ,260+y);
    fill(0 ,0 ,160);
    text("Music Book" ,130+x ,335+y);
 //สร้างสี่เหลี่ยม
    fill(255 ,255 ,255);
    stroke(40 ,255 ,95);
    strokeWeight(10+s);
    quad(90+x-s ,640+y+s ,90+x-s ,550+y+s ,450+x+s ,550+y+s ,450+x+s ,640+y+s);
 }

Lab1-EDGE Of Tomorrow (Move and Resize)

//K.Thanapat
void setup(){
    size(500 ,500);
    background(37 ,37 ,37);
    fill(69 ,68 ,66);
//ประกาศตัวแปร
    float x ,y ,s;
//ใส่ค่าให้x(แนวนอน)
    x = 0;
//ใส่ค่าให้y(แนวตั้ง)
    y = 0;
//ใส่ค่าให้s(ขนาด ขนาดมาก ,ใหญ่ขึ้น)
    s = 0;
//ทำโครงหน้าส่วนบน
    beginShape();
    vertex(0+x-s ,89+y-s);
    vertex(48+x-s ,106+y-s);
    vertex(92+x-s ,123+y-s);
    vertex(116+x-s ,129+y-s);
    vertex(133+x-s ,133+y-s);
    vertex(143+x-s ,136+y-s);
    vertex(186+x-s ,140+y-s);
    vertex(186+x-s ,140+y-s);
    vertex(286+x+s ,98+y-s);
    vertex(390+x+s ,98+y-s);
    vertex(479+x+s ,140+y-s);
    vertex(500+x+s ,139+y-s);
    vertex(500+x+s ,0+y-s);
    vertex(0+x-s ,0+y-s);
    vertex(0+x-s ,89+y-s);
    endShape();
//ทำโครงหน้าส่วนล่าง
    fill(182 ,181 ,179);
    beginShape();
    vertex(0+x-s ,92+y-s);
    vertex(25+x-s ,105+y-s);
    vertex(51+x-s ,118+y-s);
    vertex(74+x-s ,130+y-s);
    vertex(103+x-s ,138+y-s);
    vertex(144+x-s ,147+y-s);
    vertex(179+x-s ,152+y-s);
    vertex(192+x-s ,149+y-s);
    vertex(283+x+s ,108+y-s);
    vertex(308+x+s ,110+y-s);
    vertex(248+x-s ,158+y-s);
    vertex(229+x-s ,167+y-s);
    vertex(219+x-s ,170+y-s);
    vertex(207+x-s ,172+y-s);
    vertex(198+x-s ,172+y-s);
    vertex(217+x-s ,241+y-s);
    vertex(187+x-s ,173+y-s);
    vertex(163+x-s ,170+y-s);
    vertex(143+x-s ,166+y-s);
    vertex(42+x-s ,131+y-s);
    vertex(40+x-s ,116+y-s);
    vertex(22+x-s ,114+y-s);
    vertex(22+x-s ,142+y-s);
    vertex(32+x-s ,158+y-s);
    vertex(42+x-s ,171+y-s);
    vertex(40+x-s ,116+y-s);
    vertex(22+x-s ,114+y-s);
    vertex(32+x-s ,158+y-s);
    vertex(42+x-s ,171+y-s);
    vertex(58+x-s ,181+y-s);
    vertex(64+x-s ,184+y-s);
    vertex(117+x-s ,201+y-s);
    vertex(143+x-s ,212+y-s);
    vertex(164+x-s ,227+y-s);
    vertex(178+x-s ,238+y-s);
    vertex(189+x-s ,258+y+s);
    vertex(191+x-s ,271+y+s);
    vertex(206+x-s ,270+y+s);
    vertex(215+x-s ,274+y+s);
    vertex(229+x-s ,269+y+s);
    vertex(237+x-s ,268+y+s);
    vertex(254+x+s ,276+y+s);
    vertex(270+x+s ,274+y+s);
    vertex(279+x+s ,279+y+s);
    vertex(285+x+s ,295+y+s);
    vertex(328+x+s ,296+y+s);
    vertex(330+x+s ,242+y-s);
    vertex(326+x+s ,236+y-s);
    vertex(318+x+s ,243+y-s);
    vertex(294+x+s ,245+y-s);
    vertex(277+x+s ,238+y-s);
    vertex(264+x+s ,232+y-s);
    vertex(258+x+s ,224+y-s);
    vertex(258+x+s ,205+y-s);
    vertex(266+x+s ,192+y-s);
    vertex(272+x+s ,191+y-s);
    vertex(288+x+s ,193+y-s);
    vertex(297+x+s ,179+y-s);
    vertex(312+x+s ,176+y-s);
    vertex(338+x+s ,180+y-s);
    vertex(355+x+s ,176+y-s);
    vertex(362+x+s ,177+y-s);
    vertex(381+x+s ,189+y-s);
    vertex(394+x+s ,187+y-s);
    vertex(410+x+s ,198+y-s);
    vertex(413+x+s ,220+y-s);
    vertex(400+x+s ,239+y-s);
    vertex(393+x+s ,245+y-s);
    vertex(282+x+s ,246+y-s);
    vertex(370+x+s ,244+y-s);
    vertex(341+x+s ,234+y-s);
    vertex(339+x+s ,292+y+s);
    vertex(377+x+s ,291+y+s);
    vertex(381+x+s ,281+y+s);
    vertex(391+x+s ,274+y+s);
    vertex(401+x+s ,274+y+s);
    vertex(407+x+s ,275+y+s);
    vertex(419+x+s ,263+y+s);
    vertex(428+x+s ,262+y+s);
    vertex(442+x+s ,268+y+s);
    vertex(466+x+s ,267+y+s);
    vertex(468+x+s ,250+y);
    vertex(500+x+s ,226+y-s);
    vertex(500+x+s ,167+y-s);
    vertex(486+x+s ,168+y-s);
    vertex(449+x+s ,252+y+s);
    vertex(470+x+s ,172+y-s);
    vertex(461+x+s ,168+y-s);
    vertex(361+x+s ,121+y-s);
    vertex(361+x+s ,115+y-s);
    vertex(385+x+s ,107+y-s);
    vertex(482+x+s ,151+y-s);
    vertex(500+x+s ,150+y-s);
    vertex(500+x+s ,139+y-s);
    vertex(479+x+s ,140+y-s);
    vertex(390+x+s ,98+y-s);
    vertex(286+x+s ,98+y-s);
    vertex(186+x-s ,140+y-s);
    vertex(186+x-s ,140+y-s);
    vertex(143+x-s ,136+y-s);
    vertex(133+x-s ,133+y-s);
    vertex(116+x-s ,129+y-s);
    vertex(92+x-s ,123+y-s);
    vertex(48+x-s ,106+y-s);
    vertex(0+x-s ,89+y-s);
    vertex(0+x-s ,92+y-s);
    endShape();
    fill(123 ,123 ,123);
//ตัวอักษร
    textSize(50+s);
    text("EDGE" ,200+x ,400+y+s);
    text("OF" ,230+x ,440+y+s);
    text("TOMORROW" ,110+x ,480+y+s);
    }

Lab1-All Of Me (Move)

//K.Thanapat
void setup(){
    size(500 ,500);
    background(260 ,200 ,270);
    fill(250 ,255 ,255);
//ประกาศตัวแปร x ,y ,s
    int x ,y ,s;
//กำหนดค่าให้ x(แนวตั้ง)
    x = 0;
//กำหนดค่าให้ y(แนวนอน)
    y = 0;
//กำหนดค่าให้ s (ขนาด)
    s = 0;
//แสดง CAUSE ให้ปรากฎบนหน้าจอ
    textSize(95+s);
    text("CAUSE" ,90+x-s ,80+y-s);
//แสดง ALL OF ME ให้ปรากฎบนหน้าจอ
    textSize(50+s);
    text("  ALL OF ME" ,90+x-s ,125+y-s);
//แสดง LOVES ให้ปรากฎบนหน้าจอ
    textSize(100+s);
    text("LOVES" ,90+x-s ,210+y-s);
//แสดง ALL OF YOU ให้ปรากฎบนหน้าจอ
    textSize(50+s);
    text(" ALL OF YOU" ,90+x-s ,270+y-s);
//เส้น
    strokeWeight(10+s);
    stroke(250 ,255 ,255);
//วาดเส้น
    line(50+x-s-s ,300+y+s+s ,450+x+s+s ,300+y+s+s);
    line(50+x-s-s ,295+y+s+s ,50+x-s-s ,50+y-s-s);
    line(453+x+s+s ,295+y+s+s ,453+x+s+s ,50+y-s-s);
    textSize(50+s);
    text("- John Legend -" ,90+x-s-s ,400+y+s+s);
 
    textSize(30+s)
    text("       ---ALL OF ME---" ,90+x-s-s ,450+y+s+s);

}

Lab1-Battery

//K. Thanapat
void setup(){
     size(600 ,400);
     background(0);
//กำหนดตัวแปรในรูปแบบทศนิยม
     float x ,y ,s ,n;
//กำหนดค่าให้ตัวแปร x(แนวนอน)
     x = 100;
//กำหนดค่าให้ตัวแปร y(แนวตั้ง)
     y = 100;
//กำหนดค่าให้ตัวแปร s(ขนาด)
     s = 200;
//กำหนดค่าให้ตัวแปร n(เปอร์เซ็นต์ชาร์จของแบตเตอรี่ สูงสุด=100)
     n = 99;

     noStroke();
     fill(195 ,195 ,195);
//สร้างสี่เหลี่ยมให้เป็นกรอบแบตเตอรี่
     rect(x ,y ,s*2 ,s ,8);
//ใส่สีลงให้แบตเตอรี่
     fill(0 ,255 ,0);
//สร้างแบตเตอรี่รูปสี่เหลี่ยม
     rect(x+8 ,y+8 ,(n/100*s)+(n/100*s)+(-16) ,s-16 ,10);
}

Lab1-Positive Sign

//K. Thanapat
void setup(){
    size(500 ,500);
    background(0);
    noStroke();
//ประกาศตัวแปรx ,y ,s
    int x ,y ,s;
//ให้ค่าตัวแปร x (แนวแกนx)
    x = 0;
//ให้ค่าตัวแปร y (แนวแกน y)
    y = 0;
//ให้ค่าตัวแปร s (ขนาด)
    s = 250;

    fill(255 ,0 ,0);
//สี้เหลี่ยมแนวตั้ง
    rect(s/3+x ,y ,s/3 ,s);
//สี่เหลี่ยมแนวนอน
    rect(x ,s/3+y ,s ,s/3);
}