hyt-Project-02: Minion Faces

hyt-02-Minions

// helen tsui
// 15-104 section d
// hyt@andrew.cmu.edu
// project-02-minions-variation

var eyeSize = 50;
var mouthSize = 30; 
var bodyWidth = 140;
var bodyHeight = 130;
var eyeballSize = 40; 
var mouthAngle = 100;
var x = 0; //rgb value randomization


function setup() {
    createCanvas(480, 640);   
}

function draw() {
    angleMode(DEGREES); // angle unit change
    background(x, 194, 239); // blue and pink-ish backgrounds randomizing
    
// body
    stroke(0);
    strokeWeight(4.5);
    fill(255, 221, 119); // yellow
    arc(width / 2, height / 2, bodyWidth, bodyHeight, 180, 360, OPEN); // bald head part
    rect(width / 2 - bodyWidth / 2, height / 2, bodyWidth, bodyHeight); // actual body

//pants?
    fill(68, 100, 133); // denim blue
    arc(width / 2, height / 2 + bodyHeight, bodyWidth, bodyHeight - 30, 0, 180, OPEN);

// eyes    
    var eyeLX = width / 2 - bodyWidth * 0.23; // Left eye's x position
    var eyeRX = width / 2 + bodyWidth * 0.23; // Right eye's x position
    fill(256); // white
    ellipse(eyeLX, height / 2, eyeSize, eyeSize); // 
    ellipse(eyeRX, height / 2, eyeSize, eyeSize);

// eyeballs
    fill(60, 40, 40); // brown
    noStroke();
    ellipse(eyeLX, height / 2, eyeballSize, eyeballSize);
    ellipse(eyeRX, height / 2, eyeballSize, eyeballSize);

// mouth
    fill(0);
    arc(width / 2, height / 2 + bodyHeight - 50, mouthSize, mouthSize, 0, mouthAngle);

// hands (referenced from p5.js angleMode)
    var a = atan2(mouseY - height / 2, mouseX - width / 2);
    fill(255, 221, 119); // yellow
    
// left hand rotate! 
    translate(width / 2 - bodyWidth / 2, height / 2 + bodyHeight);
    push();
    rotate(a);
    rect(0, - bodyHeight / 12, bodyHeight / 3, bodyHeight / 6); // arms
    fill(0); // black
    ellipse(bodyHeight / 3, 0, bodyHeight / 5, bodyHeight / 5); // black hands
    pop();

// right hand rotate! 
    translate(bodyWidth, 0);
    push();
    rotate(a);
    rect(0, - bodyHeight / 12, bodyHeight / 3, bodyHeight / 6); // arms
    fill(0); // black
    ellipse(bodyHeight / 3, 0, bodyHeight / 5, bodyHeight / 5); // black hands
    pop();

 }


// randomization when mouse clicks on the canvas
function mousePressed() {
    bodyWidth = random(100, 180);
    bodyHeight = random(90, 180);
    eyeSize = random(30, 50);
    eyeballSize = eyeSize - 12; 
    mouthSize = eyeSize; 
    mouthAngle = random(10, 220); 
    x = random(81, 225); // background rgb value change
}

Now that we have entered week 2, there are many more functions and attributes that I have began to explore in p5.js, and based on those I decided to make a minion with animation-like facial features for my program. I didn’t particularly plan out the sketches on Illustrator, but rather drew out primitive shapes like ellipses and rectangles through trial and error. One of the more difficult process was the moving hands when the mouse hovers over, but once I figured out the coordinates and center for rotation it became much easier. Overall, I really enjoyed creating the project!

rkondrup-project-02

face.js

/*Ryu Kondrup
rkondrup@andrew.cmu.edu
Section D
project-02*/
//feature variables

var eyeHeight = 30;
var eyeWidth = 15;
var noseyLiars = 50;
var mouthAgape = 30;
var hatHeight = 120;
var rightShadow = 15;
var downShadow = 10;
var mouthWidth = 30;
var r, g, b;

function setup() {
    createCanvas(640, 480);
    r = random(150, 255);
    g = random(150, 255);
    b = random(150, 255);
  }

