Project-05-Wallpaper

I was inspired by one of my favorite prints-cow print, and a fruit I love- cherries. Additionally, when you click on the image, the background will change.

graanak-05
//Graana Khan
//Section B
//graanak@andrew.cmu.edu
//Project-05

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

function draw() {
	
	//cow print backdrop 

	background(255);
	noStroke();
	fill(0);
	beginShape();
	curveVertex(40, 45);
	curveVertex(40, 45);
	curveVertex(46, 35);
	curveVertex(76, 26);
	curveVertex(139, 78);
	curveVertex(66, 141);
	curveVertex(36, 123);
	curveVertex(47, 83);
	curveVertex(47, 83);
	endShape();
	beginShape();
	curveVertex(180, 32);
	curveVertex(180, 32);
	curveVertex(197, 19);
	curveVertex(249, 23);
	curveVertex(255, 62);
	curveVertex(232, 62);
	curveVertex(232, 62);
	endShape();
	beginShape();
	curveVertex(276, 45);
	curveVertex(276, 45);
	curveVertex(307, 23);
	curveVertex(361, 26);
	curveVertex(375, 89);
	curveVertex(369, 126);
	curveVertex(318, 141);
	curveVertex(282, 82);
	curveVertex(282, 82);
	endShape();
	beginShape();
	curveVertex(156, 141);
	curveVertex(156, 141);
	curveVertex(152, 120);
	curveVertex(196, 82);
	curveVertex(256, 117);
	curveVertex(316, 197);
	curveVertex(259, 220);
	curveVertex(176, 187);
	curveVertex(176, 187);
	endShape();
	beginShape();;
	curveVertex(344, 182);
	curveVertex(344, 182);
	curveVertex(355, 199);
	curveVertex(355, 231);
	curveVertex(331, 196);
	curveVertex(331, 196);
	endShape();
	beginShape();
	curveVertex(83, 172);
	curveVertex(83, 172);
	curveVertex(56, 170);
	curveVertex(44, 200);
	curveVertex(52, 210);
	curveVertex(87, 200);
	curveVertex(87, 200);
	endShape();
	beginShape();
	curveVertex(168, 253);
	curveVertex(168, 253);
	curveVertex(175, 231);
	curveVertex(196, 228);
	curveVertex(218, 241);
	curveVertex(208, 273);
	curveVertex(180, 273);
	curveVertex(180, 273);
	endShape();
	beginShape();
	curveVertex(78, 253);
	curveVertex(78, 253);
	curveVertex(130, 247);
	curveVertex(180, 331);
	curveVertex(142, 369);
	curveVertex(78, 377);
	curveVertex(36, 317);
	curveVertex(36, 317);
	endShape();
	beginShape();
	curveVertex(250, 253);
	curveVertex(250, 253);
	curveVertex(311, 244);
	curveVertex(354, 259);
	curveVertex(369, 293);
	curveVertex(307, 321);
	curveVertex(237, 324);
	curveVertex(237, 324);
	endShape();
	beginShape();
	curveVertex(214, 341);
	curveVertex(214, 341);
	curveVertex(242, 345);
	curveVertex(248, 365);
	curveVertex(206, 377);
	curveVertex(195, 367);
	curveVertex(195, 367);
	endShape();
	beginShape();
	curveVertex(234, 400);
    curveVertex(234, 400);
    curveVertex(293, 349);
    curveVertex(369, 363);
    curveVertex(388, 400);
    curveVertex(388, 400);
    endShape();
    beginShape();
    curveVertex(23, 348);
    curveVertex(23, 348);
    curveVertex(44, 362);
    curveVertex(52, 388);
    curveVertex(10, 384);
    curveVertex(5, 374);
    curveVertex(5, 374);
    endShape();

    //red cherry columns 

    for(var x = -10; x <= 340; x += 100){
    	for(var y = -60; y <= 372; y += 80){
    		push();
    		translate(x,y);
    		rotate(radians(-15));
    		cherries();
    		pop();
    	}
    }


    // pink cherry columnns

    for(var x = 60; x <= 293; x += 100){
    	for(var y = 45; y <= 352; y += 80){
    		push();
    		translate(x,y);
    		rotate(radians(15));
    		pinkcherries();
    		pop();
    	}
    }
    noLoop();
}

function mousePressed(){
    background(213, 238, 247);
    for(var x = 0; x <= 360; x += 145){
        for(var y = 0; y <= 360; y += 105){
        	push();
        	translate(x,y);
        	clouds1();
        	pop();
    		
    	}
    }

    for(var x = 0; x <= 260; x += 145){
    	for(var y = 0; y <= 260; y += 105){
    		push();
    		translate(x,y);
    		clouds2();
    		pop();
    	}
    }

    //red cherry columns 

    for(var x = -10; x <= 340; x += 100){
    	for(var y = -60; y <= 372; y += 80){
    		push();
    		translate(x,y);
    		rotate(radians(-15));
    		cherries();
    		pop();
    	}
    }


    // pink cherry columnns

    for(var x = 60; x <= 293; x += 100){
    	for(var y = 45; y <= 352; y += 80){
    		push();
    		translate(x,y);
    		rotate(radians(15));
    		pinkcherries();
    		pop();
    	}
    }
    noLoop();    
}

//cherries pattern

function cherries(){

	//stems
	stroke(61, 130, 48);
	strokeWeight(2);
	line(35, 40, 44, 22);
	line(53, 40, 44, 22);
	
	//leaf
	noStroke();
	fill(61, 130, 48);
	beginShape();
	curveVertex(44, 22);
	curveVertex(44, 22);
	curveVertex(46, 19);
	curveVertex(50, 19);
	curveVertex(47, 22);
	curveVertex(47, 22);
	endShape();

	//cherry
	noStroke();
	fill(229, 14, 14);
	circle(35, 44, 15);
	circle(52, 44, 15);

}

function pinkcherries(){

	//stems
	stroke(61, 130, 48);
	strokeWeight(2);
	line(35, 40, 44, 22);
	line(53, 40, 44, 22);
	
	//leaf
	noStroke();
	fill(61, 130, 48);
	beginShape();
	curveVertex(44, 22);
	curveVertex(44, 22);
	curveVertex(46, 19);
	curveVertex(50, 19);
	curveVertex(47, 22);
	curveVertex(47, 22);
	endShape();

	//cherry
	noStroke();
	fill(255, 199, 227);
	circle(35, 44, 15);
	circle(52, 44, 15);

}


//clouds1 pattern 
function clouds1(){
	noStroke();
	fill(255);
	rect(21, 23, 51, 28, 30);
	rect(51, 40, 38, 18, 15);
}

//clouds2 pattern 
function clouds2(){
	noStroke();
	fill(255);
	rect(106, 76, 60, 24, 20);
	rect(103, 89, 33, 24, 10);
}

Leave a Reply