{"id":72679,"date":"2022-09-24T13:37:20","date_gmt":"2022-09-24T17:37:20","guid":{"rendered":"https:\/\/courses.ideate.cmu.edu\/15-104\/f2022\/?p=72679"},"modified":"2022-09-24T13:37:20","modified_gmt":"2022-09-24T17:37:20","slug":"project-04-string-art-3","status":"publish","type":"post","link":"https:\/\/courses.ideate.cmu.edu\/15-104\/f2022\/2022\/09\/24\/project-04-string-art-3\/","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 id=\"wp-block-file--media-1b0f17fb-f22d-4ab9-98e9-5fbff99b13f4\" href=\"https:\/\/courses.ideate.cmu.edu\/15-104\/f2022\/wp-content\/uploads\/2022\/09\/sketch-337.js\">sketch<br><\/a><\/div>\n\n\n<div><a class=\"p5_sketch_link\" href=\"https:\/\/courses.ideate.cmu.edu\/15-104\/f2022\/wp-content\/uploads\/2022\/09\/sketch-337.js\" data-width=\"400\" data-height=\"300\">sketch<\/a>\n<p>&nbsp;<\/p>\n<p>in this project, I tried to use different colors and combinations of strings to compose a gradually changing geometry that goes from edge to the center.<\/p>\n<p>&nbsp;<\/p>\n<iframe src=\"https:\/\/courses.ideate.cmu.edu\/15-104\/f2022\/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;\n    var dy1;\n    var dx2;\n    var dy2;\n    var dx3;\n    var dy3;\n    var dx4;\n    var dy4;\n    var numLines = 50;\n    var c;\n\n\nfunction setup() {\n    createCanvas(400, 300);\n    background(0);\n    \n    \/\/base set of lines #1\n    \/*line(width\/4,0,0,height\/3);\n    line(0,height\/3,width\/2,height\/3);*\/\n\n    \/*line(1,300,2,1);\n    line(2,1,200,150);\n    line(200,150,398,299);\n    line(398,299,399,1);*\/\n\n    dx1=(2-1)\/numLines;\n    dy1=(1-300)\/numLines;\n    dx2=(200-2)\/numLines;\n    dy2=(150-1)\/numLines;\n    dx3=(398-200)\/numLines;\n    dy3=(299-150)\/numLines;\n    dx4=(399-398)\/numLines;\n    dy4=(1-299)\/numLines;\n\n    \/\/define the change of x, y variables\n    \/*dx1 = (0-width\/4)\/numLines;\n    dy1 = (height\/3-0)\/numLines;\n    dx2 = (width\/2-0)\/numLines;\n    dy2 = (height\/3-height\/3)\/numLines;*\/\n}\n    \n    \/\/draw first set of strings\nfunction draw() {\n\n        var x1 = 1;\n        var y1 = 300;\n        var x2 = 2;\n        var y2 = 1;\n        var x3 = 200;\n        var y3 = 150;\n        var x4 = 398;\n        var y4 = 299;\n\n        stroke(0,255,0);\n        \/\/in a for loop, when a increases, x1+= a*dx1)\n        \/\/for(var e=0;e&lt;=5;e+=1){\n            \/\/dx2=e*dx2;\n            \/*x1 += e*dx1;\n            y1 += e*dy1;\n            x2 += e*dx2;\n            y2 += e*dy2;\n            x3 += e*dx3;\n            y3 += e*dy3;\n            x4 += e*dx4;\n            y4 += e*dy4;*\/\n        \n            for (var i = 0; i &lt;= numLines; i += 1) {\n                line(x1, y1, x2, y2);\n                line(x3,y3,x4,y4);\n                x1 += dx1;\n                y1 += dy1;\n                x2 += dx2;\n                y2 += dy2;\n                x3 += dx3;\n                y3 += dy3;\n                x4 += dx4;\n                y4 += dy4;\n}\n                \n                string02();\n                string03();\n                string04();\n                noLoop();\n}\n        \/\/second set of strings\n    function string02(){\n\n\n        var x5 = 2;\n        var y5 = 1;\n        var x6 = 399;\n        var y6 = 50;\n        var x7 = 1;\n        var y7 = 250;\n        var x8 = 399;\n        var y8 = 300;\n\n        stroke(255);\n       \n            for (var e =0; e &lt;= 20; e += 1) {\n                line(x5, y5, x6, y6);\n                line(x7,y7,x8,y8);\n                x5 += dx1;\n                y5 -= dy1;\n                x6 += dx2;\n                y6 -= dy2;\n                x7 -= dx3;\n                y7 += dy3;\n                x8 -= dx4;\n                y8 += dy4;\n    }\n    }\n\n    \/\/third set of strings\n    function string03(){\n\n        var x9 = 2;\n        var y9 = 1;\n        var x10 = 399;\n        var y10 = 100;\n        var x11 = 1;\n        var y11 = 200;\n        var x12 = 399;\n        var y12 = 300;\n\n        stroke(195,255,195);\n       \n            for (var l =0; l &lt;= 25; l += 1) {\n                line(x9, y9, x10, y10);\n                line(x11,y11,x12,y12);\n                x9 += dx1;\n                y9 -= dy1;\n                x10 += dx2;\n                y10 -= dy2;\n                x11 -= dx3;\n                y11 += dy3;\n                x12 -= dx4;\n                y12 += dy4;\n    }  \n    }\n\n    \/\/fourth set of strings\n    function string04(){\n\n        var a = 2;\n        var b = 1;\n        var c = 399;\n        var d = 200;\n        var e = 1;\n        var f = 100;\n        var g = 399;\n        var h = 300;\n\n        stroke(90,255,90);\n       \n            for (var l =0; l &lt;= 28; l += 1) {\n                line(a, b, c, d);\n                line(e,f,g,h);\n                a += dx1;\n                b -= dy1;\n                c += dx2;\n                d -= dy2;\n                e -= dx3;\n                f += dy3;\n                g -= dx4;\n                h += dy4;\n    }  \n    }\n    \/\/}\n       \/\/noLoop();\n\n\n\n    \/\/devide the lines\n    \/\/connect different parts on each line\n    \/\/define a function for different lines and variable\n\n<\/code><\/pre><\/div><\/body><\/html>\n","protected":false},"excerpt":{"rendered":"<p>sketch &nbsp; in this project, I tried to use different colors and combinations of strings to compose a gradually changing geometry that goes from edge to the center. &nbsp; var dx1; var dy1; var dx2; var dy2; var dx3; var dy3; var dx4; var dy4; var numLines = 50; var c; function setup() { createCanvas(400, &hellip; <a href=\"https:\/\/courses.ideate.cmu.edu\/15-104\/f2022\/2022\/09\/24\/project-04-string-art-3\/\" class=\"more-link\">Continue reading<span class=\"screen-reader-text\"> &#8220;Project 04: String Art&#8221;<\/span><\/a><\/p>\n","protected":false},"author":770,"featured_media":0,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":[],"categories":[102,121,1],"tags":[],"_links":{"self":[{"href":"https:\/\/courses.ideate.cmu.edu\/15-104\/f2022\/wp-json\/wp\/v2\/posts\/72679"}],"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\/770"}],"replies":[{"embeddable":true,"href":"https:\/\/courses.ideate.cmu.edu\/15-104\/f2022\/wp-json\/wp\/v2\/comments?post=72679"}],"version-history":[{"count":2,"href":"https:\/\/courses.ideate.cmu.edu\/15-104\/f2022\/wp-json\/wp\/v2\/posts\/72679\/revisions"}],"predecessor-version":[{"id":72687,"href":"https:\/\/courses.ideate.cmu.edu\/15-104\/f2022\/wp-json\/wp\/v2\/posts\/72679\/revisions\/72687"}],"wp:attachment":[{"href":"https:\/\/courses.ideate.cmu.edu\/15-104\/f2022\/wp-json\/wp\/v2\/media?parent=72679"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/courses.ideate.cmu.edu\/15-104\/f2022\/wp-json\/wp\/v2\/categories?post=72679"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/courses.ideate.cmu.edu\/15-104\/f2022\/wp-json\/wp\/v2\/tags?post=72679"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}