function draw() {
  background(26, 83, 92);
  //colors
    var darkDarkBlue = color(22, 74, 82);
    var darkBlue = color(26, 83, 92);
    var blue = color(78, 205, 196);
    var white = color(248, 255, 247);
    var red = color(255, 107, 107);
    var yellow = color(255, 231, 109);



noStroke();


//shirt SHADOW
fill(darkDarkBlue);
rectMode(CENTER);
rect(150+rightShadow, 390+downShadow, 150, 200, 75);

//collar SHADOW
fill(darkDarkBlue);
ellipse(150+rightShadow, 320+downShadow, 160, 50);

//hat top SHADOW
fill(darkDarkBlue);
rectMode(CENTER);
rect(150+rightShadow, 145+downShadow, 120, hatHeight, 60);

//brim of hat SHADOW
fill(darkDarkBlue);
rectMode(CENTER);
rect(150+rightShadow, 190+downShadow, 150, 30, 15);

//head SHADOW
fill(darkDarkBlue);
ellipse(150+rightShadow, 250+downShadow, 150, 150);

//hat wrap SHADOW
fill(darkDarkBlue);
rect(150+rightShadow, 160+downShadow, 120, 30);

//noooose SHADOW
fill(darkDarkBlue);
rectMode(CORNER);
rect(190+rightShadow, 230+downShadow, noseyLiars, 30, 15);



//shirt
fill(yellow);
rectMode(CENTER);
rect(150, 390, 150, 200, 75);

//collar
fill(white);
ellipse(150, 320, 160, 50);

//hat top
fill(yellow);
rectMode(CENTER);
rect(150, 145, 120, hatHeight, 60);

//head
fill(blue);
ellipse(150, 250, 150, 150);

//eyeball
fill(white);
ellipse(140, 240, eyeWidth, eyeHeight);

//brim of hat
fill(yellow);
rectMode(CENTER);
rect(150, 190, 150, 30, 15);

//hat wrap
fill(blue);
rect(150, 160, 120, 30);

//bow CENTER
fill(blue);
ellipse(160, 355, 40);
//bow right
ellipse(195, 355, 40, 60);
//bow right
ellipse(125, 355, 40, 60);

//mouth
fill(red);
rectMode(CORNER);
rect(170, 270, 30, mouthAgape, 15);

//noooose
fill(r, g, b);
rectMode(CORNER);
rect(190, 230, noseyLiars, 30, 15);





}

function mousePressed() {
    eyeHeight = random(30, 70);
    eyeWidth = random(15, 30);
    noseyLiars = random(50, 500);
    mouthAgape = random(30,90);
    hatHeight = random(120, 300);
    r = random(200, 255);
    g = random(100, 255);
    b = random(100, 255);

}

Creating this interactive image was lots of fun.  I wanted to have a concept that made sense with the aim of the assignment, so I settled on a wooden boy as a subject. I also wanted to explore how facial expressions change with different sized facial features. I would like to further explore how features can be changed in ways other than through clicking that can add more depth and complexity to the image.

Project-02-Variable-Face

sketch

//Hanna Jang 
//hannajan@andrew.cmu.edu 
//Section B 
//Project 2: Variable Faces

var BGcircleSize=250;
var BGcircleSize2=280;
var UpperFaceWidth=100; 
var UpperFaceHeight=80; 
var SmileX=300; 
var SmileY=245;
var Smilewidth=15; 
var SmileHeight=15; 
var anglestart=0; 
var LowerFaceWidth=150; 
var LowerFaceHeight=100;
var EyeSize=27;
var PupilSize=7;
var NostrilWidth=5;
var NostrilHeight=15; 
var EarSize=25;
var InnerEarSize=13;

function setup() {
    createCanvas(640, 480);
    background(245, 196, 224);
}

