{"id":71336,"date":"2022-09-10T23:07:15","date_gmt":"2022-09-11T03:07:15","guid":{"rendered":"https:\/\/courses.ideate.cmu.edu\/15-104\/f2022\/?p=71336"},"modified":"2022-09-10T23:07:15","modified_gmt":"2022-09-11T03:07:15","slug":"project-2-variable-face-3","status":"publish","type":"post","link":"https:\/\/courses.ideate.cmu.edu\/15-104\/f2022\/2022\/09\/10\/project-2-variable-face-3\/","title":{"rendered":"Project 2: Variable Face"},"content":{"rendered":"<!DOCTYPE html PUBLIC \"-\/\/W3C\/\/DTD HTML 4.0 Transitional\/\/EN\" \"http:\/\/www.w3.org\/TR\/REC-html40\/loose.dtd\">\n<html><body><p><a class=\"p5_sketch_link\" data-width=\"480\" data-height=\"640\" href=\"https:\/\/courses.ideate.cmu.edu\/15-104\/f2022\/wp-content\/uploads\/2022\/09\/sketch-202.js\">sketch<\/a><iframe src=\"https:\/\/courses.ideate.cmu.edu\/15-104\/f2022\/wp-content\/plugins\/p5-embedder\/p5_iframe.html\" class=\"p5_exampleFrame\" width=\"480\" height=\"640\"><\/iframe><pre class=\"language-javascript\"><code class=\"p5_editor language-javascript\">\/\/Name: Hari Vardhan Sampath\n\/\/Section: E\n\nvar x = 80;\nvar y = 160;\nvar eyeSize = 50;\nvar faceWidth = 200;\nvar faceHeight = 300;\nvar backgroundColor = 180\nvar chinWidth = 15\nvar mouthHeight1 = 20\nvar mouthHeight2 = 20 \nvar noseHeight = 100\n\nfunction setup() {\n    createCanvas(480, 640);\n}\n\nfunction draw() {\n    background(backgroundColor);\n\n    \/\/ outline of face\n    fill(210,180,140);\n    beginShape();\n    curveVertex(x*2, y);\n    curveVertex(x*2, y);\n    curveVertex(x, y*2);\n    curveVertex(x*2 + chinWidth, y*3 + x\/2);\n    curveVertex(x*4 - chinWidth, y*3 + x\/2);\n    curveVertex(x*5, y*2);\n    curveVertex(x*4, y);\n    curveVertex(x*2, y);\n    curveVertex(x*2, y);\n    endShape();\n\n    \/\/ mouth\n    noFill();\n    beginShape();\n    vertex(x*2 + 30, y*3);\n    bezierVertex(x*2 + 60, y*3 + mouthHeight1, \n        x*4 - 60, y*3 + mouthHeight2, x*4 - 30, y*3);\n    endShape();\n\n    \/\/ eyes\n    fill(255,248,220);\n    ellipse(x*2 + 10, y*2, eyeSize, eyeSize+5);\n    ellipse(x*4 - 10, y*2, eyeSize, eyeSize+5);\n    fill(0,0,0);\n    ellipse(x*2 + 10, y*2, eyeSize\/2, eyeSize\/2);\n    ellipse(x*4 - 10, y*2, eyeSize\/2, eyeSize\/2);\n\n    \/\/ hair \n    fill(5,5,0);\n    beginShape();\n    curveVertex(x*2, y + x);\n    curveVertex(x*2, y + x);\n    curveVertex(x, y*2);\n    curveVertex(x, y*2 - x);\n    curveVertex(x*2, y - 15);\n    curveVertex(x*4, y - 15);\n    curveVertex(x*5, y*2 - 25);\n    curveVertex(x*2, y + x);\n    curveVertex(x*2, y + x)\n    endShape();\n\n    \/\/ nose\n    fill(210,180,140);\n    beginShape();\n    curveVertex(x*3 - 30, y*2 + noseHeight - 20);\n    curveVertex(x*3 - 30, y*2 + noseHeight - 20);\n    curveVertex(x*3 - 30, y*2 + noseHeight - 10);\n    curveVertex(x*3 - 15, y*2 + noseHeight - 15);\n    curveVertex(x*3, y*2 + noseHeight);\n    curveVertex(x*3 + 15, y*2 + noseHeight - 15);\n    curveVertex(x*3 + 30, y*2 + noseHeight - 10);\n    curveVertex(x*3 + 30, y*2 + noseHeight - 20);\n    curveVertex(x*3 + 30, y*2 + noseHeight - 20);\n    endShape();\n\n}\n\nfunction mousePressed() {\n    \/\/ when the user clicks, these variables are reassigned\n    \/\/ to random values within specified ranges. For example,\n    \/\/ 'backgroundColor' gets a random value between 160 and 200.\n    x = random(75, 95);\n    y = random(150, 170);\n    eyeSize = random(30, 70);\n    backgroundColor = random(160, 200);\n    chinWidth = random(0, 25);\n    mouthHeight1 = random(-30, 40);\n    noseHeight = randon(90, 110);\n}<\/code><\/pre><\/p>\n\n\n\n<figure class=\"wp-block-image size-large\"><img loading=\"lazy\" width=\"823\" height=\"1024\" src=\"https:\/\/courses.ideate.cmu.edu\/15-104\/f2022\/wp-content\/uploads\/2022\/09\/harivars-02-project-823x1024.jpg\" alt=\"\" class=\"wp-image-71391\" srcset=\"https:\/\/courses.ideate.cmu.edu\/15-104\/f2022\/wp-content\/uploads\/2022\/09\/harivars-02-project-823x1024.jpg 823w, https:\/\/courses.ideate.cmu.edu\/15-104\/f2022\/wp-content\/uploads\/2022\/09\/harivars-02-project-241x300.jpg 241w, https:\/\/courses.ideate.cmu.edu\/15-104\/f2022\/wp-content\/uploads\/2022\/09\/harivars-02-project-768x956.jpg 768w, https:\/\/courses.ideate.cmu.edu\/15-104\/f2022\/wp-content\/uploads\/2022\/09\/harivars-02-project-1234x1536.jpg 1234w, https:\/\/courses.ideate.cmu.edu\/15-104\/f2022\/wp-content\/uploads\/2022\/09\/harivars-02-project-1645x2048.jpg 1645w, https:\/\/courses.ideate.cmu.edu\/15-104\/f2022\/wp-content\/uploads\/2022\/09\/harivars-02-project-1200x1494.jpg 1200w\" sizes=\"(max-width: 709px) 85vw, (max-width: 909px) 67vw, (max-width: 984px) 61vw, (max-width: 1362px) 45vw, 600px\"><\/figure><\/body><\/html>\n","protected":false},"excerpt":{"rendered":"<p>sketch \/\/Name: Hari Vardhan Sampath \/\/Section: E var x = 80; var y = 160; var eyeSize = 50; var faceWidth = 200; var faceHeight = 300; var backgroundColor = 180 var chinWidth = 15 var mouthHeight1 = 20 var mouthHeight2 = 20 var noseHeight = 100 function setup() { createCanvas(480, 640); } function draw() &hellip; <a href=\"https:\/\/courses.ideate.cmu.edu\/15-104\/f2022\/2022\/09\/10\/project-2-variable-face-3\/\" class=\"more-link\">Continue reading<span class=\"screen-reader-text\"> &#8220;Project 2: Variable Face&#8221;<\/span><\/a><\/p>\n","protected":false},"author":756,"featured_media":0,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":[],"categories":[97,121],"tags":[],"_links":{"self":[{"href":"https:\/\/courses.ideate.cmu.edu\/15-104\/f2022\/wp-json\/wp\/v2\/posts\/71336"}],"collection":[{"href":"https:\/\/courses.ideate.cmu.edu\/15-104\/f2022\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/courses.ideate.cmu.edu\/15-104\/f2022\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/courses.ideate.cmu.edu\/15-104\/f2022\/wp-json\/wp\/v2\/users\/756"}],"replies":[{"embeddable":true,"href":"https:\/\/courses.ideate.cmu.edu\/15-104\/f2022\/wp-json\/wp\/v2\/comments?post=71336"}],"version-history":[{"count":4,"href":"https:\/\/courses.ideate.cmu.edu\/15-104\/f2022\/wp-json\/wp\/v2\/posts\/71336\/revisions"}],"predecessor-version":[{"id":71393,"href":"https:\/\/courses.ideate.cmu.edu\/15-104\/f2022\/wp-json\/wp\/v2\/posts\/71336\/revisions\/71393"}],"wp:attachment":[{"href":"https:\/\/courses.ideate.cmu.edu\/15-104\/f2022\/wp-json\/wp\/v2\/media?parent=71336"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/courses.ideate.cmu.edu\/15-104\/f2022\/wp-json\/wp\/v2\/categories?post=71336"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/courses.ideate.cmu.edu\/15-104\/f2022\/wp-json\/wp\/v2\/tags?post=71336"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}