{"id":70796,"date":"2022-09-09T18:09:31","date_gmt":"2022-09-09T22:09:31","guid":{"rendered":"https:\/\/courses.ideate.cmu.edu\/15-104\/f2022\/?p=70796"},"modified":"2022-09-09T20:22:49","modified_gmt":"2022-09-10T00:22:49","slug":"project-02-variable-face","status":"publish","type":"post","link":"https:\/\/courses.ideate.cmu.edu\/15-104\/f2022\/2022\/09\/09\/project-02-variable-face\/","title":{"rendered":"Project-02-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>The hardest part of my project was attempting to debug the randomizer function.<\/p>\n\n\n\n<div><a class=\"p5_sketch_link\" href=\"https:\/\/courses.ideate.cmu.edu\/15-104\/f2022\/wp-content\/uploads\/2022\/09\/sketch-129.js\" data-width=\"300\" data-height=\"300\">sketch<\/a><iframe src=\"https:\/\/courses.ideate.cmu.edu\/15-104\/f2022\/wp-content\/plugins\/p5-embedder\/p5_iframe.html\" class=\"p5_exampleFrame\" width=\"300\" height=\"300\"><\/iframe><pre class=\"language-javascript\"><code class=\"p5_editor language-javascript\">\/\/ Zoe Lin (ID: youlin)\n\/\/ Section B\n\nvar eyeSize = 20;\nvar faceWidth = 100;\nvar faceHeight = 150;\nvar faceType;\nvar noseType = 3;\nvar mouthType = 1;\nvar earType;\nvar pupilSize;\nvar browType;\nvar stuffType;\nvar r;\nvar g;\nvar b;\n \nfunction setup() {\n    createCanvas(300, 300);\n    rectMode(CENTER);\n}\n \nfunction draw() {\n    background(r, g, b);\n    face();\n    nose();\n    eyes();\n    \/\/brows();\n    pupils();\n    mouth();\n    \/\/ears();\n    \/\/stuffs();\n  \n}\n \n \/\/face shape   \nfunction face() {\n    if (faceType &lt; 0.7) {\n      ellipse(width \/ 2, height \/ 2, faceWidth,  faceHeight);\n    } else {\n      rect(width \/ 2, height \/ 2, faceWidth, faceHeight\/1.05, 30)\n    }\n  \n}\n\n\/\/eye shape\nfunction eyes() {\n    var eyeLX = width \/ 2 - faceWidth * 0.25;\n    var eyeRX = width \/ 2 + faceWidth * 0.25;\n    ellipse(eyeLX, height \/ 2, eyeSize, eyeSize);\n    ellipse(eyeRX, height \/ 2, eyeSize, eyeSize);\n}\n  \n\/\/pupil size\nfunction pupils() {\n    push();\n    \/\/strokeWeight(9);\n    \/\/pupilSize = strokeWeight(1);\n    if (pupilSize &gt;= 1 & pupilSize <= 2) {\n      strokeWeight(4);\n    } else if (pupilSize &gt;= 2 & pupilSize <= 3) {\n      strokeWeight(5);\n    } else if (pupilSize &gt;= 3 & pupilSize <= 4) {\n      strokeWeight(6);\n    } else if (pupilSize &gt;= 4 & pupilSize <= 5) {\n      strokeWeight(7);\n    } else if (pupilSize &gt;= 5 & pupilSize <= 6) {\n      strokeWeight(8);\n    } else if (pupilSize &gt;= 6 & pupilSize <= 7) {\n      strokeWeight(9);\n    } else if (pupilSize &gt;= 7 & pupilSize <= 8) {\n      strokeWeight(10);\n    } else {\n      strokeWeight(11);\n    }\n    var eyeLX = width \/ 2 - faceWidth * 0.25;\n    var eyeRX = width \/ 2 + faceWidth * 0.25;\n    point(eyeLX, height \/ 2, eyeSize);\n    point(eyeRX, height \/ 2, eyeSize);\n    \/\/strokeWeight(random(1, 7));\n    pop();\n}\n\n\/\/nose shape\nfunction nose() {\n    var noseW = width \/ 2 - faceWidth * 0.04\n    var noseH = height \/ 2 + faceHeight * 0.07\n    \/\/noseType = random(1, 5);\n    if (noseType &gt;= 1 & noseType <= 2) {\n      rect(noseW+4, noseH, 7, 18, 10);\n    } else if (noseType &gt;= 2 & noseType <= 3) {\n      arc(noseW+4, noseH, 10, 10, PI + TWO_PI, TWO_PI);\n    } else if (noseType &gt;= 3 & noseType <= 4) {\n      push();\n      strokeWeight(4);\n      point(noseW+2, noseH+5);\n      point(noseW+10, noseH+5);\n      pop();\n      \/\/triangle(noseW-3, noseH, noseW, noseH-4, noseW+3, noseH)\n    } else if (noseType &gt;= 4 & noseType <= 5) {\n     ellipse(noseW+4, noseH+3, 10, 10);\n    } else if (noseType &gt;= 5 & noseType <= 6) {\n      triangle(noseW+2, noseH, noseW+5, noseH-4, noseW+8, noseH)\n    }\n}\n  \n\/\/mouth shape\nfunction mouth() {\n    var mouthW = width \/ 2\n    var mouthH = height \/ 2 + faceHeight * 0.1\n    if (mouthType >= 1 && mouthType <= 2) {\n      push();\n      fill(0);\n      ellipse(mouthW, mouthH+20, 10, 10);\n      pop();\n    } else if (mouthType &gt;= 2 & mouthType <= 3) {\n      push();\n      noFill();\n      arc(mouthW, mouthH+25, 25, 18, PI + TWO_PI, TWO_PI);\n      pop();\n    } else if (mouthType &gt;= 3 & mouthType <= 4) {\n      push();\n      noFill();\n      arc(mouthW, mouthH+2, 60, 40, PI*0.1, PI*0.9, OPEN);\n      pop();\n    } else if (mouthType &gt;= 4 & mouthType <= 5) {\n      line(mouthW-15, mouthH+20, mouthW+15, mouthH+20);\n    }\n}\n \nfunction mousePressed() {\n    faceWidth = random(100, 170);\n    faceHeight = random(100, 165);\n    eyeSize = random(10, 30);\n    pupilSize = random(1, 9);\n    faceType = random(0, 2);\n    noseType = random(1, 6);\n    mouthType = random(1, 5);\n    r = random(20, 230);\n    g = random(120, 200);\n    b = random(50, 255);\n    strokeWeight(random(1.5, 3));\n}<\/code><\/pre><\/div><\/body><\/html>\n","protected":false},"excerpt":{"rendered":"<p>The hardest part of my project was attempting to debug the randomizer function. sketch \/\/ Zoe Lin (ID: youlin) \/\/ Section B var eyeSize = 20; var faceWidth = 100; var faceHeight = 150; var faceType; var noseType = 3; var mouthType = 1; var earType; var pupilSize; var browType; var stuffType; var r; var &hellip; <a href=\"https:\/\/courses.ideate.cmu.edu\/15-104\/f2022\/2022\/09\/09\/project-02-variable-face\/\" class=\"more-link\">Continue reading<span class=\"screen-reader-text\"> &#8220;Project-02-Variable-Face&#8221;<\/span><\/a><\/p>\n","protected":false},"author":740,"featured_media":0,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":[],"categories":[97,56],"tags":[],"_links":{"self":[{"href":"https:\/\/courses.ideate.cmu.edu\/15-104\/f2022\/wp-json\/wp\/v2\/posts\/70796"}],"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\/740"}],"replies":[{"embeddable":true,"href":"https:\/\/courses.ideate.cmu.edu\/15-104\/f2022\/wp-json\/wp\/v2\/comments?post=70796"}],"version-history":[{"count":3,"href":"https:\/\/courses.ideate.cmu.edu\/15-104\/f2022\/wp-json\/wp\/v2\/posts\/70796\/revisions"}],"predecessor-version":[{"id":70813,"href":"https:\/\/courses.ideate.cmu.edu\/15-104\/f2022\/wp-json\/wp\/v2\/posts\/70796\/revisions\/70813"}],"wp:attachment":[{"href":"https:\/\/courses.ideate.cmu.edu\/15-104\/f2022\/wp-json\/wp\/v2\/media?parent=70796"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/courses.ideate.cmu.edu\/15-104\/f2022\/wp-json\/wp\/v2\/categories?post=70796"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/courses.ideate.cmu.edu\/15-104\/f2022\/wp-json\/wp\/v2\/tags?post=70796"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}