Wallpaper/fabric

fabric sketch
function setup() {
    createCanvas(620, 600);
    background('skyblue');
}

function draw() {
    //blue patches
    for(let x=10; x<width; x+=240){
        for(let y=0; y<height; y+=240){
            patch(x,y);
        }
    }

    //other blue lol
    for(let x=130; x<width; x+=240){
        for(let y=120; y<height; y+=240){
            patchtw(x,y);
        }
    }

    //pig moving etc
    for(let x=70; x<width; x+=120){
        for(let y=50; y<height-50; y+= 120){
            pigg(x, y);       
        }
    }

    //rows of stitch up and down
    for(let x=10; x<width; x+=120){
        for(let y = 10; y<height; y+=20){
            cross(x, y);
        }
    }

    //row of stitch across
    for(let y =120; y<height; y+=120){
        for(let x=10; x<width; x+=20){
        cross(x,y);
        }
    }

}



function pigg (x, y){
    strokeWeight(1);
    stroke('black');
    fill('pink');
    //legs
    rect(x - 30, y, 10, 60);
    rect(x + 20, y, 10, 60);
    //bod
    ellipse(x, y, 100, 80);
    //ears
    triangle(x-10, y-20, x-20, y-15, x-20, y-30);
    triangle(x+10, y-20, x+20, y-15, x+20, y-30);
    //head
    ellipse(x, y, 50);
    //snout
    push();
    fill('plum');
    ellipse(x, y+10, 20, 10); 
    pop();
    //eyes
    push();
    fill('black');
    ellipse(x-10, y-5, 5);
    ellipse(x+10, y-5, 5);
    //nose hole
    ellipse(x-5, y+10, 2);
    ellipse(x+5, y+10, 2); 
    pop(); 
 
}


function cross(x,y){
    strokeWeight(1);
    stroke('yellow');
    line(x-10, y-10, x+10, y+10);
    line(x-10, y+10, x+10, y-10);
}

function patch(x,y){
    noStroke();
    fill('darkcyan');
    rect(x, y, 120, 120);
}

function patchtw(x,y){
    noStroke();
    fill('lightseagreen');
    rect(x, y, 120, 120);
}

Leave a Reply