{"id":72718,"date":"2022-09-24T15:51:50","date_gmt":"2022-09-24T19:51:50","guid":{"rendered":"https:\/\/courses.ideate.cmu.edu\/15-104\/f2022\/?p=72718"},"modified":"2022-09-24T15:58:43","modified_gmt":"2022-09-24T19:58:43","slug":"line-drawing","status":"publish","type":"post","link":"https:\/\/courses.ideate.cmu.edu\/15-104\/f2022\/2022\/09\/24\/line-drawing\/","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\" id=\"wp-block-file--media-36888592-8a47-4b4e-bbee-517520d42b95\" href=\"https:\/\/courses.ideate.cmu.edu\/15-104\/f2022\/wp-content\/uploads\/2022\/09\/sketch-345.js\">islandd sketch<\/a><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\">function setup() {\n    createCanvas(400, 300);\n    background(\"lightsteelblue\");\n}\n\nfunction draw() {\n    strokeWeight(0.5);\n    numLines = 30;\n\n    \/\/sun beams\n    strt(-width, 0, width, 2*height, 0, 0, width, 0, 20, \"yellow\");\n    fill(\"yellow\");\n    ellipse(width, 0, 100);  \/\/sun\n\n    \/\/mountains\n    fill(\"green\");\n    triangle(90, 150, 20, 250, 390, 250);\n    triangle(290, 150, 390, 250, 20, 250);\n    stroke(\"green\");\n    line(90, 150, 20, 250);    \/\/left mountain\n    line(290, 150, 390, 250);   \/\/right mountain\n    crshtch(90, 150, 20, 250, 290, 150, 390, 250, numLines, \"palegreen\");\n    crshtch(290, 150, 390, 250, 90, 150, 20, 250, numLines, \"palegreen\");\n\n    \/\/water\n    fill(\"lightseagreen\");\n    rect(0, 250, 400, 50);\n    lne(0, 250, 0, 300, 400, 250, 400, 300, 30, \"blue\");\n\n}\n\n\n\/\/diag crosshatch\nfunction crshtch(x1, y1, x2, y2, x3, y3, x4, y4, numLines, colour){\n    stroke(colour);\n    dx3 = (x4-x3)\/numLines;\n    dy3 = (y4-y3)\/numLines;\n    dx1 = (x2-x1)\/numLines;\n    dy1 = (y2-y1)\/numLines;\n    dx2 = (x4-x3)\/numLines;\n    dy2 = (y4-y3)\/numLines;\n    for(var i = 0; i &lt;= numLines; i ++){\n            line(x1, y1, x4, y4);\n\n            x1 += dx1;\n            y1 += dy1;\n            x2 += dx2;\n            y2 += dy2;\n            x3 += dx3;\n            y3 += dy3;\n    }\n}\n\n\/\/light lines\nfunction strt(a1, b1, a2, b2, a3, b3, a4, b4, numLines, colour){\n    stroke(colour);\n    dx3 = (a4-a3)\/numLines;\n    dy3 = (b4-b3)\/numLines;\n    dx1 = (a2-a1)\/numLines;\n    dy1 = (b2-b1)\/numLines;\n    dx2 = (a4-a3)\/numLines;\n    dy2 = (b4-b3)\/numLines;\n    for(var i = 0; i &lt;= numLines; i ++){\n            line(a1, b1, a4, b4);\n            a1 += dx1;\n            b1 += dy1;\n    }\n\n}\n\n\/\/straight lines\nfunction lne(x1, y1, x2, y2, x3, y3, x4, y4, numLines, colour){\n    stroke(colour);\n    dy1 = (y2-y1)\/numLines;\n    dy3 = (y4-y3)\/numLines;\n    for(var i = 0; i &lt;= numLines; i ++){\n            line(x1, y1, x3, y3);\n\n            y1 += dy1;\n            y3 += dy2;\n    }\n}\n\n\n<\/code><\/pre><\/div><\/body><\/html>\n","protected":false},"excerpt":{"rendered":"","protected":false},"author":747,"featured_media":0,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":[],"categories":[102,58],"tags":[],"_links":{"self":[{"href":"https:\/\/courses.ideate.cmu.edu\/15-104\/f2022\/wp-json\/wp\/v2\/posts\/72718"}],"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\/747"}],"replies":[{"embeddable":true,"href":"https:\/\/courses.ideate.cmu.edu\/15-104\/f2022\/wp-json\/wp\/v2\/comments?post=72718"}],"version-history":[{"count":4,"href":"https:\/\/courses.ideate.cmu.edu\/15-104\/f2022\/wp-json\/wp\/v2\/posts\/72718\/revisions"}],"predecessor-version":[{"id":72727,"href":"https:\/\/courses.ideate.cmu.edu\/15-104\/f2022\/wp-json\/wp\/v2\/posts\/72718\/revisions\/72727"}],"wp:attachment":[{"href":"https:\/\/courses.ideate.cmu.edu\/15-104\/f2022\/wp-json\/wp\/v2\/media?parent=72718"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/courses.ideate.cmu.edu\/15-104\/f2022\/wp-json\/wp\/v2\/categories?post=72718"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/courses.ideate.cmu.edu\/15-104\/f2022\/wp-json\/wp\/v2\/tags?post=72718"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}