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

Lab 1 - Tree (with Variable)

Increase Space_Left  for move tree to right side.
Decrease Space_Left for move tree to left side.
Increase Space_Top for move tree to bottom.
Decrease Space_Top for move tree to top.

Example
Space_Left = 20
It's mean move to right side 20 points.
Space_Top = 80
It's mean move to bottom 80 points.

Here is my coding.
void setup()
{
    //variable
    int Space_Left,Space_Top;
    //assign variable
    Space_Left = 20;
    Space_Top = 80;
    //setup
    size(300,500);
    background(0,238,255);
    //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);
    //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);
}