jknip-Project-05-wallpaper

sketch

/*Jessica Nip
Section A
jknip@andrew.cmu.edu
Project-05
*/

function setup() {
    createCanvas(400, 400);
    background(255,254,208);
    var tw = 80; //horizontal spacing between circles
    var th = 40; //vertical spacing between circles
    var oy = 0; //y position of circles
    var ox = 0; //x position of circles
    var circlesize = 20;

//for odd rows
    for (var y = 0; y < 6; y++) { //create 6 rows
        for (var x = 0; x < 6; x++) { //create 6 circles in each row
            var py = oy + y * th * 2; //y position = position + row  * vertical spacing distance
            var px = ox + x * tw; //adjust x spacing to accomodate 2*space + one circle
           
    //shadow behind avocado
            fill(138,86,47);
            noStroke();
            ellipse(px+2, py, circlesize, circlesize*1.2);
            ellipse(px+2, py+11, circlesize*1.3, circlesize*1.8);

    //avocado       
            fill(186,217,64);
            noStroke();
            ellipse(px, py, circlesize, circlesize*1.2); // top half of avocado
            ellipse(px, py+11, circlesize*1.3, circlesize*1.8); //bottom half of avocado
            
    //pit
            fill(138,86,47);
            ellipse(px-1, py+13, circlesize/2, circlesize/1.7);
        }
    }


//for even rows
    for (var y = 0; y < 5; y++) { //create 5 rows
        for (var x = 0; x < 6; x++) { //create 6 circles in each row
            var py = oy + y * th * 2 + circlesize*2;
            var px = ox + x * tw + circlesize*2; //adjust x spacing to accomodate 2*space + one circle
    
    //shadow behind avocado
            fill(138,86,47);
            noStroke();
            ellipse(px+2, py, circlesize, circlesize*1.2);
            ellipse(px+2, py+11, circlesize*1.3, circlesize*1.8);
        
    //avocado  
            fill(186,217,64);
            noStroke();
            ellipse(px, py, circlesize, circlesize*1.2); // top half of avocado
            ellipse(px, py+11, circlesize*1.3, circlesize*1.8); // bottom half of avocado
           
    //pit
            fill(138,86,47);
            ellipse(px-1, py+13, circlesize/2, circlesize/1.7); //avocado pit
        }
    }
    noLoop();
}


function draw() {
    // draw is not called due to noLoop() in setup()
}

Inspired by a friend’s graphic design work, I wanted to create a simple avocado wallpaper that mimics the fun in her work. I was also inspired by the hexagonal pattern from the previous assignment.

 

Leave a Reply