{"id":66001,"date":"2021-09-18T16:31:21","date_gmt":"2021-09-18T20:31:21","guid":{"rendered":"https:\/\/courses.ideate.cmu.edu\/15-104\/f2021\/?p=66001"},"modified":"2021-09-18T16:31:21","modified_gmt":"2021-09-18T20:31:21","slug":"dynamic-drawing-2","status":"publish","type":"post","link":"https:\/\/courses.ideate.cmu.edu\/15-104\/f2021\/2021\/09\/18\/dynamic-drawing-2\/","title":{"rendered":"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><div class=\"wp-block-file\"><a class=\"p5_sketch_link\" data-width=\"400\" data-height=\"400\" href=\"https:\/\/courses.ideate.cmu.edu\/15-104\/f2021\/wp-content\/uploads\/2021\/09\/sketch-133.js\">sketch<\/a><iframe src=\"https:\/\/courses.ideate.cmu.edu\/15-104\/f2021\/wp-content\/plugins\/p5-embedder\/p5_iframe.html\" class=\"p5_exampleFrame\" width=\"400\" height=\"400\"><\/iframe><pre class=\"language-javascript\"><code class=\"p5_editor language-javascript\">function setup() {\n    createCanvas(400, 400);\n}\n\nfunction draw() {\n    background(0);\n    fill(255, 255, 0);\n    var m = max(min(mouseX, 400), 0);\n    var size = m * 350.0 \/ 400.0;\n    ellipse(10 + m * 190.0 \/ 400.0, height\/4, size, size); \/\/yellow circle\n    fill(255, 0, 0);\n    ellipse(200 + m * 190.0 \/ 400.0, 3*height\/4, size, size); \/\/red circle\n    size = 350 - size;\n    fill(0, 0, 255);\n    ellipse(200 + m * 190.0 \/ 400.0, height\/4, size, size); \/\/blue circle\n    fill(0,255,0); \n    ellipse(10 + m * 190.0 \/ 400.0, 3*height\/4, size, size); \/\/green circle\n\n}<\/code><\/pre><\/div>\n\n\n\n<p>I really liked the live movements of the squares in the example, so I took my own spin-off of it using circles. The trickiest part was figuring out how to make it change size diagonally. <\/p><\/body><\/html>\n","protected":false},"excerpt":{"rendered":"<p>sketch function setup() { createCanvas(400, 400); } function draw() { background(0); fill(255, 255, 0); var m = max(min(mouseX, 400), 0); var size = m * 350.0 \/ 400.0; ellipse(10 + m * 190.0 \/ 400.0, height\/4, size, size); \/\/yellow circle fill(255, 0, 0); ellipse(200 + m * 190.0 \/ 400.0, 3*height\/4, size, size); \/\/red circle &hellip; <a href=\"https:\/\/courses.ideate.cmu.edu\/15-104\/f2021\/2021\/09\/18\/dynamic-drawing-2\/\" class=\"more-link\">Continue reading<span class=\"screen-reader-text\"> &#8220;Dynamic Drawing&#8221;<\/span><\/a><\/p>\n","protected":false},"author":679,"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\/f2021\/wp-json\/wp\/v2\/posts\/66001"}],"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\/679"}],"replies":[{"embeddable":true,"href":"https:\/\/courses.ideate.cmu.edu\/15-104\/f2021\/wp-json\/wp\/v2\/comments?post=66001"}],"version-history":[{"count":3,"href":"https:\/\/courses.ideate.cmu.edu\/15-104\/f2021\/wp-json\/wp\/v2\/posts\/66001\/revisions"}],"predecessor-version":[{"id":66010,"href":"https:\/\/courses.ideate.cmu.edu\/15-104\/f2021\/wp-json\/wp\/v2\/posts\/66001\/revisions\/66010"}],"wp:attachment":[{"href":"https:\/\/courses.ideate.cmu.edu\/15-104\/f2021\/wp-json\/wp\/v2\/media?parent=66001"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/courses.ideate.cmu.edu\/15-104\/f2021\/wp-json\/wp\/v2\/categories?post=66001"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/courses.ideate.cmu.edu\/15-104\/f2021\/wp-json\/wp\/v2\/tags?post=66001"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}