Project-05: Wallpaper

I applied the same coding structure I used in my assignment A to this project. Then, I changed the repeated shapes from Hexagon to my designed shapes 1 and 2. Because of the assignment A, it is relatively easy to create this wallpaper pattern.

project05: wallpaperDownload
var x;
var y;
var a=20;
var b=20;



function setup() {
    createCanvas(400, 300);
    background( 240,230,140);
}

//shape in the first column
function shape1(){
    push();
    translate(a,b);
    noStroke();
    x=0;
    y=0;
    var s = 10;
    if(color==1){
        fill(255);
        circle(x,y,s);
        fill(175,238,238);
        circle(x,y+5,s);
        color+=1;
    }
    else{
        fill(175,238,238);
        circle(x,y,s);
        fill(255);
        circle(x,y+5,s);
        color=1;
    }
    
    pop();
}
//shape in the second column
function shape2(){
    push();
    translate(a,b);

    x=0;
    y=0;
    var d=5;
    strokeWeight(2);
    stroke(139,69,19);
    line(x-d,y,x,y-10);
    line(x+d,y,x,y-10);
    noStroke();
    fill(255,69,0);
    circle(x-d,y,10);
    circle(x+d,y,10);
    pop();
}

function draw() {
    //two circles
    for(b=20; b<=400; b +=50){
        for(a=20; a<=500; a+=50){
            shape1();
        }
    }

    //cherry shape
    
    for(b=50; b<=250; b +=50){
        for(a=45; a<=350; a+=50){
            shape2();
        }
    }


}

Leave a Reply