{"id":76059,"date":"2022-11-20T21:37:17","date_gmt":"2022-11-21T02:37:17","guid":{"rendered":"https:\/\/courses.ideate.cmu.edu\/15-104\/f2022\/?p=76059"},"modified":"2022-11-20T21:37:17","modified_gmt":"2022-11-21T02:37:17","slug":"project-11-winter-scroll","status":"publish","type":"post","link":"https:\/\/courses.ideate.cmu.edu\/15-104\/f2022\/2022\/11\/20\/project-11-winter-scroll\/","title":{"rendered":"Project 11: Winter Scroll"},"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><a class=\"p5_sketch_link\" data-width=\"500\" data-height=\"300\" href=\"https:\/\/courses.ideate.cmu.edu\/15-104\/f2022\/wp-content\/uploads\/2022\/11\/sketch-78.js\">sketch<\/a><iframe src=\"https:\/\/courses.ideate.cmu.edu\/15-104\/f2022\/wp-content\/plugins\/p5-embedder\/p5_iframe.html\" class=\"p5_exampleFrame\" width=\"500\" height=\"300\"><\/iframe><pre class=\"language-javascript\"><code class=\"p5_editor language-javascript\">\/\/Name: Hari Vardhan Sampath\n\/\/Section: E\n\/\/eMail address: harivars@andrew.cmu.edu\n\/\/Project-11\n\nvar snowForeground = []; \/\/ array of snow particles in the foreground\nvar snowBackground = []; \/\/ array of snow particles in the background\nvar snowAmountForeground = 500;\nvar snowAmountBackground = 750;\nvar snowSize = 3;\nvar snowLayers = 3;\n\nfunction setup() {\n    createCanvas(500, 300);\n\n    for (i = 0; i &lt; snowAmountForeground; i++) {\n        snowForeground[i] = new Object();\n        snowForeground[i].x = random(width);\n        snowForeground[i].y = random(height);\n        snowForeground[i].dy = random(0.25, 1);\n        snowForeground[i].c = color(random(200, 255));\n    }\n\n    for (i = 0; i &lt; snowAmountBackground; i++) {\n        snowBackground[i] = new Object();\n        snowBackground[i].x = random(width);\n        snowBackground[i].y = random(height);\n        snowBackground[i].dy = random(0.25, 1);\n        snowBackground[i].c = color(random(200, 255));\n    }\n}\n\n\/\/ update position and draw each of 100 rectangles\nfunction draw() {\n    \/\/ background sky gradient\n    for (var i = 0; i &lt; height; i++) {\n        \/\/ \n        var c1 = color(0, 20, 52);\n        var c2 = color(0, 71, 126);\n        \/\/ \n        var gradient = map(i, 0, height, 0, 1);\n        var c = lerpColor(c1, c2, gradient);\n        stroke(c);\n        line(0, i, width, i);\n    }\n\n    \/\/ snow falling in the background\n    noStroke();\n    for (i = 0; i &lt; snowAmountBackground; i++) {\n        drawSnowBackground(snowBackground[i]);\n        updateSnowBackground(snowBackground[i]);\n    }\n\n    \/\/ layers of winter forest\n    forest();\n\n    \/\/ snow falling in the foreground\n    noStroke();\n    for (i = 0; i &lt; snowAmountForeground; i++) {\n        drawSnowForeground(snowForeground[i]);\n        updateSnowForeground(snowForeground[i]);\n    }\n}\n\nfunction forest() {\n    foliage0 = 0.06;\n    foliage1 = 0.04;\n    foliage2 = 0.02;\n    foliage3 = 0.01;\n    foliageSpeed0 = 0.001;\n    foliageSpeed1 = 0.002;\n    foliageSpeed2 = 0.003;\n    foliageSpeed3 = 0.004;\n\n    stroke(163, 196, 217);\n    beginShape();\n    for (var i = 0; i &lt; width; i++) {\n        var t0 = (i * foliage0) + (millis() * foliageSpeed0);\n        var y0 = map(noise(t0), 0, 1, 200, 5);\n        line(i, y0, i, height);\n    }\n    endShape();\n\n    stroke(117, 163, 191);\n    beginShape();\n    for (var i = 0; i &lt; width; i++) {\n        var t1 = (i * foliage1) + (millis() * foliageSpeed1);\n        var y1 = map(noise(t1), 0, 1, 250, 6);\n        line(i, y1, i, height);\n    }\n    endShape();\n\n    stroke(70, 113, 140);\n    beginShape();\n    for (var i = 0; i &lt; width; i++) {\n        var t2 = (i * foliage2) + (millis() * foliageSpeed2);\n        var y2 = map(noise(t2), 0, 1, 275, 7);\n        line(i, y2, i, height);\n    }\n    endShape();\n\n    stroke(30, 51, 64);\n    beginShape();\n    for (var i = 0; i &lt; width; i++) {\n        var t3 = (i * foliage3) + (millis() * foliageSpeed2);\n        var y3 = map(noise(t3), 0, 1, 300, 8);\n        line(i, y3, i, height);\n    }\n    endShape();\n}\n\nfunction drawSnowForeground(s) {\n    fill(s.c);\n    circle(s.x, s.y, 2);\n}\n\nfunction updateSnowForeground(s) {\n        s.y += s.dy;\n        if (s.y &gt; height) {\n        s.y = 0;\n        }\n        else if (s.y &lt; 0) {\n            s.y = height;       \n        }\n}\n\nfunction drawSnowBackground(s) {\n    fill(s.c);\n    circle(s.x, s.y, random(0.5,1.5));\n}\n\nfunction updateSnowBackground(s) {\n        s.y += s.dy;\n        if (s.y &gt; height) {\n        s.y = 0;\n        }\n        else if (s.y &lt; 0) {\n            s.y = height;       \n        }\n}\n\n\n<\/code><\/pre><\/p>\n\n\n\n<p><\/p>\n\n\n\n<figure class=\"wp-block-image size-full\"><img loading=\"lazy\" width=\"900\" height=\"675\" src=\"https:\/\/courses.ideate.cmu.edu\/15-104\/f2022\/wp-content\/uploads\/2022\/11\/Indian_railways_journey_basket_blog-14.jpg\" alt=\"\" class=\"wp-image-76067\" srcset=\"https:\/\/courses.ideate.cmu.edu\/15-104\/f2022\/wp-content\/uploads\/2022\/11\/Indian_railways_journey_basket_blog-14.jpg 900w, https:\/\/courses.ideate.cmu.edu\/15-104\/f2022\/wp-content\/uploads\/2022\/11\/Indian_railways_journey_basket_blog-14-300x225.jpg 300w, https:\/\/courses.ideate.cmu.edu\/15-104\/f2022\/wp-content\/uploads\/2022\/11\/Indian_railways_journey_basket_blog-14-768x576.jpg 768w\" sizes=\"(max-width: 709px) 85vw, (max-width: 909px) 67vw, (max-width: 1362px) 62vw, 840px\"><figcaption>Train&rsquo;s window <br>Credits: https:\/\/www.journeyb.com\/2019\/10\/journeybasket-short-history-indian-railways-book-photos.html<\/figcaption><\/figure><\/body><\/html>\n","protected":false},"excerpt":{"rendered":"<p>sketch \/\/Name: Hari Vardhan Sampath \/\/Section: E \/\/eMail address: harivars@andrew.cmu.edu \/\/Project-11 var snowForeground = []; \/\/ array of snow particles in the foreground var snowBackground = []; \/\/ array of snow particles in the background var snowAmountForeground = 500; var snowAmountBackground = 750; var snowSize = 3; var snowLayers = 3; function setup() { createCanvas(500, &hellip; <a href=\"https:\/\/courses.ideate.cmu.edu\/15-104\/f2022\/2022\/11\/20\/project-11-winter-scroll\/\" class=\"more-link\">Continue reading<span class=\"screen-reader-text\"> &#8220;Project 11: Winter Scroll&#8221;<\/span><\/a><\/p>\n","protected":false},"author":756,"featured_media":0,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":[],"categories":[115,121],"tags":[],"_links":{"self":[{"href":"https:\/\/courses.ideate.cmu.edu\/15-104\/f2022\/wp-json\/wp\/v2\/posts\/76059"}],"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\/756"}],"replies":[{"embeddable":true,"href":"https:\/\/courses.ideate.cmu.edu\/15-104\/f2022\/wp-json\/wp\/v2\/comments?post=76059"}],"version-history":[{"count":4,"href":"https:\/\/courses.ideate.cmu.edu\/15-104\/f2022\/wp-json\/wp\/v2\/posts\/76059\/revisions"}],"predecessor-version":[{"id":76070,"href":"https:\/\/courses.ideate.cmu.edu\/15-104\/f2022\/wp-json\/wp\/v2\/posts\/76059\/revisions\/76070"}],"wp:attachment":[{"href":"https:\/\/courses.ideate.cmu.edu\/15-104\/f2022\/wp-json\/wp\/v2\/media?parent=76059"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/courses.ideate.cmu.edu\/15-104\/f2022\/wp-json\/wp\/v2\/categories?post=76059"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/courses.ideate.cmu.edu\/15-104\/f2022\/wp-json\/wp\/v2\/tags?post=76059"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}