{"id":66206,"date":"2021-09-19T14:21:08","date_gmt":"2021-09-19T18:21:08","guid":{"rendered":"https:\/\/courses.ideate.cmu.edu\/15-104\/f2021\/?p=66206"},"modified":"2021-09-19T14:21:08","modified_gmt":"2021-09-19T18:21:08","slug":"project-3-dynamic-drawing-13","status":"publish","type":"post","link":"https:\/\/courses.ideate.cmu.edu\/15-104\/f2021\/2021\/09\/19\/project-3-dynamic-drawing-13\/","title":{"rendered":"Project 3: Dynamic Drawing"},"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>For this project I wanted to mess around with 3D geometries. I used the mouse position to change the size, and color of various objects as well as the color and the position of a point light source. <\/p>\n\n\n\n<p><a class=\"p5_sketch_link\" data-width=\"450\" data-height=\"600\" href=\"https:\/\/courses.ideate.cmu.edu\/15-104\/f2021\/wp-content\/uploads\/2021\/09\/sketch-3-1.js\">sketch 3<\/a><iframe src=\"https:\/\/courses.ideate.cmu.edu\/15-104\/f2021\/wp-content\/plugins\/p5-embedder\/p5_iframe.html\" class=\"p5_exampleFrame\" width=\"450\" height=\"600\"><\/iframe><pre class=\"language-javascript\"><code class=\"p5_editor language-javascript\">\/\/Tim Nelson-Pyne\n\/\/Section C\n\nvar diameterA = 5;\nvar diameterB = 0;\n\nfunction setup() {\n    createCanvas(450, 600, WEBGL);\n}\n\nfunction draw() {\n    noStroke();\n\n    \/\/sets the background color and changes it based on mouse position\n    background((mouseY\/width)*255, 0, 255-(mouseX\/width)*255);\n\n    \/\/sets the material for all 3d objects and allows the color to be changed based on mouse position\n    specularMaterial(255-(mouseX\/width)*255, (mouseY\/width)*255, (mouseX\/width)*255); \n    ambientLight(255);\n    \/\/creates a point light and moves it and changes its color based on mouse position\n    pointLight((mouseY\/width)*255, 0, 255-(mouseX\/width)*255, mouseX, mouseY, mouseY);\n    shininess(0);\n\n\n\n    \/\/changes the size of the spheres based on mouseX position\n    diameterA = 100 * sin(PI *mouseX\/450);\n\n    \/\/changes the size of the boxes based on mouseX position\n    \/\/also changes the diameter of the torus\n    diameterB = 100 * cos(PI *mouseY\/600);\n\n\n\n    \n\n    \n\n\n\n    \n    \/\/draws top right sphere and box\n    push();\n    translate(width\/4, height\/4);\n    sphere(diameterA);\n    box(diameterB);\n    pop();\n\n\n    \/\/draws bottom right sphere and box\n    push();\n    translate(width\/4, -height\/4);\n    sphere(diameterA);\n    box(diameterB);\n    pop();\n\n    \/\/draws top left sphere and box\n    push();\n    translate(-width\/4, height\/4);\n    sphere(diameterA);\n    box(diameterB);\n    pop();\n\n    \/\/draws bottom left sphere and box\n    push();\n    translate(-width\/4, -height\/4);\n    sphere(diameterA);\n    box(diameterB);    \n    pop();\n\n    \/\/draws middle sphere and torus\n    sphere(diameterA);\n    specularMaterial(0,0,(mouseX\/width)*255);\n    torus(2*diameterB, mouseY\/4);\n\n\n    \n\n\n\n\n\n\n    \n    \n\n}\n\n\nfunction mousePressed() {\n    \n\n}<\/code><\/pre><\/p>\n\n\n\n<p><\/p><\/body><\/html>\n","protected":false},"excerpt":{"rendered":"<p>For this project I wanted to mess around with 3D geometries. I used the mouse position to change the size, and color of various objects as well as the color and the position of a point light source. sketch 3 \/\/Tim Nelson-Pyne \/\/Section C var diameterA = 5; var diameterB = 0; function setup() { &hellip; <a href=\"https:\/\/courses.ideate.cmu.edu\/15-104\/f2021\/2021\/09\/19\/project-3-dynamic-drawing-13\/\" class=\"more-link\">Continue reading<span class=\"screen-reader-text\"> &#8220;Project 3: Dynamic Drawing&#8221;<\/span><\/a><\/p>\n","protected":false},"author":662,"featured_media":0,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":[],"categories":[100,57],"tags":[],"_links":{"self":[{"href":"https:\/\/courses.ideate.cmu.edu\/15-104\/f2021\/wp-json\/wp\/v2\/posts\/66206"}],"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\/662"}],"replies":[{"embeddable":true,"href":"https:\/\/courses.ideate.cmu.edu\/15-104\/f2021\/wp-json\/wp\/v2\/comments?post=66206"}],"version-history":[{"count":1,"href":"https:\/\/courses.ideate.cmu.edu\/15-104\/f2021\/wp-json\/wp\/v2\/posts\/66206\/revisions"}],"predecessor-version":[{"id":66208,"href":"https:\/\/courses.ideate.cmu.edu\/15-104\/f2021\/wp-json\/wp\/v2\/posts\/66206\/revisions\/66208"}],"wp:attachment":[{"href":"https:\/\/courses.ideate.cmu.edu\/15-104\/f2021\/wp-json\/wp\/v2\/media?parent=66206"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/courses.ideate.cmu.edu\/15-104\/f2021\/wp-json\/wp\/v2\/categories?post=66206"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/courses.ideate.cmu.edu\/15-104\/f2021\/wp-json\/wp\/v2\/tags?post=66206"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}