function draw() {
	//Background Circles
	fill(27, 71, 128);
	ellipse(width/2, height/2-45, BGcircleSize2, BGcircleSize2);
	fill(255);
	noStroke();
	ellipse(width/2, height/2-45, BGcircleSize, BGcircleSize);
	
	//ears 
	fill(202, 197, 245);
	var LXear =width/2-UpperFaceWidth*0.40; 
	var RXear =width/2+UpperFaceWidth*0.40; 
	ellipse(LXear, height/2-105, EarSize, EarSize);
	ellipse(RXear, height/2-105, EarSize, EarSize);
	
	//innerears
	fill(157, 141, 187); 
	var LXear =width/2-UpperFaceWidth*0.40; 
	var RXear =width/2+UpperFaceWidth*0.40; 
	ellipse(LXear, height/2-105, InnerEarSize, InnerEarSize);
	ellipse(RXear, height/2-105, InnerEarSize, InnerEarSize);
	
	//UpperFace
	fill(202, 197, 245); 
	ellipse(width/2, height/2-75, UpperFaceWidth, UpperFaceHeight);
	
	//LowerFace 
	fill(202, 197, 245);
	ellipse(width/2, height/2-20, LowerFaceWidth, LowerFaceHeight);

	//eyes 
	var LXeye =width/2-UpperFaceWidth*0.27;
	var RXeye =width/2+UpperFaceWidth*0.27;
	fill(255);
	noStroke();
	ellipse(LXeye, height/2-83, EyeSize, EyeSize);
	ellipse(RXeye, height/2-83, EyeSize, EyeSize);
	
	//pupils
	var LXpupil =width/2-UpperFaceWidth*0.27; 
	var RXpupil =width/2+UpperFaceWidth*0.27;
	fill(0);
	ellipse(LXpupil, height/2-81, PupilSize, PupilSize);
	ellipse(RXpupil, height/2-81, PupilSize, PupilSize);
	
	//nostrils
	var LXnostril =width/2-LowerFaceWidth*0.30;
	var RXnostril =width/2+LowerFaceWidth*0.30;
	ellipse(LXnostril, height/2-30, NostrilWidth, NostrilHeight);
	ellipse(RXnostril, height/2-30, NostrilWidth, NostrilHeight);
	
	//smile 
	fill(198, 73, 59);
	arc(SmileX, SmileY, Smilewidth, SmileHeight, anglestart, PI+QUARTER_PI, OPEN);
	}
	
function mousePressed() {
	//when the user's mouse clicks, these variables are reassigned
	//to random variables within specified ranges 
	
	BGcircleSize2=random(270, 350);
	EyeSize=random(20, 35);
	LowerFaceWidth=random(100, 180);
	LowerFaceHeight=random(90, 120);
	NostrilWidth=random(5, 15);
	NostrilHeight=random(15, 30);
	SmileX=random(280, 330);
	SmileY=random(240, 250);
	EarSize=random(25, 35); 
	
}
	
	

When I first saw the project assignment, I knew I wanted to make my character a hippo, one of my favorite animals. I then sketched up different ideas to make different changes on the hippo’s face when the mouse was clicked. This included variations in eyes, nostrils, ears, and the lower mouth area.

I then experimented with the different variations of sizes and movement of face structures. I was pleased to see that each time the mouse was clicked, a completely new hippo identity appeared, by random variation.

gyueunp – Project-02: Variable Faces

variable face

// GyuEun Park
// 15-104 E
// gyueunp@andrew.cmu.edu
// Project-02

var eyeSize = 14;
var blushTransp = 0;
var colorR = 112;
var colorG = 104;
var colorB = 104;
var eyebrowTransp = 0;

function setup() {
    createCanvas(480, 600);
}

function draw() {
	background(colorR,colorG,colorB);

	// ears
	fill(0);
	noStroke();
	ellipse(175,125,20,30);
	ellipse(305,125,20,30);

	// head and neck
	fill(252,252,248);
	ellipse(width/2,320,280,440);
	
	// face
	fill(240,234,227);
	ellipse(width/2,230,170,200);

	// eyes
	fill(70);
	ellipse(200,230,eyeSize,eyeSize);
	ellipse(280,230,eyeSize,eyeSize);

	//blush
	fill(246,179,167,blushTransp);
	ellipse(190,245,15,6);
	ellipse(290,245,15,6);

	// nose
	stroke(100);
	strokeWeight(2);
	line(235,255,240,260);
	line(245,255,240,260);

	//philtrum
	stroke(100);
	strokeWeight(2);
	line(width/2,260,width/2,275);

	//eyebrows
	stroke(100,eyebrowTransp)
	line(200,215,210,218);
	line(280,215,270,218);

	fill(178,191,199);
	noStroke(0);
	ellipse(230,282,4,4);

	fill(255);
	noStroke(0);
	ellipse(229,281.4,1.5,1.5);
}

function mousePressed() {
	// when the user clicks, these variables are reassigned to random values within specified ranges.
	eyeSize = random(10,20);
	blushTransp = random(0,100);
	colorR = random(100,112);
	colorG = random(100,104);
	colorB = random(100,104);
	eyebrowTransp = random(0,100);
}

