Lvanveen Project 9: Portrait

My project 9! I decided to reuse and modify some code from our wallpaper project to make the design more fun, and overall, I’m pretty pleased!

sketch
var img; //the code takes a sec to load, but it does load don't worry!

function preload(){
	img = loadImage("https://i.imgur.com/UerFer7.jpg");
}

function setup() {
    createCanvas(480, 400);
    background(200);
    strokeWeight(0)
}

function draw() {
	fill(255);
	background(200)
	image(img, 0, 0, width, height);
	fill(255, 35, 10); //red
	rect(0, 0, width, height);

	for(var y = 0; y < 500; y += 100){ //initally the background was just bright red, but I wanted more of a pattern...
		for(var x = 0; x < 600; x += 200){ //... so I decided to reuse some code that made flowers that I used in week 5 w/ a change in color etc
            
			drawFlower(x, y);
		}
	}

	for(var y = -50; y < 500; y += 100){
		for(var x = 100; x < 600; x += 200){
			drawFlower(x, y);
		}
	}

    for(var col = 500; col < 600; col += 40){
        strokeWeight(2)
        stroke(110, 94, 66);
        fill(186, 156, 95);
        rect(col, 350, 40, 50);
    }
	for(var i = 0; i <= width/5; i++){ //use of 5 basically made the scale of the pixels 5x bigger
		for(var j = 0; j <= height/5; j++){
			c = img.get(i*5, j*5);
			if(c[0] > 110 & c[1] > 110 && c[2] > 110){
				strokeWeight(0);
				fill(140, 255, 251); //cyan blue of face
				rect(i*5, j*5, 5, 5);
			}
		}
	}
}

function drawFlower(x, y) { //code to make flowers
	push();
	translate(x, y); 
	strokeWeight(8);
	stroke(184, 176, 79); //green stem color
	line(-25, 35, -40, 50);
	line(-40, 50, -45, 60);
	line(-45, 60, -55, 20);
	line(-55, 20, -55, 0);
	line(-45, 60, -55, 90);

	strokeWeight(0);
	fill(184, 176, 79); //same green
	ellipse(-55, 0, 20, 30);

	push();
	rotate(radians(30));
	fill(209, 187, 96); //underside of stem color
    rect(-10, 0, 15, 45);
    pop();

    fill(255, 209, 25); //main flower yellow color
    rect(-15, -35, 30, 50); //base of the flowers
    rect(-35, -5, 40, 20);
    rect(5, -5, 30, 30); 
    rect(-15, 15, 20, 20);

    push();
    rotate(radians(45));
    rect(-14, 6, 15, 30);
    rect(-32, -4, 30, 15);
    rect(-5, -35, 15, 30);
    pop();

    strokeWeight(1);
    stroke(245, 183, 15); //darker yellow thin line flower color
    line(0, 0, -3, -25);
    line(0, 0, 7, -25);
    line(0, 0, -8, -25);
    line(0, 0, 12, -25);
    line(0, 0, -30, 1);
    line(0, 0, -30, -2);
    line(0, 0, -25, 15);
    line(0, 0, -20, 20);
    line(0, 0, 27, 15);
    line(0, 0, 25, 20);
    line(0, 0, 30, 5);
    line(0, 0, 30, 0);

    stroke(250, 231, 180); //flower light cream color
    strokeWeight(2);
    line(0, 0, 3, -25);
    line(0, 0, -30, 5);
    line(0, 0, 30, 10);

    strokeWeight(1);
    stroke(242, 223, 145); //lines connecting seeds color
    line(0, 0, 10, -10);
    line(0, 0, 9, -5);
    line(0, 0, 13, -13);
    line(0, 0, 15, -18);
    line(0, 0, 10, -15);

    strokeWeight(0);
    fill(69, 43, 31); //seed color
    ellipse(10, -10, 3, 3);
    ellipse(9, -5, 3, 3);
    ellipse(13, -13, 3, 3);
    ellipse(15, -18, 3, 3);
    ellipse(10, -15, 3, 3);
    pop();
}

Leave a Reply