{"id":72354,"date":"2022-09-18T22:23:02","date_gmt":"2022-09-19T02:23:02","guid":{"rendered":"https:\/\/courses.ideate.cmu.edu\/15-104\/f2022\/?p=72354"},"modified":"2022-09-18T22:27:09","modified_gmt":"2022-09-19T02:27:09","slug":"72354","status":"publish","type":"post","link":"https:\/\/courses.ideate.cmu.edu\/15-104\/f2022\/2022\/09\/18\/72354\/","title":{"rendered":"Dynamic Drawing &#8211; Project 3"},"content":{"rendered":"<!DOCTYPE html PUBLIC \"-\/\/W3C\/\/DTD HTML 4.0 Transitional\/\/EN\" \"http:\/\/www.w3.org\/TR\/REC-html40\/loose.dtd\">\n<html><body><div class=\"wp-block-file\"><a class=\"p5_sketch_link\" data-width=\"600\" data-height=\"400\" id=\"wp-block-file--media-0f8dc529-d2da-4cd9-9d87-e00fc3540e35\" href=\"https:\/\/courses.ideate.cmu.edu\/15-104\/f2022\/wp-content\/uploads\/2022\/09\/trippy_geometry.js\">trippy_geometry<\/a><iframe src=\"https:\/\/courses.ideate.cmu.edu\/15-104\/f2022\/wp-content\/plugins\/p5-embedder\/p5_iframe.html\" class=\"p5_exampleFrame\" width=\"600\" height=\"400\"><\/iframe><pre class=\"language-javascript\"><code class=\"p5_editor language-javascript\">\n\nfunction setup() {\n    createCanvas(600, 400);\n    background(255);\n    text(\"p5.js vers 0.9.0 test.\", 10, 15);\n}\n\nfunction draw() {\n    var w = width\n    var h = height\n    var mX = mouseX\n    var mY = mouseY\n    var diam= dist(w\/2, h\/2,mX,mY) \/\/diameter of center circle\n    var diam2= 2 * (dist(w\/2,h\/2,w\/2 + w\/4, h\/2)- diam\/2)\/\/ diameter of peripheral circles\n    background(255);\n    noFill();\n    strokeWeight(constrain(diam\/10,3,6)); \/\/stroke \n    stroke(diam,diam\/3,170)\n    circle(w\/2,h\/2,diam); \/\/this is the big circle in the middle\n    \n    push();\n    noFill();\n    strokeWeight(constrain(diam2\/10,5,15));\n    translate(w\/2,h\/2);\/\/ translates origin to canvas center\n    \n    var angle = atan((mY -h\/2) \/ (mX - w\/2)) \/\/this outputs the angle of the cursor to the center of the canvas\n    \n    if(mX &lt; w\/2){\n    var x = diam\/2 * cos(angle - PI) \/\/ x position of peripheral circle based on angle of cursor\n    var y = diam\/2 * sin(angle - PI) \/\/ y position of peripheral circle based on angle of cursor\n    } else {\n    var x = diam\/2 * cos(angle )\n    var y = diam\/2 * sin(angle )\n    }\n    for (var r=0; r&lt;=2 * PI;r+=PI\/4){ \/\/the circles rotate every 45 degrees\n    rotate(r);\n    circle(x ,y,diam2); \/\/ these are the peripheral circles\n}\n    pop();\n\n}\n<\/code><\/pre><\/div><\/body><\/html>\n","protected":false},"excerpt":{"rendered":"<p>trippy_geometry function setup() { createCanvas(600, 400); background(255); text(&#8220;p5.js vers 0.9.0 test.&#8221;, 10, 15); } function draw() { var w = width var h = height var mX = mouseX var mY = mouseY var diam= dist(w\/2, h\/2,mX,mY) \/\/diameter of center circle var diam2= 2 * (dist(w\/2,h\/2,w\/2 + w\/4, h\/2)- diam\/2)\/\/ diameter of peripheral circles background(255); &hellip; <a href=\"https:\/\/courses.ideate.cmu.edu\/15-104\/f2022\/2022\/09\/18\/72354\/\" class=\"more-link\">Continue reading<span class=\"screen-reader-text\"> &#8220;Dynamic Drawing &#8211; Project 3&#8221;<\/span><\/a><\/p>\n","protected":false},"author":767,"featured_media":0,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":[],"categories":[100,55],"tags":[],"_links":{"self":[{"href":"https:\/\/courses.ideate.cmu.edu\/15-104\/f2022\/wp-json\/wp\/v2\/posts\/72354"}],"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\/767"}],"replies":[{"embeddable":true,"href":"https:\/\/courses.ideate.cmu.edu\/15-104\/f2022\/wp-json\/wp\/v2\/comments?post=72354"}],"version-history":[{"count":4,"href":"https:\/\/courses.ideate.cmu.edu\/15-104\/f2022\/wp-json\/wp\/v2\/posts\/72354\/revisions"}],"predecessor-version":[{"id":72362,"href":"https:\/\/courses.ideate.cmu.edu\/15-104\/f2022\/wp-json\/wp\/v2\/posts\/72354\/revisions\/72362"}],"wp:attachment":[{"href":"https:\/\/courses.ideate.cmu.edu\/15-104\/f2022\/wp-json\/wp\/v2\/media?parent=72354"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/courses.ideate.cmu.edu\/15-104\/f2022\/wp-json\/wp\/v2\/categories?post=72354"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/courses.ideate.cmu.edu\/15-104\/f2022\/wp-json\/wp\/v2\/tags?post=72354"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}