{"id":66101,"date":"2021-09-18T22:27:32","date_gmt":"2021-09-19T02:27:32","guid":{"rendered":"https:\/\/courses.ideate.cmu.edu\/15-104\/f2021\/?p=66101"},"modified":"2021-09-18T22:27:32","modified_gmt":"2021-09-19T02:27:32","slug":"project-03-dynamic-drawing-8","status":"publish","type":"post","link":"https:\/\/courses.ideate.cmu.edu\/15-104\/f2021\/2021\/09\/18\/project-03-dynamic-drawing-8\/","title":{"rendered":"Project 03: 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> <a class=\"p5_sketch_link\" data-width=\"600\" data-height=\"450\" href=\"https:\/\/courses.ideate.cmu.edu\/15-104\/f2021\/wp-content\/uploads\/2021\/09\/sketch-146.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=\"600\" height=\"450\"><\/iframe><pre class=\"language-javascript\"><code class=\"p5_editor language-javascript\">\/\/Julianna Bolivar\n\/\/jbolivar\n\/\/section d\nvar x = 305; \/\/center petal\nvar y = 225;\nvar y1 = 140; \/\/petals\nvar py1 = 0; \/\/petal velocities\nvar y2 = 180;\nvar py2 = 0;\nvar y3 = 180;\nvar py3 = 0;\nvar y4 = 270;\nvar py4 = 0;\nvar y5 = 270;\nvar py5 = 0;\n\nfunction setup() {\n    createCanvas(600, 450);\n    py1 = 0; \/\/petal velocitiess\n    py2 = 0;\n    py3 = 0;\n    py4 = 0;\n    py5 = 0;\n}\n\nfunction draw() {\n    if (mouseX &gt; width\/2){     \n        background(0, 51, 102); \/\/mouseX in right is midnight blue\n    }\n    else {\n        background(173, 216, 230); \/\/mouse X in left in sky blue\n    } \n    \n    push();\n    rotate(frameCount \/ 50.0);\n    star(100, 100, 80, 100, 20); \/\/sun \n    pop();\n    \n    fill(154, 205, 50);\n    noStroke();\n    rect(290, 250, 30, 400); \/\/stem\n    fill(255, 105, 180);\n    circle(305, y1, 100); \/\/top petal\n    circle(380, y2, 100); \/\/upper right petal\n    circle(230, y3, 100); \/\/upper left petal\n    circle(245, y4, 100); \/\/lower left petal\n    circle(370, y5, 100); \/\/lower right petal\n    y1 += py1; \n    y2 += py2; \n    y3 += py3; \n    y4 += py4; \n    y5 += py5; \n    fill(255, 215, 0);\n    circle(x, y, (100 + mouseY\/3)); \/\/center gets bigger with mouseY\n} \n\nfunction mousePressed() { \/\/petals fall on click\n    py1 = 10;\n    py2 = 9;\n    py3 = 5;\n    py4 = 10;\n    py5 = 6;\n}\n\nfunction star(x, y, radius1, radius2, npoints) { \/\/star spin\n  let angle = TWO_PI \/ npoints;\n  let halfAngle = angle \/ 2.0;\n  beginShape();\n  for (let a = 0; a &lt; TWO_PI; a += angle) {\n    let sx = x + cos(a) * radius2;\n    let sy = y + sin(a) * radius2;\n    vertex(sx, sy);\n    sx = x + cos(a + halfAngle) * radius1;\n    sy = y + sin(a + halfAngle) * radius1;\n    vertex(sx, sy);\n  }\n    endShape(CLOSE);\n}\n<\/code><\/pre><\/div>\n\n\n\n<p>This was so difficult. Because my idea was very simple at first it ended up looking all over the place as I added elements. Some things I never figured out, like how I wanted the petals to change as they fall.<\/p><\/body><\/html>\n","protected":false},"excerpt":{"rendered":"<p>sketch \/\/Julianna Bolivar \/\/jbolivar \/\/section d var x = 305; \/\/center petal var y = 225; var y1 = 140; \/\/petals var py1 = 0; \/\/petal velocities var y2 = 180; var py2 = 0; var y3 = 180; var py3 = 0; var y4 = 270; var py4 = 0; var y5 = 270; &hellip; <a href=\"https:\/\/courses.ideate.cmu.edu\/15-104\/f2021\/2021\/09\/18\/project-03-dynamic-drawing-8\/\" class=\"more-link\">Continue reading<span class=\"screen-reader-text\"> &#8220;Project 03: Dynamic Drawing&#8221;<\/span><\/a><\/p>\n","protected":false},"author":640,"featured_media":0,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":[],"categories":[100,58],"tags":[],"_links":{"self":[{"href":"https:\/\/courses.ideate.cmu.edu\/15-104\/f2021\/wp-json\/wp\/v2\/posts\/66101"}],"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\/640"}],"replies":[{"embeddable":true,"href":"https:\/\/courses.ideate.cmu.edu\/15-104\/f2021\/wp-json\/wp\/v2\/comments?post=66101"}],"version-history":[{"count":1,"href":"https:\/\/courses.ideate.cmu.edu\/15-104\/f2021\/wp-json\/wp\/v2\/posts\/66101\/revisions"}],"predecessor-version":[{"id":66106,"href":"https:\/\/courses.ideate.cmu.edu\/15-104\/f2021\/wp-json\/wp\/v2\/posts\/66101\/revisions\/66106"}],"wp:attachment":[{"href":"https:\/\/courses.ideate.cmu.edu\/15-104\/f2021\/wp-json\/wp\/v2\/media?parent=66101"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/courses.ideate.cmu.edu\/15-104\/f2021\/wp-json\/wp\/v2\/categories?post=66101"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/courses.ideate.cmu.edu\/15-104\/f2021\/wp-json\/wp\/v2\/tags?post=66101"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}