วันอาทิตย์ที่ 7 กันยายน พ.ศ. 2557

Lab 2 - Forest

ขโมยป่าของ "วรุณาทิตย์ ทองสาลี" มาอีกที อิอิ
http://a5730174.blogspot.com/2014/09/lab2-forest.html



void setup()
{
    //variable
    int Space_Left,Space_Top;
    //assign variable
    Space_Left = -100;
    Space_Top = -40;
    //setup
    size(300,200);
    background(0,238,255);
    DrawTree(Space_Left,Space_Top);
    DrawApple(Space_Left,Space_Top);
    //friend's tree 
    draw_rect(130,100,50,150) ; 
    draw_circle(150,90,30); // circle 
    draw_circle(125,110,30); // circle
    draw_circle(100,100,30); // circle 
    draw_circle(75,90,30); // circle 
    draw_circle(100,80,30); // circle 
    draw_circle(125,70,30); // circle 
    draw_circle(150,60,30); // circle 
    draw_circle(175,70,30); // circle 
    draw_circle(200,80,30); // circle 
    draw_circle(225,90,30); // circle 
    draw_circle(200,100,30); // circle 
    draw_circle(175,110,30); // circle

void DrawTree(int Space_Left,int Space_Top)
{
    //draw tree
    fill(194,88,52);
    noStroke();
    rect(Space_Left+110,Space_Top+150,80,300);
    //add curve to tree
    noStroke();
    fill(0,238,255);
    ellipse(Space_Left+110,Space_Top+300,40,300);
    ellipse(Space_Left+190,Space_Top+300,40,300);
    //add leaf
    noStroke();
    fill(98,255,0);
    ellipse(Space_Left+60,Space_Top+150,80,80);
    ellipse(Space_Left+80,Space_Top+120,80,80);
    ellipse(Space_Left+100,Space_Top+100,80,80);
    ellipse(Space_Left+240,Space_Top+150,80,80);
    ellipse(Space_Left+220,Space_Top+120,80,80);
    ellipse(Space_Left+200,Space_Top+100,80,80);
    ellipse(Space_Left+150,Space_Top+80,120,85);
    ellipse(Space_Left+150,Space_Top+100,120,85);
    ellipse(Space_Left+150,Space_Top+160,150,80);
}

void DrawApple(int Space_Left,int Space_Top)
{
    //add apple
    noStroke();
    fill(255,0,0);
    ellipse(Space_Left+70,Space_Top+150,24,24);
    ellipse(Space_Left+152,Space_Top+160,24,24);
    ellipse(Space_Left+220,Space_Top+140,24,24);
    stroke(125,49,9);
    strokeWeight(4);
    line(Space_Left+70,Space_Top+138,Space_Left+70,Space_Top+128);
    line(Space_Left+152,Space_Top+148,Space_Left+152,Space_Top+138);
    line(Space_Left+220,Space_Top+128,Space_Left+220,Space_Top+118);

}

void draw_rect (int x, int y , int small , int longg) { 
 fill(#8B4513); 
 noStroke(); 
 rect(x+80,y,small,longg); 
void draw_circle (int x,int y , int radius){ 
fill(#00FF00); 
noStroke(); 
ellipse(x+80,y,2*radius,2*radius); //my tree ==" 
fill(#8A5C00); 
draw_tree(105, 80, 165, 80, 165, 163, 105, 163); //brown tree 
fill(#19A319); 
noStroke(); 
draw_leaves(100, 90, 40, 40); //green leaves1 
draw_leaves(85, 65, 40, 40); //green leaves2 
draw_leaves(105, 50, 40, 40); //green leaves3 
draw_leaves(153, 45, 30, 40); //green leaves4 
draw_leaves(185, 75, 40, 40); //green leaves5 
draw_leaves(175, 60, 40, 40); //green leaves6 
draw_leaves(175, 90, 30, 40); //green leaves7 
draw_leaves(140, 63, 90, 65); //green leaves8 
void draw_tree(int x1,int y1,int x2,int y2,int x3,int y3,int x4,int y4){ 
quad(x1,y1+50, x2, y2+50, x3, y3+50, x4, y4+50); 
void draw_leaves(int x,int y,int width,int height){ 
ellipse(x, y+50, width, height); }