{"id":65817,"date":"2021-09-13T11:41:28","date_gmt":"2021-09-13T15:41:28","guid":{"rendered":"https:\/\/courses.ideate.cmu.edu\/15-104\/f2021\/?p=65817"},"modified":"2021-09-13T11:46:44","modified_gmt":"2021-09-13T15:46:44","slug":"project-2-variable-face-2","status":"publish","type":"post","link":"https:\/\/courses.ideate.cmu.edu\/15-104\/f2021\/2021\/09\/13\/project-2-variable-face-2\/","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=\"300\" data-height=\"300\" href=\"https:\/\/courses.ideate.cmu.edu\/15-104\/f2021\/wp-content\/uploads\/2021\/09\/sketch-119.js\">Karan &ndash; Variable Face<\/a><iframe src=\"https:\/\/courses.ideate.cmu.edu\/15-104\/f2021\/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\">var faceWidth = 100\nvar faceLength = 100\n\/\/hat, bow and sun glass colours colours R, G, B\nvar hbtR = 200\nvar hbtG = 150\nvar hbtB = 155\n\n\/\/skin colour variables \nskinColour = 1\n\n\/\/sunglass shape and width\nvar sgWidth = 20\nvar sgHeight = 20\n\n\/\/ hat size variables\nvar hatWidth = 200\nvar hatHeight = 100\nvar topWidth = 150\n\n\/\/ mouth variables\nmouth = 1\n\n\n\nfunction setup() {\n    createCanvas(300, 300);\n    background(220);\n    text(\"p5.js vers 0.9.0 test.\", 10, 15);\n}\n\nfunction draw() {\n    background(220)\n    \/\/skin colour\n    if (skinColour==1){\n        fill(117,64,27)\n    } else if (skinColour==2){\n        fill(207,152,84)\n    } else if (skinColour==3){\n        fill(244,203,151)\n    }\n\n     \/\/face\n    noStroke()\n    ellipse(width\/2,height\/2, faceWidth, faceLength);\n\n    \/\/sunglasses\n    fill(hbtR, hbtG, hbtB);\n    ellipse(width\/2-1\/5*faceWidth, height\/2-1\/8*faceLength,sgWidth,sgHeight);\n    ellipse(width\/2+1\/5*faceWidth, height\/2-1\/8*faceLength,sgWidth,sgHeight);\n    stroke(hbtR, hbtG, hbtB)\n    line(width\/2-1\/5*faceWidth,height\/2-1\/8*faceLength,width\/2+1\/5*faceWidth,height\/2-1\/8*faceLength);\n\n    \/\/bow\n    triangle(width\/2,height\/2+1\/2*faceLength,width\/2-15,(height\/2+1\/2*faceLength)-5,width\/2-15,(height\/2+1\/2*faceLength)+5);\n    triangle(width\/2,height\/2+1\/2*faceLength,width\/2+15,(height\/2+1\/2*faceLength)-5,width\/2+15,(height\/2+1\/2*faceLength)+5);\n\n    \/\/nose\n    fill(0);\n    \n    triangle(width\/2,height\/2,width\/2+5,height\/2+10,width\/2-5,height\/2+10);\n\n    \/\/hat\n    fill(hbtR,hbtG,hbtB);\n    line(width\/2-60,height\/2-1\/3*faceLength,width\/2+60,height\/2-1\/3*faceLength);\n    quad(width\/2-30,height\/2-1\/3*faceLength,width\/2+30,height\/2-1\/3*faceLength,width\/2+23,height\/2-faceLength,width\/2-23,height\/2-faceLength)\n}\n\nfunction mousePressed() {\n    skinColour = int(random(1,4));\n    faceWidth = random (75,150);\n    faceLength = random(75,150);\n    hbtR = random(0,255);\n    hbtG = random(0,255);\n    hbtB = random(0,255);\n}\n<\/code><\/pre><\/p>\n\n\n\n<p>This is what I imagine my fashion sense in terms of colour coding would be: Same coloured hat, sunglasses and bow-tie. It was interesting to understand the relationship in between variables.<\/p><\/body><\/html>\n","protected":false},"excerpt":{"rendered":"<p>Karan &ndash; Variable Face var faceWidth = 100 var faceLength = 100 \/\/hat, bow and sun glass colours colours R, G, B var hbtR = 200 var hbtG = 150 var hbtB = 155 \/\/skin colour variables skinColour = 1 \/\/sunglass shape and width var sgWidth = 20 var sgHeight = 20 \/\/ hat size &hellip; <a href=\"https:\/\/courses.ideate.cmu.edu\/15-104\/f2021\/2021\/09\/13\/project-2-variable-face-2\/\" class=\"more-link\">Continue reading<span class=\"screen-reader-text\"> &#8220;Project 2: Variable Face&#8221;<\/span><\/a><\/p>\n","protected":false},"author":668,"featured_media":0,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":[],"categories":[97,58],"tags":[],"_links":{"self":[{"href":"https:\/\/courses.ideate.cmu.edu\/15-104\/f2021\/wp-json\/wp\/v2\/posts\/65817"}],"collection":[{"href":"https:\/\/courses.ideate.cmu.edu\/15-104\/f2021\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/courses.ideate.cmu.edu\/15-104\/f2021\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/courses.ideate.cmu.edu\/15-104\/f2021\/wp-json\/wp\/v2\/users\/668"}],"replies":[{"embeddable":true,"href":"https:\/\/courses.ideate.cmu.edu\/15-104\/f2021\/wp-json\/wp\/v2\/comments?post=65817"}],"version-history":[{"count":3,"href":"https:\/\/courses.ideate.cmu.edu\/15-104\/f2021\/wp-json\/wp\/v2\/posts\/65817\/revisions"}],"predecessor-version":[{"id":65823,"href":"https:\/\/courses.ideate.cmu.edu\/15-104\/f2021\/wp-json\/wp\/v2\/posts\/65817\/revisions\/65823"}],"wp:attachment":[{"href":"https:\/\/courses.ideate.cmu.edu\/15-104\/f2021\/wp-json\/wp\/v2\/media?parent=65817"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/courses.ideate.cmu.edu\/15-104\/f2021\/wp-json\/wp\/v2\/categories?post=65817"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/courses.ideate.cmu.edu\/15-104\/f2021\/wp-json\/wp\/v2\/tags?post=65817"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}