mmirho – Project 5 – Wallpaper

Leaves!

I spent most of my time getting the construction of the leaf right, but after that, it was just making a simple alternating grid of them, like we’ve done in class before.

sketch

//Maxwell Mirho
//Section A
//mmirho@andrew.cmu.edu
//Project 5

function setup() {
    createCanvas(400, 400);
    background(10, 170, 260);
}

function drawLeaf(tipX, tipY) {

    fill(150,250,150);

    fill(10, 170, 260);
    arc(tipX + 30, tipY + 95, 60, 60, 1.5708 + 0.2, 3.14159, OPEN);
    fill(150, 250, 150);
    //Stem

    //Leaf tip
    triangle(tipX, tipY, tipX + 30, tipY + 70, tipX - 30, tipY + 70);

    //Leaf butt
    arc(tipX, tipY + 75, 60, 55, -0.3, 3.14159 + 0.3, OPEN);

    stroke(100,200,100);

    //1st (Top) leaf contour)
    arc(tipX, tipY + 51, 60, 60, 0.83, 2.3, OPEN);

    //2nd
    arc(tipX, tipY + 40, 50, 50, 0.83, 2.3, OPEN);

    //3rd
    arc(tipX, tipY + 29, 40, 40, 0.83, 2.3, OPEN);

    line(tipX, tipY + 88, tipX, tipY + 20);
    line(tipX - 1, tipY + 88, tipX - 1, tipY + 20);
    stroke(0);
    //Center leaf contour
    
}

function draw() {
    
    for (var x = 0 ; x < 6 ; x += 1) {
        for (var y = 0 ; y < 6 ; y += 1) {
            //Creates a grid

            push();
            translate(x*100, y*100);
            //Move the tip of the leaf to the grid

            if ((y%2) == 0) {
                rotate(-0.5);
            } else {
                rotate(0.5);
            }
            //Twists the leaf the opposite way if the row is an even number
            
            drawLeaf(0,0);
            //Draws an entire leaf!
            pop();

        }

    }
}

Leave a Reply