sntong-Project-02-Variable-Face

sketch
For this project, I wanted to create a “cheesy” looking slice of cheddar cheese. I was having fun and going along with the metaphor as I was coding for this assignment. As my second coding project I felt I had better understanding of the code basics and syntax and I hope I can move on to more complicated ideas and codes later on.

//Scarlet Tong
//sntong@andrew.cmu.edu
//Section A
//Project 02 - Variable Face

//Cheese Slice
var rectX = 320
var rectY = 240
var rectW = 180
var rectH = 130
var rectC = 10

//Eyes
var iStrokeWeight = 5
var eyeLX = 270
var eyeLY = 210

//Mouth
var mouthX = 280
var mouthW = 2

//Heart
var heartX = 224

//Colors
var black = 0
var faceG = 220
var faceB = 151
var heartC = 130
var backgR = 215
var backgG = 244

function setup() {
    createCanvas(640,480);
    background(215,backgG,255);

}

function draw() {
  background(backgR,backgG,255);

  //Cheese slice
  fill(255,faceG,faceB);
  noStroke();
  rectMode(CENTER);
  rect(rectX,rectY,rectW,rectH,rectC);
  //left eye
  stroke(black);
  strokeWeight(iStrokeWeight);
  strokeCap(SQUARE);
  line(eyeLX,eyeLY,eyeLX+25,eyeLY-10);
  //right eye
  line(eyeLX+50,eyeLY-5,eyeLX+75,eyeLY);
  //mouth
  ellipse(mouthX,mouthX-40,mouthW,mouthW*4);
  //heart
  fill(249,heartC,heartC);
  noStroke();
  ellipse(heartX,heartX-18,20,20);
  ellipse(heartX+15,heartX-24,20,20);
  triangle(heartX-4,heartX-9,heartX+25,heartX-28,heartX+26,heartX+1);

}

function mousePressed(){
  //Change in color for the background
  backgR = random(254,215);
  backgG = random(254,244);
  //Change in weight and height of the cheese slice
  rectX = random(300,340);
  rectY = random(220,160);
  rectW = random(120,200);
  rectH = random(120,170);
  rectC = random(0,25);

  // change in size od eyes
  iStrokeWeight = random(3,8);
  eyeLX = random(265,275);
  eyeLY = random(190,220);

  //Change in location of mouth
  mouthX = random(275,280);
  mouthW = random(1,4);

  //Change of location of heart on face
  heartX = random(210,230);

  //Different shades of color for the composition
  black = random(0,254);
  faceG = random(213,187);
  faceB = random(146,77);
  heartC = random(151,51);


}

Leave a Reply