I made a face of my new stuffed alpaca. Although the random changes were interesting, I wanted to avoid drastic alterations. Therefore, I focused on creating subtle color and transparency changes in the background and its facial features.

rsp1-SectionB-Project-02-VariableFace

sketch

//Rachel Park
//Section B @ 10:30 AM
//rsp1@andrew.cmu.edu
//Project-02-VariableFace


function setup() {
    createCanvas(480,640);

}
    //variables for the face
    var eyesize = 20; //a
    var facewidth = 155; //b
    var faceheight = 125; //c
    var earwidth = 30;
    var earheight = 60;
    var antwidth = 20;
    var armswidth = 20;
    var armsheight = 20;
    var armheight = 20;
    var handsheight = 440;
    var handswidth = 155/3;
    var bodywidth = d/2-20;
    var d = 480; //bodysize
    var e = 180; //medium gray fill color
    var f = 138; //dark gray fill color

function draw() {
    background(212,249,246);

    //robot face
    var faceX = width/2
    var faceY = height/3

    rectMode(CENTER);
    noStroke();
    fill(e);
    rect(faceX,faceY,facewidth,faceheight,10);

    fill(220);
    rect(faceX,faceY,facewidth-20,faceheight/2,10);

    //ear things
    var earX = width/3
    var earY = height/3

    noStroke();
    fill(f);
    rect(earX-10,earY,earwidth,earheight,5);

    noStroke();
    fill(f);
    rect(width/2+90,earY,earwidth,earheight,5);

    //antennae
    var antY = height/6

    noStroke();
    fill(f);
    rect(width/2,antY+20,antwidth/2,antwidth*2+10,10);

    noStroke();
    fill(255,41,41);
    ellipse(width/2,antY-10,antwidth,antwidth,10);

    //eyes
    var eyeLX = width/2-38.75;
    var eyeRX = width/2+38.75;
    var eyeY = height/3

    noStroke();
    fill(255);
    ellipse(eyeLX,eyeY,eyesize*2,eyesize*2);
    ellipse(eyeRX,eyeY,eyesize*2,eyesize*2);

    fill(203,35,35);
    ellipse(eyeLX,eyeY,eyesize+10,eyesize+10);
    ellipse(eyeRX,eyeY,eyesize+10,eyesize+10);

    //arms joints
    var armsY = height/2
    fill(f);
    ellipse(width/4,armsY,armswidth,armsheight);
    ellipse(width-120,armsY,armswidth,armsheight);

    //legs & feet
    var legsX = width/2
    var legsY = height-125-35
    var legsYX = height-125+35

    fill(f);
    rect(legsX+60,legsY,40,100);
    rect(legsX-60,legsY,40,100);

    fill(203,35,35);
    rect(legsX+60,legsYX,80,40);
    rect(legsX-60,legsYX,80,40);

    //body
    var bodyX = width/2
    var bodyY = height/2+40
    var bodywidth = d/2-20
    var bodyheight = d/3

    noStroke();
    fill(e);
    rect(bodyX,bodyY,bodywidth,bodyheight,10);

    //arms down

    fill(180);
    rect(width/5+5,armheight+340,21,125,5);
    rect(width-100,armheight+340,21,125,5);

    //hands down
    fill(203,35,35);
    arc(width/4-20,armheight+420,155/3,155/3,3*PI/4,PI/4,PIE);
    arc(width/2+155-15,armheight+420,155/3,155/3,3*PI/4,PI/4,PIE);
}

function mousePressed(){
  armheight = random([10,30]);
  armswidth = random([20,30]);
  eyesize = random(10,20);
  facewidth = random(155,160);
  faceheight = random(125,150);
  earwidth = random(30,55);
  earheight = random(25,60);
  antwidth = random(20,30);
  bodywidth = random([220,210]);
}

For my project, I wanted to make a visual of a small robot because I honestly that it was fun to change up of the possible movements of the figure along with the various facial feature sizes. I had an okay time creating the graphics within the code, but eventually got stuck on the actual functions that were used to make the arms and facial features vary in sizes and locations on the canvas. Overall, I thought that this was a very interesting project and thought that it was a good way to continue to practice the skills that we have learned thus far.

Image of the screenshot of my robot before I could figure out the solution to my function problem. I was able to make the arm shapes themselves, but couldn’t get them to appear separately so that it would make the robot look like its raising and lowering its arms with each click.
Variation on the sizes of the head, antenna, ears, and location of the arms.

 

 

 

 

 

 

 

 

 

