{"id":66628,"date":"2021-09-26T23:23:11","date_gmt":"2021-09-27T03:23:11","guid":{"rendered":"https:\/\/courses.ideate.cmu.edu\/15-104\/f2021\/?p=66628"},"modified":"2021-09-26T23:23:11","modified_gmt":"2021-09-27T03:23:11","slug":"string-art","status":"publish","type":"post","link":"https:\/\/courses.ideate.cmu.edu\/15-104\/f2021\/2021\/09\/26\/string-art\/","title":{"rendered":"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><div class=\"wp-block-file\"><a class=\"p5_sketch_link\" data-width=\"400\" data-height=\"300\" href=\"https:\/\/courses.ideate.cmu.edu\/15-104\/f2021\/wp-content\/uploads\/2021\/09\/sketch-194.js\">sketch<\/a><a href=\"https:\/\/courses.ideate.cmu.edu\/15-104\/f2021\/wp-content\/uploads\/2021\/09\/sketch-194.js\" class=\"wp-block-file__button\" download>Download<\/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=\"300\"><\/iframe><pre class=\"language-javascript\"><code class=\"p5_editor language-javascript\">var dx1;\nvar dy1;\nvar dx2;\nvar dy2;\n\nfunction setup() {\n    createCanvas(400, 300);\n    background(200);\n}\n\nfunction draw() {\n    drawLines(0, 50, 400, 200, 150, 300, 100, 100, 50);\n    drawLines(100, 0, 300, 300, 150, 200, 350, 100, 50);\n    drawLines(0, 200, 300, 100, 300, 300, 400, 300, 50);\n    drawLines(350, 100, 300, 200, 150, 300, 350, 100, 50);\n    noLoop();\n}\n\nfunction drawLines(x1, y1, x2, y2, x3, y3, x4, y4, numLines) {\n  dx1 = (x3-x1)\/numLines;\n  dy1 = (y3-y1)\/numLines;\n  dx2 = (x4-x2)\/numLines;\n  dy2 = (y4-y2)\/numLines;\n  line(x1, y1, x3, y3);\n  line(x2, y2, x4, y4);\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<\/code><\/pre><\/div>\n\n\n\n<p>Although my art isn&rsquo;t super cool, I&rsquo;m glad that I was able to write a method to draw shapes. Now I can spam it as many times as I want and just put in the parameters for where the lines should start and end \ud83d\ude42<\/p><\/body><\/html>\n","protected":false},"excerpt":{"rendered":"<p>sketchDownload var dx1; var dy1; var dx2; var dy2; function setup() { createCanvas(400, 300); background(200); } function draw() { drawLines(0, 50, 400, 200, 150, 300, 100, 100, 50); drawLines(100, 0, 300, 300, 150, 200, 350, 100, 50); drawLines(0, 200, 300, 100, 300, 300, 400, 300, 50); drawLines(350, 100, 300, 200, 150, 300, 350, 100, 50); &hellip; <a href=\"https:\/\/courses.ideate.cmu.edu\/15-104\/f2021\/2021\/09\/26\/string-art\/\" class=\"more-link\">Continue reading<span class=\"screen-reader-text\"> &#8220;String Art&#8221;<\/span><\/a><\/p>\n","protected":false},"author":652,"featured_media":0,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":[],"categories":[102,56],"tags":[],"_links":{"self":[{"href":"https:\/\/courses.ideate.cmu.edu\/15-104\/f2021\/wp-json\/wp\/v2\/posts\/66628"}],"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\/652"}],"replies":[{"embeddable":true,"href":"https:\/\/courses.ideate.cmu.edu\/15-104\/f2021\/wp-json\/wp\/v2\/comments?post=66628"}],"version-history":[{"count":2,"href":"https:\/\/courses.ideate.cmu.edu\/15-104\/f2021\/wp-json\/wp\/v2\/posts\/66628\/revisions"}],"predecessor-version":[{"id":66634,"href":"https:\/\/courses.ideate.cmu.edu\/15-104\/f2021\/wp-json\/wp\/v2\/posts\/66628\/revisions\/66634"}],"wp:attachment":[{"href":"https:\/\/courses.ideate.cmu.edu\/15-104\/f2021\/wp-json\/wp\/v2\/media?parent=66628"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/courses.ideate.cmu.edu\/15-104\/f2021\/wp-json\/wp\/v2\/categories?post=66628"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/courses.ideate.cmu.edu\/15-104\/f2021\/wp-json\/wp\/v2\/tags?post=66628"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}