{"id":74664,"date":"2022-10-16T18:38:50","date_gmt":"2022-10-16T22:38:50","guid":{"rendered":"https:\/\/courses.ideate.cmu.edu\/15-104\/f2022\/?p=74664"},"modified":"2022-10-16T18:39:17","modified_gmt":"2022-10-16T22:39:17","slug":"dynamic-snowflakes","status":"publish","type":"post","link":"https:\/\/courses.ideate.cmu.edu\/15-104\/f2022\/2022\/10\/16\/dynamic-snowflakes\/","title":{"rendered":"Dynamic Snowflakes"},"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 used the rose curves and epicycloid functions to create this composition. The rose curve (white) resembles a snow flake and as the mouse moves the it changes but still looks like a snow flake. When mouse is at zero,  the middle of the composition, 480 or off the canvas it creates a circle. The epicycloid changes in complexity and in color as the mouse moves.   <\/p><div><a class=\"p5_sketch_link\" href=\"https:\/\/courses.ideate.cmu.edu\/15-104\/f2022\/wp-content\/uploads\/2022\/10\/sketch-140.js\" data-width=\"480\" data-height=\"480\">sketch<\/a><iframe src=\"https:\/\/courses.ideate.cmu.edu\/15-104\/f2022\/wp-content\/plugins\/p5-embedder\/p5_iframe.html\" class=\"p5_exampleFrame\" width=\"480\" height=\"480\"><\/iframe><pre class=\"language-javascript\"><code class=\"p5_editor language-javascript\">\/\/Nakshatra Menon\n\/\/Section C\n\nvar nPoints = 240;\n\n\n\nfunction setup() {\n    createCanvas(480, 480);\n    background(246, 242, 240);\n    colorMode(HSB);\n}\n\n\n\nfunction draw() {\n    background(\"black\");\n    translate (width\/2, height\/2); \/\/ origin is middle of canvas \n    noFill();\n    epicycloid(0, 0);             \/\/ shape 1\n    roseCurve(0,0);               \/\/ shape 2 \n}\n\nfunction roseCurve(){  \/\/ draw rose curve from https:\/\/mathworld.wolfram.com\/RoseCurve.html\n    var g = constrain(mouseY\/32, 5, 15);      \/\/ g is based on mouse Y\n    var n = constrain(int(mouseX), 0, 480);   \/\/ n is based on mouse X\n    strokeWeight(.5);\n    stroke(\"white\");\n    beginShape();\n    for (var i = 0; i &lt; nPoints; i++) {\n        var t = map(i, 0, nPoints, 0, TWO_PI);\n        var radius = 10 * cos(n * t);    \/\/ function \n\n        \/\/ first set of values \n        var x = g*radius * cos(t);       \/\/ function \n        var y = g*radius * sin(t);       \/\/ function \n\n        \/\/ second set of values \n        var x1 = 2*g*radius * cos(t);    \/\/ function \n        var y1 = 2*g*radius * sin(t);    \/\/ function \n\n        vertex(x, y);                    \/\/ vertex for shape\n        vertex(x1, y1);                  \/\/ vertex 2 for shape \n    }\n    endShape(CLOSE);\n}  \n\nfunction epicycloid (){    \/\/ draw the epicycloid from https:\/\/mathworld.wolfram.com\/Epicycloid.html\n    var f = constrain(int(mouseY\/20), 2, 48);        \/\/ output of number based on mouse Y\n    strokeWeight(1);\n    stroke(332,mouseX\/5, 20);                        \/\/ color changes based on mouse X position \n    for (var a = 10; a &lt;240; a = a+10){              \/\/ how many epicycloids are drawn \n        var b = a\/f                                  \/\/ b is related to mouse Y\n        beginShape();\n        for (var i = 0; i &lt; nPoints; i++) {\n            var t = map(i, 0, nPoints, 0, TWO_PI);  \/\/ remaps \n\n            var x = (a+b)*cos(t) - b*cos(((a+b)\/b)*t); \/\/ function \n            var y = (a+b)*sin(t) - b*sin(((a+b)\/b)*t); \/\/ function \n\n            vertex(x, y);                              \/\/ vertex for points \n        }\n\n    endShape(CLOSE); \n    }  \n}\n\n\n\n\n\n\n\n\n\n<\/code><\/pre><\/div><\/body><\/html>\n","protected":false},"excerpt":{"rendered":"<p>For this project I used the rose curves and epicycloid functions to create this composition. The rose curve (white) resembles a snow flake and as the mouse moves the it changes but still looks like a snow flake. When mouse is at zero, the middle of the composition, 480 or off the canvas it creates &hellip; <a href=\"https:\/\/courses.ideate.cmu.edu\/15-104\/f2022\/2022\/10\/16\/dynamic-snowflakes\/\" class=\"more-link\">Continue reading<span class=\"screen-reader-text\"> &#8220;Dynamic Snowflakes&#8221;<\/span><\/a><\/p>\n","protected":false},"author":746,"featured_media":0,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":[],"categories":[108,57],"tags":[],"_links":{"self":[{"href":"https:\/\/courses.ideate.cmu.edu\/15-104\/f2022\/wp-json\/wp\/v2\/posts\/74664"}],"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\/746"}],"replies":[{"embeddable":true,"href":"https:\/\/courses.ideate.cmu.edu\/15-104\/f2022\/wp-json\/wp\/v2\/comments?post=74664"}],"version-history":[{"count":2,"href":"https:\/\/courses.ideate.cmu.edu\/15-104\/f2022\/wp-json\/wp\/v2\/posts\/74664\/revisions"}],"predecessor-version":[{"id":74666,"href":"https:\/\/courses.ideate.cmu.edu\/15-104\/f2022\/wp-json\/wp\/v2\/posts\/74664\/revisions\/74666"}],"wp:attachment":[{"href":"https:\/\/courses.ideate.cmu.edu\/15-104\/f2022\/wp-json\/wp\/v2\/media?parent=74664"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/courses.ideate.cmu.edu\/15-104\/f2022\/wp-json\/wp\/v2\/categories?post=74664"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/courses.ideate.cmu.edu\/15-104\/f2022\/wp-json\/wp\/v2\/tags?post=74664"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}