Project 5: Wallpaper

wallpaper karan

function setup() {
    createCanvas(450, 450);
    background(220);
    text("p5.js vers 0.9.0 test.", 10, 15);
}

function draw() {
    for(x=75;x<=375;x+=150){ //loop for pink shaded eye pattern
        for(y=37.5;y<=412.5;y+=75){
            pattern(x,y);
        }
    }
    for(x=0;x<=width;x+=150){ //loop for yellow shaded eye pattern
        for(y=0;y<=height;y+=75){
            pattern2(x,y);
        }
    }
    noLoop()
}

function pattern(centerX,centerY){ //pattern for pink eye
    noStroke()
    fill(200,121,174); 
    quad(centerX-75,centerY,centerX,centerY-37.5,centerX+75,centerY,centerX,centerY+37.5); //rhombus
    fill(79,0,145);
    arc(centerX,centerY+18.75,75,75,PI+PI/6,2*PI-PI/6,CHORD) //outer eye top half
    arc(centerX,centerY-18.75,75,75,PI/6,PI-PI/6,CHORD) //outer eye lower half
    fill(189,151,177);
    ellipse(centerX,centerY,37.5,37.5);//outer pupil 
    fill(0);
    ellipse(centerX,centerY,18.75,18.75);//inner pupil
}

function pattern2(centerX,centerY){//same code, different colours
    noStroke()
    fill(254,199,73);
    quad(centerX-75,centerY,centerX,centerY-37.5,centerX+75,centerY,centerX,centerY+37.5);
    fill(251,254,46);
    arc(centerX,centerY+18.75,75,75,PI+PI/6,2*PI-PI/6,CHORD)
    arc(centerX,centerY-18.75,75,75,PI/6,PI-PI/6,CHORD)
    fill(254,183,116);
    ellipse(centerX,centerY,37.5,37.5);
    fill(0);
    ellipse(centerX,centerY,18.75,18.75);
}

This was an interesting project because I liked that I drew eyes. It was a little tricky figure where the arcs should be placed.

Leave a Reply