zhuoyinl- project05 wallpaper

wallpaper.js

//Zhuoying Lin
//section a 
//zhuoyinl@andrew.cmu.edu
//project

function setup() {
    createCanvas(600, 700);
    
}


function draw() {
    background(240);

    //monster
    var mx = random(-50,100);//origin x
    var my = random(30,100);//origin y
    var sy = 200;//y spacing
    var sx = 200;//x spacing
    for (var y = 0; y<7; y++) {
        if (y%2==0) {
            for (var x = 0; x<5; x++) {
                monster(mx+x*sx, my+y* (sy*sqrt(3)/2));
            }
        } else {
            for (var x = 0; x<5; x++) {
                monster(mx+sx/2+x*sx, my+y* (sy*sqrt(3)/2));
            }
        }
    }
    noLoop();

    //duck
    var dx = random(0,50);//origin x
    var dy = random(30,50);//origin y
    var sy = 150;//y spacing
    var sx = 250;//x spacing
    for (var y = 0; y<7; y++) {
        if (y%2==0) {
            for (var x = 0; x<5; x++) {
                duck(dx+sx/2+x*sx, dy+y* (sy*sqrt(3)/2));
            }
        } else {
            for (var x = 0; x<5; x++) {
                duck(dx+x*sx, dy+y* (sy*sqrt(3)/2));
            }
        }
    }
    noLoop();

}

function monster(mx, my) {//draw monster
    push();
    translate(mx, my);
    stroke(137,78,115);
    strokeWeight(5);
    line(25, -25, 25, 0);//ear1
    line(45, -25, 35, 0);//ear2
    line(30, 30, 85, 40);//tail
    stroke(244,179,220);
    strokeWeight(30);
    line(10, 0, 50, 0);//monster head
    strokeWeight(5);
    line(35, 40, 35, 60);//foot1
    line(45, 40, 45, 60);//foot2
    line(55, 40, 55, 60);//foot3
    line(65, 40, 65, 60);//foot4
    strokeWeight(50);
    line(50, 10, 50, 30);//monster body
    fill(255);
    noStroke();
    ellipse(22, 0, 15, 15);//left eye
    ellipse(42, 0, 15, 15);//right eye
    fill(0);
    noStroke();
    ellipse(20, 0, 5, 5);//eyeball1
    ellipse(40, 0, 5, 5);//eyeball2
    pop();
}

function duck(dx, dy) {//draw duck
    push();
    translate(dx, dy);
    stroke(255, 183, 0);
    strokeWeight(5);
    line(-15, 60, -15, 85);//foot1
    line(-5, 60, -5, 85);//foot2
    stroke(154, 231, 217);
    strokeWeight(40);
    line(0, 0, 0, 30);//neck
    strokeWeight(40);
    line(-30, 40, 0, 40);//body
    strokeWeight(10);
    line(-55, 40, -30, 40);//tail
    stroke(255, 183, 0);
    strokeWeight(7);
    line(10, 7, 25, 7);//mouse
    line(10, 14, 25, 14);//mouse
    fill(255);
    noStroke();
    ellipse(0, 0, 10, 10);//eye
    fill(0);
    noStroke();
    ellipse(1, 0, 5, 5);



    pop();
}


For this wallpaper, I used ‘random’ command to generate a little bit different patterns each time it is opened, and I tried to make the grid hexagon to add some interest to the grid.

sketch

Leave a Reply