{"id":73196,"date":"2022-09-27T15:41:35","date_gmt":"2022-09-27T19:41:35","guid":{"rendered":"https:\/\/courses.ideate.cmu.edu\/15-104\/f2022\/?p=73196"},"modified":"2022-09-27T15:41:35","modified_gmt":"2022-09-27T19:41:35","slug":"project-04-string-art-19","status":"publish","type":"post","link":"https:\/\/courses.ideate.cmu.edu\/15-104\/f2022\/2022\/09\/27\/project-04-string-art-19\/","title":{"rendered":"Project 04 &#8211; String art"},"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>Randomly generated string vortex effect<\/p>\n\n\n\n<div><a class=\"p5_sketch_link\" href=\"https:\/\/courses.ideate.cmu.edu\/15-104\/f2022\/wp-content\/uploads\/2022\/09\/sketch-402.js\" data-width=\"400\" data-height=\"600\">sketch<\/a><iframe src=\"https:\/\/courses.ideate.cmu.edu\/15-104\/f2022\/wp-content\/plugins\/p5-embedder\/p5_iframe.html\" class=\"p5_exampleFrame\" width=\"400\" height=\"600\"><\/iframe><pre class=\"language-javascript\"><code class=\"p5_editor language-javascript\">\/\/Aarnav Patel\n\/\/aarnavp\n\/\/Section D\n\nvar numLines = 100;\nvar dx1;\nvar dy1;\nvar dx2;\nvar dy2;\n\n\nfunction setup() {\n    createCanvas(400, 300);\n    background(220);\n\n}\n\nfunction draw() {\n\tstrokeWeight(0.25)\t\/\/to better see string\n\n    for (var i = 0; i &lt; 10; i += 1) {\t\/\/the amount of vortex triangles drawn\n       \tlet x1 = random(0, width);\n    \tlet y1 = random(0, height);\n    \tlet x2 = width \/ 2;\n    \tlet y2 = height \/ 2;\n        \/\/centering all lines towards middle on end point &ndash;&nbsp;converging vortex\n        \n        let x3 = random(0, width);\n        let y3 = random(0, height);\n        let x4 = random(0, width);\n        let y4 = random(0, height);\n\n    \tline(x1, y1, x2, y2);\n    \t\/\/line(x3, y3, x4, y4);\n\n    \tdx1 = (x2 - x1) \/ numLines;\n    \tdy1 = (y2 - y1) \/ numLines;\n    \tdx2 = (x3 - x4) \/ numLines;\n    \tdy2 = (y3 - y4) \/ numLines;\n    \t\/\/creating evenly spaced lines for each \"line art pair\"\n\n    \tfor (var j = 0; j &lt; numLines; j += 1) {\n    \t    if (i == 5) {\t\t\/\/making the middle vortex triangle red\n    \t\t\tstroke(\"red\");\n    \t\t} else {\n    \t\t\tstroke(0)\n    \t\t}\n\n    \t\tline(x1, y1, x2, y2);\n    \t\tx1 += dx1;\n    \t\ty1 += dy1;\n    \t\tx2 += dx2;\n    \t\ty2 += dy2;\n\n    \t}\n\n    }\n    noLoop();\n\n\n}\n\n<\/code><\/pre><\/div><\/body><\/html>\n","protected":false},"excerpt":{"rendered":"<p>Randomly generated string vortex effect sketch \/\/Aarnav Patel \/\/aarnavp \/\/Section D var numLines = 100; var dx1; var dy1; var dx2; var dy2; function setup() { createCanvas(400, 300); background(220); } function draw() { strokeWeight(0.25) \/\/to better see string for (var i = 0; i &lt; 10; i += 1) { \/\/the amount of vortex triangles &hellip; <a href=\"https:\/\/courses.ideate.cmu.edu\/15-104\/f2022\/2022\/09\/27\/project-04-string-art-19\/\" class=\"more-link\">Continue reading<span class=\"screen-reader-text\"> &#8220;Project 04 &#8211; String art&#8221;<\/span><\/a><\/p>\n","protected":false},"author":750,"featured_media":0,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":[],"categories":[102,58],"tags":[],"_links":{"self":[{"href":"https:\/\/courses.ideate.cmu.edu\/15-104\/f2022\/wp-json\/wp\/v2\/posts\/73196"}],"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\/750"}],"replies":[{"embeddable":true,"href":"https:\/\/courses.ideate.cmu.edu\/15-104\/f2022\/wp-json\/wp\/v2\/comments?post=73196"}],"version-history":[{"count":1,"href":"https:\/\/courses.ideate.cmu.edu\/15-104\/f2022\/wp-json\/wp\/v2\/posts\/73196\/revisions"}],"predecessor-version":[{"id":73198,"href":"https:\/\/courses.ideate.cmu.edu\/15-104\/f2022\/wp-json\/wp\/v2\/posts\/73196\/revisions\/73198"}],"wp:attachment":[{"href":"https:\/\/courses.ideate.cmu.edu\/15-104\/f2022\/wp-json\/wp\/v2\/media?parent=73196"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/courses.ideate.cmu.edu\/15-104\/f2022\/wp-json\/wp\/v2\/categories?post=73196"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/courses.ideate.cmu.edu\/15-104\/f2022\/wp-json\/wp\/v2\/tags?post=73196"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}