{"id":66739,"date":"2021-09-30T17:03:41","date_gmt":"2021-09-30T21:03:41","guid":{"rendered":"https:\/\/courses.ideate.cmu.edu\/15-104\/f2021\/?p=66739"},"modified":"2021-09-30T17:04:07","modified_gmt":"2021-09-30T21:04:07","slug":"project-04-string-art-17","status":"publish","type":"post","link":"https:\/\/courses.ideate.cmu.edu\/15-104\/f2021\/2021\/09\/30\/project-04-string-art-17\/","title":{"rendered":"Project 04: 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=\"400\" href=\"https:\/\/courses.ideate.cmu.edu\/15-104\/f2021\/wp-content\/uploads\/2021\/09\/sketch-206.js\">sketch<\/a><a href=\"https:\/\/courses.ideate.cmu.edu\/15-104\/f2021\/wp-content\/uploads\/2021\/09\/sketch-206.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=\"400\"><\/iframe><pre class=\"language-javascript\"><code class=\"p5_editor language-javascript\">var dx1;\nvar dy1;\nvar dx2;\nvar dy2;\n\nvar numLines = 40;\n\nfunction makeStringArt(x1, y1, x2, y2, x3, y3, x4, y4) { \/\/function to make string art from points of two lines\n    line(x1,y1,x2,y2);\n    line(x3,y3,x4,y4);\n    dx1 = (x2-x1)\/numLines; \/\/changes x value of first point\n    dy1 = (y2-y1)\/numLines; \/\/changes y value of first point\n    dx2 = (x4-x3)\/numLines; \/\/changes x value of second point\n    dy2 = (y4-y3)\/numLines; \/\/changes y value of second point\n\n    \/\/initial points\n    var firstx = x1; \n    var firsty = y1;\n    var secondx = x3;\n    var secondy = y3;\n\n    \/\/draws lines and adjusts points for next line\n    for (var i = 0; i &lt;= numLines; i += 1) {\n        line(firstx, firsty, secondx, secondy);\n        firstx += dx1;\n        firsty += dy1;\n        secondx += dx2;\n        secondy += dy2;\n    }\n}\n\nfunction setup() {\n    createCanvas(400, 400);\n    background(218, 190, 229); \/\/purple\n\n}\n\nfunction draw() {\n    stroke(255); \/\/white: corner shapes\n    makeStringArt(0,0,200,0,0,400,0,0);\n    makeStringArt(200,400,400,400,400,400,400,0);\n    \/\/quarters of the star shape\n    stroke(166, 155, 52); \/\/gold\n    makeStringArt(200,0,200,200,200,200,380,200);\n    stroke(0, 142, 219) \/\/blue\n    makeStringArt(200,400,200,200,200,200,380,200);\n    stroke(166, 155, 52); \/\/gold\n    makeStringArt(200,400,200,200,200,200,20,200);\n    stroke(0, 142, 219) \/\/blue\n    makeStringArt(200,0,200,200,200,200,20,200);\n\n    noLoop();\n}<\/code><\/pre><\/div><\/body><\/html>\n","protected":false},"excerpt":{"rendered":"<p>sketchDownload var dx1; var dy1; var dx2; var dy2; var numLines = 40; function makeStringArt(x1, y1, x2, y2, x3, y3, x4, y4) { \/\/function to make string art from points of two lines line(x1,y1,x2,y2); line(x3,y3,x4,y4); dx1 = (x2-x1)\/numLines; \/\/changes x value of first point dy1 = (y2-y1)\/numLines; \/\/changes y value of first point dx2 = &hellip; <a href=\"https:\/\/courses.ideate.cmu.edu\/15-104\/f2021\/2021\/09\/30\/project-04-string-art-17\/\" class=\"more-link\">Continue reading<span class=\"screen-reader-text\"> &#8220;Project 04: String Art&#8221;<\/span><\/a><\/p>\n","protected":false},"author":646,"featured_media":0,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":[],"categories":[102,57,1],"tags":[],"_links":{"self":[{"href":"https:\/\/courses.ideate.cmu.edu\/15-104\/f2021\/wp-json\/wp\/v2\/posts\/66739"}],"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\/646"}],"replies":[{"embeddable":true,"href":"https:\/\/courses.ideate.cmu.edu\/15-104\/f2021\/wp-json\/wp\/v2\/comments?post=66739"}],"version-history":[{"count":2,"href":"https:\/\/courses.ideate.cmu.edu\/15-104\/f2021\/wp-json\/wp\/v2\/posts\/66739\/revisions"}],"predecessor-version":[{"id":66743,"href":"https:\/\/courses.ideate.cmu.edu\/15-104\/f2021\/wp-json\/wp\/v2\/posts\/66739\/revisions\/66743"}],"wp:attachment":[{"href":"https:\/\/courses.ideate.cmu.edu\/15-104\/f2021\/wp-json\/wp\/v2\/media?parent=66739"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/courses.ideate.cmu.edu\/15-104\/f2021\/wp-json\/wp\/v2\/categories?post=66739"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/courses.ideate.cmu.edu\/15-104\/f2021\/wp-json\/wp\/v2\/tags?post=66739"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}