{"id":71808,"date":"2022-09-15T17:46:36","date_gmt":"2022-09-15T21:46:36","guid":{"rendered":"https:\/\/courses.ideate.cmu.edu\/15-104\/f2022\/?p=71808"},"modified":"2022-09-15T23:01:24","modified_gmt":"2022-09-16T03:01:24","slug":"project-02-variable-faces-face-variables-2","status":"publish","type":"post","link":"https:\/\/courses.ideate.cmu.edu\/15-104\/f2022\/2022\/09\/15\/project-02-variable-faces-face-variables-2\/","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><p>P2 Shirley<\/p>\n<div><a class=\"p5_sketch_link\" href=\"https:\/\/courses.ideate.cmu.edu\/15-104\/f2022\/wp-content\/uploads\/2022\/09\/sketch-262.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\">\/\/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><\/div><\/body><\/html>\n","protected":false},"excerpt":{"rendered":"<p>P2 Shirley sketch \/\/Xinyi Du \/\/15104 Section B var eyes = 20; var mouth = 20; var face = 100; var ears = 20; var r \/\/ red var g \/\/ green var b \/\/ blue var hairDeco = 20; \/\/hair decorations var hair = 30; \/\/hair var cloth = 200; function setup() { createCanvas(300, &hellip; <a href=\"https:\/\/courses.ideate.cmu.edu\/15-104\/f2022\/2022\/09\/15\/project-02-variable-faces-face-variables-2\/\" class=\"more-link\">Continue reading<span class=\"screen-reader-text\"> &#8220;Project-02: Variable Faces; Face Variables&#8221;<\/span><\/a><\/p>\n","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\/71808"}],"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=71808"}],"version-history":[{"count":5,"href":"https:\/\/courses.ideate.cmu.edu\/15-104\/f2022\/wp-json\/wp\/v2\/posts\/71808\/revisions"}],"predecessor-version":[{"id":72525,"href":"https:\/\/courses.ideate.cmu.edu\/15-104\/f2022\/wp-json\/wp\/v2\/posts\/71808\/revisions\/72525"}],"wp:attachment":[{"href":"https:\/\/courses.ideate.cmu.edu\/15-104\/f2022\/wp-json\/wp\/v2\/media?parent=71808"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/courses.ideate.cmu.edu\/15-104\/f2022\/wp-json\/wp\/v2\/categories?post=71808"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/courses.ideate.cmu.edu\/15-104\/f2022\/wp-json\/wp\/v2\/tags?post=71808"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}