{"id":66373,"date":"2021-09-25T14:04:10","date_gmt":"2021-09-25T18:04:10","guid":{"rendered":"https:\/\/courses.ideate.cmu.edu\/15-104\/f2021\/?p=66373"},"modified":"2021-09-25T14:05:01","modified_gmt":"2021-09-25T18:05:01","slug":"project-04-string-art-2","status":"publish","type":"post","link":"https:\/\/courses.ideate.cmu.edu\/15-104\/f2021\/2021\/09\/25\/project-04-string-art-2\/","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=\"300\" href=\"https:\/\/courses.ideate.cmu.edu\/15-104\/f2021\/wp-content\/uploads\/2021\/09\/sketch-166.js\">string art<\/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\">\/\/ for the right up center and left down center string shapes\nvar dx1;\nvar dy1;\nvar dx2;\nvar dy2;\nvar dx3;\nvar dy3;\nvar dx4;\nvar dy4;\n\/\/for the left up corner and right down corner string shapes\nvar da1;\nvar da2;\nvar da3;\nvar da4;\nvar ds1;\nvar ds2;\nvar ds3;\nvar ds4;\n\nvar numLines=20;\nfunction setup() {\n    createCanvas(400,300);\n    background(224,255,255);\n    dy1 = 150 \/ numLines;\n    dx2 = 200 \/ numLines;\n    dy3 = -150 \/ numLines;\n    dx4 = -200 \/ numLines;\n    da1 = 200 \/ numLines;\n    ds2 = -150 \/ numLines;\n    ds3 = 150 \/ numLines;\n    da4 = -200 \/numLines;\n}\n\nfunction draw() {\n    var x1 = 200;\n    var y1 = 0;\n    var x2 = 200;\n    var y2 = 150;\n    var x3 = 200;\n    var y3 = 300;\n    var x4 = 200;\n    var y4 = 150;\n\n    var a1 = 0;\n    var s1 = 0;\n    var a2 = 0;\n    var s2 = 150;\n    var a3 = 400;\n    var s3 = 150;\n    var a4 = 400;\n    var s4 = 300; \n\n    \/\/right up string section, section 1\n    stroke(127,255,0);\n    for (var i = 0; i &lt;= numLines; i += 1 ) {\n        line(x1,y1,x2,y2);\n        y1 += dy1;\n        x2 += dx2;\n    }\n    \/\/left down string section, section 2\n    stroke(75,0,130);\n    for (var i = 0; i &lt;= numLines; i += 1) {\n        line(x3,y3,x4,y4);\n        y3 += dy3;\n        x4 += dx4;\n    }\n\n    \/\/right up corner\n    stroke(255,192,203);\n    for (var a = 0; a &lt;= numLines; a += 1) {\n        line(a1,s1,a2,s2);\n        a1 += da1;\n        s2 += ds2; \n    }\n    \/\/left down corner\n    stroke(255,99,71);\n    for (var a = 0; a &lt;= numLines; a += 1) {\n        line(a3,s3,a4,s4);\n        s3 += ds3;\n        a4 += da4;\n    }\n    noLoop();\n}\n\n<\/code><\/pre><\/div>\n\n\n\n<p>While writing this project, I first only used 2 sets of x and y to draw out 4 string shapes, which the computer did not conduct the action I expected it to do. Then, I added another 2 sets of a and s to draw the left up corner and right down corner string shape. Eventually, my code works.<\/p><\/body><\/html>\n","protected":false},"excerpt":{"rendered":"<p>string art \/\/ for the right up center and left down center string shapes var dx1; var dy1; var dx2; var dy2; var dx3; var dy3; var dx4; var dy4; \/\/for the left up corner and right down corner string shapes var da1; var da2; var da3; var da4; var ds1; var ds2; var ds3; &hellip; <a href=\"https:\/\/courses.ideate.cmu.edu\/15-104\/f2021\/2021\/09\/25\/project-04-string-art-2\/\" class=\"more-link\">Continue reading<span class=\"screen-reader-text\"> &#8220;Project-04: String Art&#8221;<\/span><\/a><\/p>\n","protected":false},"author":676,"featured_media":0,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":[],"categories":[102,57],"tags":[],"_links":{"self":[{"href":"https:\/\/courses.ideate.cmu.edu\/15-104\/f2021\/wp-json\/wp\/v2\/posts\/66373"}],"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\/676"}],"replies":[{"embeddable":true,"href":"https:\/\/courses.ideate.cmu.edu\/15-104\/f2021\/wp-json\/wp\/v2\/comments?post=66373"}],"version-history":[{"count":3,"href":"https:\/\/courses.ideate.cmu.edu\/15-104\/f2021\/wp-json\/wp\/v2\/posts\/66373\/revisions"}],"predecessor-version":[{"id":66377,"href":"https:\/\/courses.ideate.cmu.edu\/15-104\/f2021\/wp-json\/wp\/v2\/posts\/66373\/revisions\/66377"}],"wp:attachment":[{"href":"https:\/\/courses.ideate.cmu.edu\/15-104\/f2021\/wp-json\/wp\/v2\/media?parent=66373"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/courses.ideate.cmu.edu\/15-104\/f2021\/wp-json\/wp\/v2\/categories?post=66373"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/courses.ideate.cmu.edu\/15-104\/f2021\/wp-json\/wp\/v2\/tags?post=66373"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}