ssharada-project-02-variable-face-section-a

project-02-1.js

//Shariwa Sharada
//Section A
//ssharada@andrew.cmu.edu
//Project-02-Variable Face

var x = 0
var y = 0
var eyeWidth = 12.5
var eyeHeight = 17.5
var earWidth = 50
var earHeight = 100
var bodyWidth = 350
var bodyHeight = 750
var armPlacementX = 100
var armPlacementY = 675
var noseWidth = 20
var noseHeight = 30
var eyeColour = (119,79,56)
var noseColour = (119,79,56)
var bodyColour = (255, 254, 240)

function setup() {
	createCanvas(500, 800);
	background(218,239,239);	
}

function draw() {	
	if (random(1) > 0.5) {
		stroke(114, 169, 182);
		strokeWeight(.5);
    	line(x, y, x-40, y-40);
 	} 
 	else {
 		stroke(114, 169, 182);
 		strokeWeight(.5);
    	line(x, y-40, x-40, y);
	}

	x += 60;
	if (x > width) {
		x = 0;
		y += 10;
	}

	if (y > height) {
		background(218,239,random(220,260));
		x = 0;
		y = 0;
	}
//ears
	push();
	rotate(PI*3.8);
	translate(-475,150);
	fill(bodyColour);
	stroke(241,212,175);
	strokeWeight(2);
	ellipse(width/1.6, height/1.9, earWidth, earHeight);
	ellipse(width/3.2, height/1.8, earWidth, earHeight);
	pop();

//body, arm, ears
	push();
	rotate(PI*3.8);
	translate(-475,150);
	fill(bodyColour);
	stroke(241,212,175);
	strokeWeight(2);
	ellipse(width/2, height/1.06, bodyWidth, bodyHeight);
	ellipse(armPlacementX, armPlacementY, width/4, height/2);
	pop();

//paw fingers
	stroke(119, 79, 56);
	strokeWeight(1.5);
	line(armPlacementX-25, armPlacementY+47, armPlacementX, armPlacementY+75);

	push();
	translate(-11, 4);
	line(armPlacementX-25, armPlacementY+47, armPlacementX, armPlacementY+75);
	pop();

	push();
	translate(-18, 14);
	line(armPlacementX-25, armPlacementY+47, armPlacementX, armPlacementY+75);
	pop();

//eyes
	fill(eyeColour);
	noStroke();;
	ellipse(width/3, height/1.17, eyeWidth, eyeHeight);
	ellipse(width/2.3, height/1.25, eyeWidth, eyeHeight);

//nose
	push();
	rotate(PI*0.175);
	translate(340,-160);
	fill(noseColour);
	ellipse(width/2.3, height/1.25, noseWidth, noseHeight);
	pop();

//mouth
	push();
	noFill();
	stroke(eyeColour);
	arc(250, 700, 75, 120, PI*0.17, PI/1.73);
	pop();
}

function mouseClicked(){
	background(218,239,random(220,260));
	y=0
	x=0
	earWidth = random(25, 75);
	earHeight = random(75, 125);
	eyeWidth = random(5, 25);
	eyeHeight = random(10, 30);
	armPlacementX = random(75, 125);
	armPlacementY = random(650, 700);
	eyeColour = (random(99,139),random(59,99),random(56,166));
	noseColour =(random(99,139),random(59,99),random(56,166));
	noseWidth = random (noseWidth-7.5, noseWidth+7.5);
	noseHeight = random (noseHeight-7.5, noseHeight+7.5);
}


































 

This is a polar bear that is waving at you with a little precipitation around him. The eyes, arm movement, background, nose, and ears have been made variable through colour and/or positioning.

Leave a Reply