{"id":73109,"date":"2022-09-25T21:44:50","date_gmt":"2022-09-26T01:44:50","guid":{"rendered":"https:\/\/courses.ideate.cmu.edu\/15-104\/f2022\/?p=73109"},"modified":"2022-09-25T21:44:50","modified_gmt":"2022-09-26T01:44:50","slug":"project-04-string-art-16","status":"publish","type":"post","link":"https:\/\/courses.ideate.cmu.edu\/15-104\/f2022\/2022\/09\/25\/project-04-string-art-16\/","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><p><\/p><div><a class=\"p5_sketch_link\" href=\"https:\/\/courses.ideate.cmu.edu\/15-104\/f2022\/wp-content\/uploads\/2022\/09\/sketch-395.js\" data-width=\"600\" data-height=\"450\">sketch<\/a><iframe src=\"https:\/\/courses.ideate.cmu.edu\/15-104\/f2022\/wp-content\/plugins\/p5-embedder\/p5_iframe.html\" class=\"p5_exampleFrame\" width=\"600\" height=\"450\"><\/iframe><pre class=\"language-javascript\"><code class=\"p5_editor language-javascript\">\/\/ Emily Franco\n\/\/ efranco\n\/\/ Section C\n\n\/\/num of string lines\nvar numLines = 50;\n\n\/\/base lines\nvar dx1;\nvar dy1;\nvar dx2;\nvar dy2;\n\n\/\/string lines\nvar x1;\nvar y1;\nvar x2;\nvar y2; \n\n\/\/counts sets of lines\nvar setCount = 0;\n\n\/\/line points\nvar lnx1; \nvar lny1;\nvar lnx2;\nvar lny2;\n\n\/\/colors\nr = 0; \ng = 0; \nb = 0;\nfunction setup() {\n    createCanvas(400, 300);\n    background(220);\n    text(\"p5.js vers 0.9.0 test.\", 10, 15);\n    background (\"white\");\n}\n\nfunction draw() {\n\tvar halfW = width\/2;\n\tvar halfH = height\/2;\n\t\n\tif (setCount == 0){\n\t\t\/\/-----first line set--------\n\t\tlnx1 = 0; \n\t\tlny1 = 0;\n\t\tlnx2 = width\/10;\n\t\tlny2 = height-(height\/12);\n\t}else if (setCount == 1){\n\t\t\/\/-----second line set--------\n\t\tlnx1 = width\/10; \n\t\tlny1 = height-(height\/12);;\n\t\tlnx2 = halfW;\n\t\tlny2 = height-(height\/7);\n\t}else if (setCount == 2){\n\t\t\/\/-----third line set--------\n\t\tlnx1 = halfW; \n\t\tlny1 = height-(height\/7);\n\t\tlnx2 = width-(width\/6);\n\t\tlny2 = height-(height\/2);\n\t}else if (setCount == 3){\n\t\t\/\/-----fourth line set--------\n\t\tlnx1 = width-(width\/6); \n\t\tlny1 = height-(height\/2);\n\t\tlnx2 = width-(width\/3);\n\t\tlny2 = 0;\n\t}else if (setCount == 4){\n\t\t\/\/-----fifth line set--------\n\t\tlnx1 = width-(width\/3); \n\t\tlny1 = 0;\n\t\tlnx2 = width\/2;\n\t\tlny2 = height\/8;\n\t}else if (setCount == 5){\n\t\t\/\/-----fifth line set--------\n\t\tlnx1 = width\/2; \n\t\tlny1 = height\/8;\n\t\tlnx2 = width\/9;\n\t\tlny2 = height\/9;\n\t}else if (setCount&gt;5){\n\t\t\/\/stop looping\n\t\tnoLoop();\n\t}\n\n\t\/\/generate random colors\n\tr = random (255);\n\tg = random (255);\n\tb = random (255);\n\n\tpush();\n\tnoStroke();\n\t\/\/fill trangle between base lines\n\tfill (r,g,b,100);\n\tbeginShape();\n\tvertex (lnx1,lny1);\n\tvertex (halfW,halfH);\n\tvertex (lnx2,lny2);\n\tendShape();\n\t\n\n\t\/\/draw base lines\n\tline(halfW,halfH,lnx1,lny1);\n\tline(halfW,halfH,lnx2,lny2);\n\n\tpop(); \n\n\t\/\/get position increment for string line\n\tdx1 = (halfW-lnx1)\/numLines;\n\tdy1 = (halfH-lny1)\/numLines;\n\tdx2 = (lnx2-halfW)\/numLines;\n\tdy2 = (lny2-halfH)\/numLines;\n\n\t\/\/reset string postions\n\tx1 = lnx1;\n\ty1 = lny1;\n\tx2 = halfW; \n\ty2 = halfH;\n\n\tfor (var i = 0; i&lt;numLines; i+=1){\n\t\t\/\/inverted stroke color\n\t\tstroke (255-r,255-g,255-b,150);\n\t\t\/\/draw string lines\n\t\tline (x1,y1,x2,y2);\n\t\tx1 += dx1;\n\t\ty1 += dy1;\n\t\tx2 += dx2;\n\t\ty2 += dy2;\n\t}\n\n\tsetCount += 1;\n}\n<\/code><\/pre><\/div><\/body><\/html>\n","protected":false},"excerpt":{"rendered":"<p>sketch \/\/ Emily Franco \/\/ efranco \/\/ Section C \/\/num of string lines var numLines = 50; \/\/base lines var dx1; var dy1; var dx2; var dy2; \/\/string lines var x1; var y1; var x2; var y2; \/\/counts sets of lines var setCount = 0; \/\/line points var lnx1; var lny1; var lnx2; var lny2; &hellip; <a href=\"https:\/\/courses.ideate.cmu.edu\/15-104\/f2022\/2022\/09\/25\/project-04-string-art-16\/\" class=\"more-link\">Continue reading<span class=\"screen-reader-text\"> &#8220;Project-04-String Art&#8221;<\/span><\/a><\/p>\n","protected":false},"author":719,"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\/f2022\/wp-json\/wp\/v2\/posts\/73109"}],"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\/719"}],"replies":[{"embeddable":true,"href":"https:\/\/courses.ideate.cmu.edu\/15-104\/f2022\/wp-json\/wp\/v2\/comments?post=73109"}],"version-history":[{"count":5,"href":"https:\/\/courses.ideate.cmu.edu\/15-104\/f2022\/wp-json\/wp\/v2\/posts\/73109\/revisions"}],"predecessor-version":[{"id":74172,"href":"https:\/\/courses.ideate.cmu.edu\/15-104\/f2022\/wp-json\/wp\/v2\/posts\/73109\/revisions\/74172"}],"wp:attachment":[{"href":"https:\/\/courses.ideate.cmu.edu\/15-104\/f2022\/wp-json\/wp\/v2\/media?parent=73109"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/courses.ideate.cmu.edu\/15-104\/f2022\/wp-json\/wp\/v2\/categories?post=73109"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/courses.ideate.cmu.edu\/15-104\/f2022\/wp-json\/wp\/v2\/tags?post=73109"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}