{"id":71489,"date":"2022-09-11T00:03:56","date_gmt":"2022-09-11T04:03:56","guid":{"rendered":"https:\/\/courses.ideate.cmu.edu\/15-104\/f2022\/?p=71489"},"modified":"2022-09-15T23:03:34","modified_gmt":"2022-09-16T03:03:34","slug":"project-02-variable-faces-face-variables","status":"publish","type":"post","link":"https:\/\/courses.ideate.cmu.edu\/15-104\/f2022\/2022\/09\/11\/project-02-variable-faces-face-variables\/","title":{"rendered":"Project-02: Variable Faces; Face Variables"},"content":{"rendered":"<!DOCTYPE html PUBLIC \"-\/\/W3C\/\/DTD HTML 4.0 Transitional\/\/EN\" \"http:\/\/www.w3.org\/TR\/REC-html40\/loose.dtd\">\n<html><body><pre class=\"wp-block-code\"><code>\/\/Xinyi Du \n\/\/15104 Section B\n\nvar eyes = 20;\nvar mouth = 20;\nvar face = 100;\nvar ears = 20;\nvar r \/\/ red\nvar g \/\/ green\nvar b \/\/ blue\nvar hairDeco = 20; \/\/hair decorations\nvar hair = 30; \/\/hair\nvar cloth = 200;\n\nfunction setup() {\n    createCanvas(300, 300);\n\n}\n \nfunction draw() {\n    background(80);\n    noStroke();\n\n    \/\/ clothing\n    fill(255-r, 255-g, 255-b);\n    triangle(width \/ 2, height \/ 2, width\/2-cloth\/2, height\/2+cloth, width\/2+cloth\/2, height\/2+cloth);\n\n    fill(255, 229, 204);\n    ellipse(width \/ 2, height \/ 2, face, face); \/\/ face\n\n    fill(255, 229, 204);\n    ellipse(width \/ 2 - face \/ 2, height \/ 2, ears, ears); \/\/ left ear\n    fill(255, 229, 204);\n    ellipse(width \/ 2 + face \/ 2, height \/ 2, ears, ears); \/\/ right ear\n    fill(255, 102, 102);\n    ellipse(width\/2, height\/2+face\/4, mouth,); \/\/ mouth\n\n    var eyeL = width\/2 - face\/4; \/\/ left eye\n    var eyeR = width\/2 + face\/4; \/\/ right eye\n    fill(64, 64, 64);\n    ellipse(eyeL, height\/2, eyes, eyes+5);\n    ellipse(eyeR, height\/2, eyes, eyes+5);\n\n    \/\/hairstyle\n    fill(r, g, b);\n    ellipse(width\/2, height\/2-face\/2, hairDeco, hairDeco); \/\/ hair decorations 1\n    fill(r, g, b);\n    \/\/ hair 1\n    var x1 = width\/2-hair\/2;\n    var y1 = height\/2-face\/2-hairDeco-hair;\n    var x2 = width\/2+hair\/2;\n    var y2 = height\/2-face\/2-hairDeco-hair;\n    var x3 = width\/2;\n    var y3 = height\/2-face\/2-hairDeco\/2;\n    triangle(x1, y1, x2, y2, x3, y3);\n    fill(r-30, g-30, b-30);\n    ellipse(width\/2-face\/4, height\/2-face\/3, hairDeco, hairDeco); \/\/ hair decorations 2\n    ellipse(width\/2+face\/4, height\/2-face\/3, hairDeco, hairDeco); \/\/ hair decorations 3\n\n    \/\/ hair 2\n    var x1 = width\/2-face\/4;\n    var y1 = height\/2-face\/3-hairDeco\/2;\n    var x2 = width\/2-face\/4-hair\/2;\n    var y2 = height\/2-face\/3-hairDeco\/2-hair;\n    var x3 = width\/2-face\/4+hair\/2;\n    var y3 = height\/2-face\/3-hairDeco\/2-hair;\n    triangle(x1, y1, x2, y2, x3, y3);\n\n    \/\/ hair 3\n    var x1 = width\/2+face\/4;\n    var y1 = height\/2-face\/3-hairDeco\/2;\n    var x2 = width\/2+face\/4-hair\/2;\n    var y2 = height\/2-face\/3-hairDeco\/2-hair;\n    var x3 = width\/2+face\/4+hair\/2;\n    var y3 = height\/2-face\/3-hairDeco\/2-hair;\n    triangle(x1, y1, x2, y2, x3, y3);\n\n}\n \nfunction mousePressed() {\n    face = random(80, 150);\n    eyes = random(10, 20);\n    ears = random(12, 30);\n    mouth = random(10, 25);\n    hairDeco = random(10, 30);\n    hair = random(20, 50);\n    r = random(10, 250);\n    g = random(10, 250);\n    b = random(10, 250);\n    cloth = random(150, 300);\n    \/\/\n}\n<\/code><\/pre><\/body><\/html>\n","protected":false},"excerpt":{"rendered":"","protected":false},"author":716,"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\/71489"}],"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\/716"}],"replies":[{"embeddable":true,"href":"https:\/\/courses.ideate.cmu.edu\/15-104\/f2022\/wp-json\/wp\/v2\/comments?post=71489"}],"version-history":[{"count":1,"href":"https:\/\/courses.ideate.cmu.edu\/15-104\/f2022\/wp-json\/wp\/v2\/posts\/71489\/revisions"}],"predecessor-version":[{"id":71490,"href":"https:\/\/courses.ideate.cmu.edu\/15-104\/f2022\/wp-json\/wp\/v2\/posts\/71489\/revisions\/71490"}],"wp:attachment":[{"href":"https:\/\/courses.ideate.cmu.edu\/15-104\/f2022\/wp-json\/wp\/v2\/media?parent=71489"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/courses.ideate.cmu.edu\/15-104\/f2022\/wp-json\/wp\/v2\/categories?post=71489"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/courses.ideate.cmu.edu\/15-104\/f2022\/wp-json\/wp\/v2\/tags?post=71489"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}