My process included a lot of trial and error. Initially, I wanted the arms of the robot to translate upwards, making it look like it was waving its arms like a “hurrah!”, but eventually I came up with a code with slight changes to the image itself, making the robot look like it’s shrugging instead.

egrady-project02-variableface

sketch

//Ean Grady
//Section B
//egrady@andrew.cmu.edu
//project-02

var mouth = 25;
var nose = 250;
var eyes = 25;
var eyes2 = 25;
var faceHeight = 150;
var faceWidth = 400;
var x = 0
var y = 0
var z = 0
var x2 = 0
var y2 = 0
var z2 = 0

function setup() {
    createCanvas(640, 480);
}

function draw() {
    background (120, 200, 400);

    //hair
    fill (x, y, z)
    triangle(250, 190, 225, 190, 220, 120)
    triangle(250, 192, 275, 190, 260, 100)
    triangle(275, 190, 300, 190, 300, 120)

    //face
    fill (255, 255, 255)
    stroke (0, 0, 0)
    ellipse (300, 225, faceWidth, faceHeight)

    //eyes
    fill (255, 255, 255)
    stroke (0, 0, 0)
    ellipse (170, 220, eyes*4, eyes*2)
    ellipse (420, 220, eyes*4, eyes*2)
    fill (x2, y, z)
    ellipse (170, 220, eyes2, eyes)
    ellipse (420, 220, eyes2, eyes)

    //nose
    line (nose, 180, 330, 240)
    line (nose, 220, 330, 240)

    //mouth 
    fill (0, 0, 0)
    ellipse (300, 260, 50, mouth)
}

function mousePressed() {
    faceWidth = random(350, 450);
    faceHeight = random(100, 200);
    eyes = random(20, 30);
    nose = random(240, 260);
    mouth = random(10, 40);
    eyes2 = random(20, 70);
    x = random (0, 255);
    y = random (0, 255);
    z = random (0, 255);
}

I found that with this project I had a much easier time setting everything up, and I feel as though I’m finally starting to get the hang of things. I still had a hard time attempting to make the face look more visually pleasing/aesthetic, but I am not mad with the results. Hopefully in future projects I will be able to produce a piece that is both functional (i.e. fulfills the requirements) and visually pleasing.

The design for the face came from a drawing I used to do a lot as a kid whenever I had a sketchbook. It’s pretty simplistic, but I thought that it could fit the goals of the project.

nahyunk1-Project-02-Variable-Face

sketch-124.js

  var eyeSize = 10;
  var faceWidth = 350;
  var faceHeight = 370;
  var red = 255;
  var green = 255;
  var blue = 255;

  function setup() {
      createCanvas(640, 480);
  }

  function draw() {
      background(red, green, blue);
      noStroke();
      smooth();
      //watermelon skin
      fill("green");
      arc(320, 240, faceWidth,  faceHeight, 0, PI, CHORD);
      //watermelon fruit inside
      fill("red");
      arc(320, 240, faceWidth-20, faceHeight-30, 0, PI, CHORD);
      //watermelon smiley mouth
      fill("orange");
      arc(320, 270, eyeSize, eyeSize, 0, PI, CHORD);
      //eyesizes&color
      var eyeLX = 640 / 2 - 20;
      var eyeRX = 640 / 2 + 20;
      fill("black");
      ellipse(eyeLX, 320-50, eyeSize, eyeSize);
      ellipse(eyeRX, 320-50, eyeSize, eyeSize);
  }

  function mousePressed() {
      faceWidth = random(100, 400);
      faceHeight = random(100, 350);
      eyeLX = random(250, 300);
      eyeRX = random(340, 370);
      eyeSize = random (10, 25);
      red = random (0, 255);
      green = random (0, 255);
      blue = random(0, 255);
  }

I really hoped to be able to change the color of the background while trying to make my slice of watermelon character. I made the character with arcs and ellipses.

hschung-Project-02

sketch

//Heidi Chung
//Section A
//hschung@andrew.cmu.edu
//Project-02: Variable Faces; Face Variables
var eyeWidth = 22;
var eyeHeight = 22;
var mouthSize = 40;

var cheekR = 234;
var cheekG = 175;
var cheekB = 152;
var cheekWidth = 60;
var cheekHeight = 60;

