{"id":66614,"date":"2021-09-26T22:32:07","date_gmt":"2021-09-27T02:32:07","guid":{"rendered":"https:\/\/courses.ideate.cmu.edu\/15-104\/f2021\/?p=66614"},"modified":"2021-09-26T22:33:39","modified_gmt":"2021-09-27T02:33:39","slug":"project-4","status":"publish","type":"post","link":"https:\/\/courses.ideate.cmu.edu\/15-104\/f2021\/2021\/09\/26\/project-4\/","title":{"rendered":"Project 4"},"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=\"400\" data-height=\"400\" href=\"https:\/\/courses.ideate.cmu.edu\/15-104\/f2021\/wp-content\/uploads\/2021\/09\/sketch-193.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\">\/\/ Michelle Dang\n\/\/Section D\n\/\/mtdang\nvar dx1;\nvar dy1;\nvar dx2;\nvar dy2;\n\nvar dx3;\nvar dy3;\nvar dx4;\nvar dy4;\n\n\nvar numLines = 40; \/\/number of lines\n\nfunction setup() {\n    createCanvas(400, 400);\n    background(0);\n\n    dx1 = -600\/numLines; \n    dy1 = 50\/numLines;\n    dx2 = (200)\/numLines; \/\/dx4 dx2 is negative\n    dy2 = (-200)\/numLines;\n\n    dx3 = 0; \n    dy3 = 200\/numLines;\n    dx4 = -300\/numLines;\n    dy4 = -200\/numLines;\n\n}\n\nfunction draw() {\n    background(0);\n\n\/\/white interactive shape\n    stroke(255);\n    var x1 = constrain(mouseX, 200, 200);\n    var y1 = 0;\n    var x2 = 0;\n    var y2 = mouseY\n    for (var i = 0; i &lt;= numLines; i += 1) {\n        line(x1, y1, x2, y2);\n        x1 += -dx1;\n        y1 += dy1;\n        x2 += -dx2;\n        y2 += dy2;\n    }\n    var x1 = constrain(mouseX, 200, 200);\n    var y1 = 0;\n    var x2 = height;\n    var y2 = mouseY;\n    for (var i = 0; i &lt;= numLines; i += 1) {\n        line(x1, y1, x2, y2);\n        x1 += dx1;\n        y1 += dy1;\n        x2 += dx2;\n        y2 += dy2;\n    }\n\n\/\/red shape 1\n    stroke(255,0,0);\n    var x1 = width\/2;\n    var y1 = 0;\n    var x2 = width\/2;\n    var y2 = height;\n    for (var i = 0; i &lt;= numLines; i += 1) {\n        line(x1, y1, x2, y2);\n        x1 += dx3;\n        y1 += dy3;\n        x2 += dx4;\n        y2 += dy4;\n    }\n\/\/red shape 2\n    var x1 = width\/2;\n    var y1 = 0;\n    var x2 = width\/2;\n    var y2 = height;\n    for (var i = 0; i &lt;= numLines; i += 1) {\n        line(x1, y1, x2, y2);\n        x1 += dx3;\n        y1 += dy3;\n        x2 += -dx4;\n        y2 += dy4;\n    }\n\n\/\/blue shape 1\n    stroke(0,0,255);\n    var x1 = 0;\n    var y1 = 0;\n    var x2 = height;\n    var y2 = height;\n    for (var i = 0; i &lt;= numLines; i += 1) {\n        line(x1, y1, x2, y2);\n        x1 += dx1;\n        y1 += dy1;\n        x2 += dx2;\n        y2 += dy2;\n    }\n\/\/ blue shape 2\n    var x1 = width;\n    var y1 = 0;\n    var x2 = 0;\n    var y2 = height;\n    for (var i = 0; i &lt;= numLines; i += 1) {\n        line(x1, y1, x2, y2);\n        x1 += -dx1;\n        y1 += dy1;\n        x2 += -dx2;\n        y2 += dy2;\n    }\n\n\n\n   }\n<\/code><\/pre><\/p>\n\n\n\n<p>I struggled a lot at first trying to understand the starting example code, but after playing around with the numbers it wasn&rsquo;t too bad. I changed some of the variables to be negative to create a symmetrical effect \ud83d\ude42<\/p><\/body><\/html>\n","protected":false},"excerpt":{"rendered":"<p>sketch \/\/ Michelle Dang \/\/Section D \/\/mtdang var dx1; var dy1; var dx2; var dy2; var dx3; var dy3; var dx4; var dy4; var numLines = 40; \/\/number of lines function setup() { createCanvas(400, 400); background(0); dx1 = -600\/numLines; dy1 = 50\/numLines; dx2 = (200)\/numLines; \/\/dx4 dx2 is negative dy2 = (-200)\/numLines; dx3 = 0; &hellip; <a href=\"https:\/\/courses.ideate.cmu.edu\/15-104\/f2021\/2021\/09\/26\/project-4\/\" class=\"more-link\">Continue reading<span class=\"screen-reader-text\"> &#8220;Project 4&#8221;<\/span><\/a><\/p>\n","protected":false},"author":647,"featured_media":0,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":[],"categories":[1],"tags":[],"_links":{"self":[{"href":"https:\/\/courses.ideate.cmu.edu\/15-104\/f2021\/wp-json\/wp\/v2\/posts\/66614"}],"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\/647"}],"replies":[{"embeddable":true,"href":"https:\/\/courses.ideate.cmu.edu\/15-104\/f2021\/wp-json\/wp\/v2\/comments?post=66614"}],"version-history":[{"count":3,"href":"https:\/\/courses.ideate.cmu.edu\/15-104\/f2021\/wp-json\/wp\/v2\/posts\/66614\/revisions"}],"predecessor-version":[{"id":66621,"href":"https:\/\/courses.ideate.cmu.edu\/15-104\/f2021\/wp-json\/wp\/v2\/posts\/66614\/revisions\/66621"}],"wp:attachment":[{"href":"https:\/\/courses.ideate.cmu.edu\/15-104\/f2021\/wp-json\/wp\/v2\/media?parent=66614"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/courses.ideate.cmu.edu\/15-104\/f2021\/wp-json\/wp\/v2\/categories?post=66614"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/courses.ideate.cmu.edu\/15-104\/f2021\/wp-json\/wp\/v2\/tags?post=66614"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}