{"id":68014,"date":"2021-10-19T15:34:58","date_gmt":"2021-10-19T19:34:58","guid":{"rendered":"https:\/\/courses.ideate.cmu.edu\/15-104\/f2021\/?p=68014"},"modified":"2021-10-19T15:34:58","modified_gmt":"2021-10-19T19:34:58","slug":"project-07-curves-4","status":"publish","type":"post","link":"https:\/\/courses.ideate.cmu.edu\/15-104\/f2021\/2021\/10\/19\/project-07-curves-4\/","title":{"rendered":"Project 07: Curves"},"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><a class=\"p5_sketch_link\" data-width=\"480\" data-height=\"480\" href=\"https:\/\/courses.ideate.cmu.edu\/15-104\/f2021\/wp-content\/uploads\/2021\/10\/sketch-128.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=\"480\" height=\"480\"><\/iframe><pre class=\"language-javascript\"><code class=\"p5_editor language-javascript\">\/\/ John Henley; jhenley; 15-104 section D\n\nfunction setup() {\n    createCanvas(480, 480);\n    background(0);\n}\n\nfunction draw() { \/\/ draw loop for each spiral\n    background(0);\n    translate(width\/2, height\/2);\n    spiral1(); \/\/ calls spiral functions\n    spiral2();\n}\n\nfunction spiral1() { \/\/ horizontal spirals\n    beginShape();\n    noFill();\n    stroke(255);\n    for (var t = 0; t &lt;= 100; t += 20) { \/\/ for loop for inner rings\n        for (var i = 1; i &lt;= 100; i ++) { \/\/ loop for each spiral\n            var theta = map(i, 0, 100, 0, TWO_PI);\n            var a = map(mouseX, 0, width\/2, 0, 1); \/\/ maps mouseX onto 0 - 1 scale\n            var x = a * t * cos(theta)^20;\n            var y = a * t * sin(theta);\n            vertex(x, y);\n            endShape();\n        }\n    }\n}\n\nfunction spiral2() { \/\/ vertical spiral\n    beginShape();\n    noFill();\n    stroke(255);\n    for (var t = 0; t &lt;= 100; t += 20) { \/\/ for loop for inner rings\n        for (var i = 1; i &lt;= 100; i ++) { \/\/ loop for each sprial\n            var theta = map(i, 0, 100, 0, TWO_PI);\n            var a = map(mouseX, 0, width\/2, 0, 1); \/\/ maps mouseX onto 0 - 1 scale\n            var x = a * t * cos(theta);\n            var y = a * t * sin(theta)^20;\n            vertex(x, y);\n            endShape();\n        }\n    }\n}<\/code><\/pre><\/p>\n\n\n\n<p>I wanted to make my curves very sharp and dramatic rather than the traditional smooth spiral. I accomplished this by using the equation for a spiral (r*cos(theta)^x, parametrically) and adjusted the exponent value and values in the map function until I achieved the desire effect. Below are two separate states of the program: the first is when the mouse is far to the left of the canvas, and the second is when the mouse is far to the right.<\/p>\n\n\n\n<figure class=\"wp-block-image size-full\"><img loading=\"lazy\" width=\"714\" height=\"715\" src=\"https:\/\/courses.ideate.cmu.edu\/15-104\/f2021\/wp-content\/uploads\/2021\/10\/image-7.png\" alt=\"\" class=\"wp-image-68016\" srcset=\"https:\/\/courses.ideate.cmu.edu\/15-104\/f2021\/wp-content\/uploads\/2021\/10\/image-7.png 714w, https:\/\/courses.ideate.cmu.edu\/15-104\/f2021\/wp-content\/uploads\/2021\/10\/image-7-300x300.png 300w, https:\/\/courses.ideate.cmu.edu\/15-104\/f2021\/wp-content\/uploads\/2021\/10\/image-7-150x150.png 150w\" sizes=\"(max-width: 709px) 85vw, (max-width: 909px) 67vw, (max-width: 984px) 61vw, (max-width: 1362px) 45vw, 600px\"><\/figure><figure class=\"wp-block-image size-full\"><img loading=\"lazy\" width=\"715\" height=\"719\" src=\"https:\/\/courses.ideate.cmu.edu\/15-104\/f2021\/wp-content\/uploads\/2021\/10\/image-8.png\" alt=\"\" class=\"wp-image-68017\" srcset=\"https:\/\/courses.ideate.cmu.edu\/15-104\/f2021\/wp-content\/uploads\/2021\/10\/image-8.png 715w, https:\/\/courses.ideate.cmu.edu\/15-104\/f2021\/wp-content\/uploads\/2021\/10\/image-8-298x300.png 298w, https:\/\/courses.ideate.cmu.edu\/15-104\/f2021\/wp-content\/uploads\/2021\/10\/image-8-150x150.png 150w\" sizes=\"(max-width: 709px) 85vw, (max-width: 909px) 67vw, (max-width: 984px) 61vw, (max-width: 1362px) 45vw, 600px\"><\/figure><\/body><\/html>\n","protected":false},"excerpt":{"rendered":"<p>sketch \/\/ John Henley; jhenley; 15-104 section D function setup() { createCanvas(480, 480); background(0); } function draw() { \/\/ draw loop for each spiral background(0); translate(width\/2, height\/2); spiral1(); \/\/ calls spiral functions spiral2(); } function spiral1() { \/\/ horizontal spirals beginShape(); noFill(); stroke(255); for (var t = 0; t &lt;= 100; t += 20) { &hellip; <a href=\"https:\/\/courses.ideate.cmu.edu\/15-104\/f2021\/2021\/10\/19\/project-07-curves-4\/\" class=\"more-link\">Continue reading<span class=\"screen-reader-text\"> &#8220;Project 07: Curves&#8221;<\/span><\/a><\/p>\n","protected":false},"author":650,"featured_media":0,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":[],"categories":[108],"tags":[],"_links":{"self":[{"href":"https:\/\/courses.ideate.cmu.edu\/15-104\/f2021\/wp-json\/wp\/v2\/posts\/68014"}],"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\/650"}],"replies":[{"embeddable":true,"href":"https:\/\/courses.ideate.cmu.edu\/15-104\/f2021\/wp-json\/wp\/v2\/comments?post=68014"}],"version-history":[{"count":1,"href":"https:\/\/courses.ideate.cmu.edu\/15-104\/f2021\/wp-json\/wp\/v2\/posts\/68014\/revisions"}],"predecessor-version":[{"id":68018,"href":"https:\/\/courses.ideate.cmu.edu\/15-104\/f2021\/wp-json\/wp\/v2\/posts\/68014\/revisions\/68018"}],"wp:attachment":[{"href":"https:\/\/courses.ideate.cmu.edu\/15-104\/f2021\/wp-json\/wp\/v2\/media?parent=68014"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/courses.ideate.cmu.edu\/15-104\/f2021\/wp-json\/wp\/v2\/categories?post=68014"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/courses.ideate.cmu.edu\/15-104\/f2021\/wp-json\/wp\/v2\/tags?post=68014"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}