var hairR = 76;
var hairG = 54;
var hairB = 36;

var eyebrowWidth = 40;
var eyebrowHeight = 10;
//var leftBrowX = 253;
var BrowY = 210;
//var rightBrowX = 347;
var BrowY = 210;

function setup() {
	 createCanvas(640,480);
	 background(145, 193, 191);

	 noStroke();
	}

function draw() {
	 fill(hairR-30, hairG-30, hairB-50); //background hair //fill(31, 34, 13);
	 quad(200, 195,  400, 185,  425, 375,  180, 375);

	 fill(234, 178, 117); //neck
	 rect(263, 380, 78, 78);

	 fill(235, 207, 155); //face
	 ellipse(300, 260, 210, 260);

	 fill(200, 125, 95); //mouth
	 ellipse(600/2, 600/2 +10, 60, mouthSize);

	 fill(235, 207, 155);//eclipse over mouth
	 rect(600/2 -40, 600/2 -75, 70, 85);


	 fill(cheekR, cheekG, cheekB); //left blush //fill(234, 175, 152);
	 ellipse(235, 265, cheekWidth, cheekHeight); //ellipse(235, 265, 60, 60);

	 fill(cheekR, cheekG, cheekB); //right blush
	 ellipse(365, 265, cheekWidth, cheekHeight);

	  fill(61, 44, 23); //left eye
	 ellipse(250, 240, eyeWidth, eyeHeight);

	 fill(61, 44, 23); //right eye
	 ellipse(350, 240, eyeWidth, eyeHeight);

	 fill(hairR-20, hairG-10, hairB-20); //left eyebrow // ellipse(253, 210, 40, 10)
	 ellipse(253, BrowY, eyebrowWidth, eyebrowHeight); //ellipse(253, 210, width, height)

	  fill(hairR-20, hairG-10, hairB-20); //right eyebrow
	 ellipse(347, BrowY, eyebrowWidth, eyebrowHeight); //ellipse(347, 210, width, height)


	 fill(234, 178, 117); //nose
	 triangle(300, 267, 320, 290, 280, 290);

	 fill(hairR, hairG, hairB); //more hair// fill(76, 54, 36);
	 quad(222, 159,  345, 129,  420, 220,  391, 230);

	 fill(hairR, hairG, hairB); //more hair
	 quad(371, 398,  391, 228,  421, 219,  433, 340);

	 fill(hairR, hairG, hairB); //more hair
	 quad(215, 156,  183, 234,  206, 245,  247, 163);

	 fill(hairR, hairG, hairB); //more hair
	 quad(183, 234,  174, 345,  237, 400,  207, 244);

	 fill(hairR, hairG, hairB); // top part of hair
	 quad(216, 157,  275, 123,  377, 132,  420, 219);

	 fill(hairR, hairG, hairB);
	 triangle(183, 235,  207, 149,  275, 122);
	}
function mousePressed() {
	eyeWidth = random(20, 35);
	eyeHeight = random(15, 35);
	mouthSize = random(10, 85);
	cheekR = random(234, 274);
	cheekG = random(175, 195);
	cheekB = random(152, 172);
	hairR = random(50, 100);
	hairG = random(54, 80);
	hairB = random(36, 70);
	eyebrowWidth = random(35, 50);
	eyebrowHeight = random(10, 20);
	cheekWidth = random(50, 75);
	cheekHeight = random(50, 75);
	BrowY = random(210, 223);
	//leftBrowX = random (253, 263);
	//rightBrowX = random (347, 357);
	

}

I used my previous face from the self-portrait as a base. I did a sketch in Illustrator for that face to give me direction as I drew it in code.

It took me a couple times to get used to manipulating the different values as variables, but once I got the hang of a few variables, it was easier for me to think of other values to turn into variables. Rather than make completely different faces, I made my program create mildly different versions of my self portrait. If I changed the hair too, it’d be drastically different, but I like it this way.

ljkim – project 02

sketch

/*Lois Kim
Section A
ljkim@andrew.cmu.edu
Project-02*/

var helmetWidth = 323;
var helmetHeight = 323;
var shieldWidth = 275;
var shieldHeight = 275;
var shieldOHeight = 275;
var shieldOWidth = 275;
var faceWidth =  178;
var faceHeight = 183;

//stars in sky
var star = {
  x: 100,
  y: 50
}

