{"id":70705,"date":"2022-09-09T12:52:05","date_gmt":"2022-09-09T16:52:05","guid":{"rendered":"https:\/\/courses.ideate.cmu.edu\/15-104\/f2022\/?p=70705"},"modified":"2022-09-09T12:52:05","modified_gmt":"2022-09-09T16:52:05","slug":"project-2-generative-faces","status":"publish","type":"post","link":"https:\/\/courses.ideate.cmu.edu\/15-104\/f2022\/2022\/09\/09\/project-2-generative-faces\/","title":{"rendered":"Project 2: Generative Faces"},"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>Some faces, generated!<\/p>\n<div><a class=\"p5_sketch_link\" href=\"https:\/\/courses.ideate.cmu.edu\/15-104\/f2022\/wp-content\/uploads\/2022\/09\/sketch-122.js\" data-width=\"640\" data-height=\"480\">sketch<\/a>\n\n\n\n<p><\/p><iframe src=\"https:\/\/courses.ideate.cmu.edu\/15-104\/f2022\/wp-content\/plugins\/p5-embedder\/p5_iframe.html\" class=\"p5_exampleFrame\" width=\"640\" height=\"480\"><\/iframe><pre class=\"language-javascript\"><code class=\"p5_editor language-javascript\">var eyeType = 3\nvar faceWidth = 200\nvar faceHeight = 275\nvar eyeSize = 60\nvar earSize = 60\nvar pupilSize = 40\nvar noseType = 1\nvar mouthType = 1\nvar blush = 1\nvar r = 89\nvar g = 74\nvar b = 58 \/\/color 1, 2, & 3 used to be able to randomize the color of hair\n\nfunction setup() {\n    createCanvas(640, 480);\n}\n \nfunction draw() {\n    background(252, 215, 91);\n    strokeWeight(0);\n\n    fill(r, g, b); \/\/random hair color\n    ellipse(width\/2, (height\/2)-((faceHeight-faceWidth)\/2), faceWidth+20, faceWidth+20); \/\/hair\n    rect((width\/2)-(faceWidth\/2), height\/2, faceWidth, faceHeight*(2\/3)); \/\/hair\n\n    fill(194, 160, 97); \/\/face\/head\n    ellipse(width\/2, height\/2, faceWidth, faceHeight); \/\/chin\n    ellipse(width\/2, (height\/2)-((faceHeight-faceWidth)\/2), faceWidth, faceWidth); \/\/to round out the top of the head better, less oval-y\n    ellipse((width\/2)-(faceWidth\/2), height\/2, earSize*(3\/4), earSize); \/\/left ear, size randomly generated\n    ellipse((width\/2)+(faceWidth\/2), height\/2, earSize*(3\/4), earSize); \/\/right ear, size ranomly generated\n\n    fill(r, g, b); \/\/random hair color for eyebrow\n    ellipse((width\/2)+(faceWidth\/4), height\/2-50, 40, 20);\n    ellipse((width\/2)-(faceWidth\/4), height\/2-50, 40, 20);\n\n    if(blush &lt;= 1) { \/\/section to create blush possibility\n    \tfill(176, 121, 76, 255)\n    } else {\n    \tfill(176, 121, 76, 0)\n    }\n    ellipse((width\/2)-(faceWidth\/4), (height\/2)+40, 40, 20);\n    ellipse((width\/2)+(faceWidth\/4), (height\/2)+40, 40, 20);\n\n    if(mouthType &lt;= 1) { \/\/section to create mouth type 1 (open)\n        fill(77, 41, 34, 255)\n    } else {\n    \tfill(77, 41, 34, 0)\n    }\n    ellipse(width\/2, (height\/2)+(faceHeight\/3), 60, 30);\n    if(mouthType &lt;= 1) {\n        fill(252, 251, 247, 255)\n    } else {\n    \tfill(252, 251, 247, 0)\n    }   \n    ellipse(width\/2, (height\/2)+(faceHeight\/3)-10, 40, 10);\n\n    if(mouthType &gt; 1 & mouthType < 2) { \/\/section to create mouth type 2 (sad mouth)\n    \tfill(77, 41, 34, 255)\n    } else {\n    \tfill(77, 41, 34, 0)\n    }\n    ellipse((width\/2), (height\/2)+(faceHeight\/3)+7, 60, 40); \/\/skin to carve out shape\n     if(mouthType &gt; 1 & mouthType < 2) { \n    \tfill(194, 160, 97, 255)\n    } else {\n    \tfill(194, 160, 97, 0)\n    }\n    ellipse(width\/2, (height\/2)+(faceHeight\/3), 60, 40);\n\n    if(mouthType &gt;= 2) { \/\/section to create mouth type 3 (happy mouth)\n    \tfill(77, 41, 34, 255)\n    } else {\n    \tfill(77, 41, 34, 0)\n    }\n    ellipse((width\/2), (height\/2)+(faceHeight\/3)-20, 60, 40); \/\/skin to carve out shape\n     if(mouthType &gt;= 2) { \n    \tfill(194, 160, 97, 255)\n    } else {\n    \tfill(194, 160, 97, 0)\n    }\n    ellipse(width\/2, (height\/2)+(faceHeight\/3)-27, 60, 40);\n\n    if(eyeType &lt;= 1) { \/\/section to create eye type 1 (open regular)\n        fill(242, 246, 247, 255)\n    } else {\n    \tfill(242, 246, 247, 0)\n    }\n    ellipse((width\/2)-(faceWidth\/4), height\/2, eyeSize, eyeSize);\n    ellipse((width\/2)+(faceWidth\/4), height\/2, eyeSize, eyeSize);\n    if(eyeType &lt;= 1) {\n        fill(0, 0, 0, 255)\n    } else {\n    \tfill(0, 0, 0, 0)\n    }   \n    ellipse((width\/2)-(faceWidth\/4)+1, height\/2, pupilSize, pupilSize);\n    ellipse((width\/2)+(faceWidth\/4)-1, height\/2, pupilSize, pupilSize);\n\n    if(eyeType &gt; 1 & eyeType < 2) { \/\/section to create eye type 2 (happy eye)\n    \tfill(77, 41, 34, 255)\n    } else {\n    \tfill(252, 251, 247, 0)\n    }\n    ellipse((width\/2)-(faceWidth\/4), height\/2, 60, 40);\n    ellipse((width\/2)+(faceWidth\/4), height\/2, 60, 40);\n     if(eyeType &gt; 1 & eyeType < 2) { \n    \tfill(194, 160, 97, 255)\n    } else {\n    \tfill(194, 160, 97, 0)\n    }\n    ellipse((width\/2)-(faceWidth\/4), (height\/2)+7, 60, 40);\n    ellipse((width\/2)+(faceWidth\/4), (height\/2)+7, 60, 40);\n\n    if(eyeType &gt;= 2) { \/\/section to create eye type 3 (sad eye)\n    \tfill(77, 41, 34, 255)\n    } else {\n    \tfill(77, 41, 34, 0)\n    }\n    ellipse((width\/2)-(faceWidth\/4), height\/2, 60, 40);\n    ellipse((width\/2)+(faceWidth\/4), height\/2, 60, 40);\n    if(eyeType &gt;= 2) { \n    \tfill(194, 160, 97, 255)\n    } else {\n    \tfill(194, 160, 97, 0)\n    }\n    ellipse((width\/2)-(faceWidth\/4), (height\/2)-7, 60, 40);\n    ellipse((width\/2)+(faceWidth\/4), (height\/2)-7, 60, 40);\n\n    if(noseType &lt;= 1) { \/\/section to create round nose type\n    \tfill(176, 121, 76, 255)\n    } else {\n    \tfill(176, 121, 76, 0)\n    }\n    ellipse(width\/2, (height\/2)+20, 20, 60);\n\n    if(noseType &gt; 1) { \/\/section to create triangle nose type\n    \tfill(176, 121, 76, 255)\n    } else {\n    \tfill(176, 121, 76, 0)\n    }\n    triangle(width\/2, (height\/2), (width\/2)-10, (height\/2)+50, (width\/2)+10, (height\/2)+50);\n\n}\n \nfunction mousePressed() {\n    r = random(0, 255);\n    g = random(0, 255);\n    b = random(0, 255);\n    eyeType = random(0, 3); \/\/eye type will be randomized, 1-3, and said # will correlate to an if else tree w eye options\n    faceWidth = random(150, 225);\n    faceHeight = random(226, 300);\n    earSize = random(60, 80);\n    pupilSize = random(30, 40);\n    eyeSize = random(50, 70);\n    noseType = random(0, 2); \/\/nose type randomized based on two types\n    mouthType = random(0,3);\n    blush = random(0, 2); \/\/whether or not blushing\n}<\/code><\/pre><\/div><\/body><\/html>\n","protected":false},"excerpt":{"rendered":"<p>Some faces, generated! sketch var eyeType = 3 var faceWidth = 200 var faceHeight = 275 var eyeSize = 60 var earSize = 60 var pupilSize = 40 var noseType = 1 var mouthType = 1 var blush = 1 var r = 89 var g = 74 var b = 58 \/\/color 1, 2, &hellip; <a href=\"https:\/\/courses.ideate.cmu.edu\/15-104\/f2022\/2022\/09\/09\/project-2-generative-faces\/\" class=\"more-link\">Continue reading<span class=\"screen-reader-text\"> &#8220;Project 2: Generative Faces&#8221;<\/span><\/a><\/p>\n","protected":false},"author":766,"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\/70705"}],"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\/766"}],"replies":[{"embeddable":true,"href":"https:\/\/courses.ideate.cmu.edu\/15-104\/f2022\/wp-json\/wp\/v2\/comments?post=70705"}],"version-history":[{"count":2,"href":"https:\/\/courses.ideate.cmu.edu\/15-104\/f2022\/wp-json\/wp\/v2\/posts\/70705\/revisions"}],"predecessor-version":[{"id":70707,"href":"https:\/\/courses.ideate.cmu.edu\/15-104\/f2022\/wp-json\/wp\/v2\/posts\/70705\/revisions\/70707"}],"wp:attachment":[{"href":"https:\/\/courses.ideate.cmu.edu\/15-104\/f2022\/wp-json\/wp\/v2\/media?parent=70705"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/courses.ideate.cmu.edu\/15-104\/f2022\/wp-json\/wp\/v2\/categories?post=70705"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/courses.ideate.cmu.edu\/15-104\/f2022\/wp-json\/wp\/v2\/tags?post=70705"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}