//color of stars
var col = {
  r: 255,
  g: 255,
  b: 255
}

function setup() {
  createCanvas(640,480);
}

function draw() {
  //background color
  background("#495C7C");
  
  //random stars in background
  star.x = random(0,width);
  star.y = random(0,height);
  fill(col.r, col.g, col.b);
  noStroke();
  ellipse(star.x, star.y, 1, 1);
  
  //helmet
  fill("#B3B3B3");
  noStroke();
  ellipse(320, 240, helmetWidth, helmetHeight);
  
  //shield
  fill("#666666");
  noStroke();
  ellipse(320, 240, shieldWidth, shieldHeight);
  
  //shield outline
  stroke("#1A1A1A");
  strokeWeight(3);
  noFill();
  ellipse(310, 250,shieldOHeight, shieldOWidth);
  
  //antenna stick
  fill("#B3B3B3");
  noStroke();
  rect(297, 29, 7, 70);
  
  //antenna circle
  fill("#9E0421");
  noStroke();
  ellipse(300,25,25,25);
  
  //face
  fill("#EAD8A9");
  noStroke();
  ellipse(320, 250, faceWidth, faceHeight);
  
  //left eye
  fill("#333333");
  noStroke();
  ellipse(365,250,12,12);
  //right eye
  fill("#333333");
  noStroke();
  ellipse(275,250,12,12);
  
  //mouth
  fill("#B2542F");
  beginShape();
  curveVertex(292, 303);
  curveVertex(310, 311);
  curveVertex(326, 280);
  curveVertex(349, 314);
  curveVertex(356, 308);
  endShape();
  
}

function mousePressed() {
  helmetWidth = random (200, 400);
  helmetHeight = random (310, 400);
  shieldWidth = random (300, 290);
  shieldHeight = random (350, 240);
  shieldOHeight = random (200, 430);
  shieldOWidth = random (290, 300);
  faceWidth = random (150, 200);
  faceHeight = random (100, 200);
}

I wanted to do an astronaut as my project this week. I attempted to add a stars generator in the background (as seen in my code) – however it would not allow my random generator for the face to start fresh. It would over draw what was existing before. Although I had fixed that issue – the star generator had disappeared. This is what it looked like with the stars:

Before I begin any project I always start in adobe illustrator and this always helps visualize projects.

TSWARSTA- Section A- Project-02-Variable-Face

swarstad-face-sketch

// Treat Swarstad
// 15-104 A
//tswarsta@andrew.cmu.edu
//Project 02 -Variable -Face

var eyeSize = 100;
var faceWidth = 350;
var faceHeight = 350;
var mouthsize=100;
var cheek=50;

 
function setup() {
    createCanvas(640, 480);
}
 
function draw() {
	noStroke();
    background(0,255,255);
    fill(255,224,189);
    ellipse(width / 2, height / 2, faceWidth,  faceHeight);
    var eyeLX = width / 2 - faceWidth * 0.25;
    var eyeRX = width / 2 + faceWidth * 0.25;
    fill(250,128,114);
    var cheekY = height/2 + faceHeight/6; //so cheeks will not appear outside of the face
    ellipse(eyeLX, cheekY, cheek, cheek);
    ellipse(eyeRX, cheekY, cheek, cheek);
    fill(255,255,255);
    ellipse(eyeLX, height / 2, eyeSize, eyeSize);
    ellipse(eyeRX, height / 2, eyeSize, eyeSize);
    fill(0,0,255);
    ellipse(eyeLX, height / 2, eyeSize/2, eyeSize/2);
    ellipse(eyeRX, height / 2, eyeSize/2, eyeSize/2);
    fill(0,0,0);
    ellipse(eyeLX, height / 2, eyeSize/4, eyeSize/4);
    ellipse(eyeRX, height / 2, eyeSize/4, eyeSize/4);
    fill(255,0,0);
    var mouthY = height/2+faceHeight*0.25; // so mouth will appear within the face
    ellipse(width/2, mouthY, mouthsize/2, mouthsize/2);
    fill(0,0,0);
    ellipse(width/2, mouthY, mouthsize/3, mouthsize/3);
    fill(0,255,0);


}
 
function mousePressed() {
    faceWidth = random(50, 500);
    faceHeight = random(50, 500);
    eyeSize = random(10, 120);
    mouthsize = random(50,150);
    cheek = random(25,75);
    clear();
}