{"id":69157,"date":"2021-11-17T14:49:50","date_gmt":"2021-11-17T19:49:50","guid":{"rendered":"https:\/\/courses.ideate.cmu.edu\/15-104\/f2021\/?p=69157"},"modified":"2021-11-17T14:53:32","modified_gmt":"2021-11-17T19:53:32","slug":"project-11-generative-landscape-10","status":"publish","type":"post","link":"https:\/\/courses.ideate.cmu.edu\/15-104\/f2021\/2021\/11\/17\/project-11-generative-landscape-10\/","title":{"rendered":"Project 11: Generative Landscape"},"content":{"rendered":"<!DOCTYPE html PUBLIC \"-\/\/W3C\/\/DTD HTML 4.0 Transitional\/\/EN\" \"http:\/\/www.w3.org\/TR\/REC-html40\/loose.dtd\">\n<html><body><figure class=\"wp-block-image size-large\"><img loading=\"lazy\" width=\"1024\" height=\"891\" src=\"https:\/\/courses.ideate.cmu.edu\/15-104\/f2021\/wp-content\/uploads\/2021\/11\/IMG_9372-1024x891.jpg\" alt=\"\" class=\"wp-image-69167\" srcset=\"https:\/\/courses.ideate.cmu.edu\/15-104\/f2021\/wp-content\/uploads\/2021\/11\/IMG_9372-1024x891.jpg 1024w, https:\/\/courses.ideate.cmu.edu\/15-104\/f2021\/wp-content\/uploads\/2021\/11\/IMG_9372-300x261.jpg 300w, https:\/\/courses.ideate.cmu.edu\/15-104\/f2021\/wp-content\/uploads\/2021\/11\/IMG_9372-768x668.jpg 768w, https:\/\/courses.ideate.cmu.edu\/15-104\/f2021\/wp-content\/uploads\/2021\/11\/IMG_9372-1536x1337.jpg 1536w, https:\/\/courses.ideate.cmu.edu\/15-104\/f2021\/wp-content\/uploads\/2021\/11\/IMG_9372-2048x1783.jpg 2048w, https:\/\/courses.ideate.cmu.edu\/15-104\/f2021\/wp-content\/uploads\/2021\/11\/IMG_9372-1200x1044.jpg 1200w\" sizes=\"(max-width: 709px) 85vw, (max-width: 909px) 67vw, (max-width: 1362px) 62vw, 840px\"><figcaption>A sketch of my intended look and its parts<\/figcaption><\/figure><p>I&rsquo;ve been missing my grandparents recently, so I knew I wanted to do something that reminds me of them. That means mountains. My grandfather is Austrian and he and my grandmother live in Colorado currently, so I wanted to make the scene feel like I was riding in the car in some mountainous area, complete with rolling hills, pine trees, a nice wooden fence, and a couple goats. I used a noise function for the mountains and hills at different amplitudes. The hill noise function gave me a little trouble when I started implementing my trees, but by lowering the amplitude more and limiting the range for the random tree generation, I was able to mitigate most of the floating trees. Originally, I was thinking about making the goat change color as well, but I couldn&rsquo;t successfully implement it, so I left it out. Overall, I&rsquo;m happy with how my landscape came out. I think that if I had more time, there are certainly more tweaks I would make, but with the time that was available to me this week I&rsquo;m happy with what I made.<\/p>\n\n\n\n<p><a class=\"p5_sketch_link\" data-width=\"480\" data-height=\"200\" href=\"https:\/\/courses.ideate.cmu.edu\/15-104\/f2021\/wp-content\/uploads\/2021\/11\/sketch-64.js\">sketch<\/a><iframe src=\"https:\/\/courses.ideate.cmu.edu\/15-104\/f2021\/wp-content\/plugins\/p5-embedder\/p5_iframe.html\" class=\"p5_exampleFrame\" width=\"480\" height=\"200\"><\/iframe><pre class=\"language-javascript\"><code class=\"p5_editor language-javascript\">\/\/Elise Chapman\n\/\/ejchapma\n\/\/ejchapma@andrew.cmu.edu\n\/\/Section D\n\nvar goats = [];\nvar hill = [];\nvar mountain = [];\nvar fence = [];\nvar trees = [];\nvar noiseParam = 1; \/\/for the mountains\nvar noiseStep = 0.05; \/\/for the mountains\nvar noiseParam2 = 5; \/\/for the hills\nvar noiseStep2 = 0.005; \/\/for the hills\n\nfunction preload() {\n    treeImg = loadImage(\"https:\/\/i.imgur.com\/eI7dRxU.png\");\n    fenceImg = loadImage(\"https:\/\/i.imgur.com\/8f0PfZu.png\");\n    goatImg = loadImage(\"https:\/\/i.imgur.com\/TX6vImS.png\");\n}\n\n\/\/the mountains\nfunction mountains() {\n    \/\/sets up the mountains\n    strokeWeight(3);\n    stroke(100); \/\/dark gray\n    fill(100); \/\/dark gray\n\n    \/\/creates the mountains\n    translate(0,0.5);\n    beginShape();\n    vertex(0,height);\n    for (var i=0; i&lt;(width\/5)+1; i+=1) {\n        vertex(i*5,mountain[i]);\n    }\n    vertex(width,height);\n    endShape();\n    mountain.shift();\n    var n=noise(noiseParam);\n    var value=map(n,0,1,0,height);\n    mountain.push(value);\n    noiseParam+=noiseStep;\n}\n\n\/\/the hills\nfunction hills() {\n    \/\/sets up the hills\n    strokeWeight(3);\n    stroke(27,81,45); \/\/dark green\n    fill(27,81,45); \/\/dark green\n\n    \/\/creates the hills\n    translate(0,10);\n    beginShape();\n    vertex(0,height);\n    for (var i=0; i&lt;(width\/5)+1; i+=1) {\n        vertex(i*5,hill[i]);\n    }\n    vertex(width,height);\n    endShape();\n    hill.shift();\n    var n=noise(noiseParam2);\n    var value=map(n,0,1,0,height);\n    hill.push(value);\n    noiseParam2+=noiseStep2;\n}\n\n\/\/the goats\nfunction makeGoat(gx) {\n    var g = {x: gx,\n        goatSpeed: -3.0,\n        goatSizeMod: random(0,51),\n        move: goatMove,\n        display: goatDisplay}\n    return g;\n}\nfunction goatDisplay() {\n    image(goatImg, this.x+200,90-this.goatSizeMod, 100+this.goatSizeMod,100+this.goatSizeMod);\n}\nfunction goatMove() {\n    this.x += this.goatSpeed;\n}\nfunction updateGoats() {\n    \/\/update the goat positions and display them\n    for (var i=0; i&lt;goats.length; i+=1) {\n        goats[i].move();\n        goats[i].display();\n    }\n}\nfunction removeGoats() {\n    \/\/remove goat when no longer on screen\n    var goatOnScreen = [];\n    for (var i=0; i&lt;goats.length; i+=1) {\n        if (goats[i].x + 400 &gt; 0) {\n            goatOnScreen.push(goats[i]);\n        }\n    }\n    goats = goatOnScreen;\n}\nfunction addNewGoats() {\n    var newGoatChance = 0.004;\n    if (random(0,1) &lt; newGoatChance) {\n        goats.push(makeGoat(width));\n    }\n}\n\n\/\/the trees\nfunction makeTree(tx) {\n    var t = {x: tx,\n        y: 90-random(0,50),\n        treeSpeed: -5.0,\n        treeSizeMod: random(0,51),\n        move: treeMove,\n        display: treeDisplay}\n    return t;\n}\nfunction treeDisplay() {\n    image(treeImg, this.x+200, this.y, 50+this.treeSizeMod,75+this.treeSizeMod);\n}\nfunction treeMove() {\n    this.x += this.treeSpeed;\n}\nfunction updateTrees() {\n    \/\/update the tree positions and display them\n    for (var i=0; i&lt;trees.length; i+=1) {\n        trees[i].move();\n        trees[i].display();\n    }\n}\nfunction removeTrees() {\n    \/\/remove tree when no longer on screen\n    var treesOnScreen = [];\n    for (var i=0; i&lt;trees.length; i+=1) {\n        if (trees[i].x + 400 &gt; 0) {\n            treesOnScreen.push(trees[i]);\n        }\n    }\n    trees = treesOnScreen;\n}\nfunction addNewTrees() {\n    var newTreeChance = 0.1;\n    if (random(0,1) &lt; newTreeChance) {\n        trees.push(makeTree(width));\n    }\n}\n\nfunction setup() {\n    createCanvas(480,200);\n    frameRate(25);\n    \n    \/\/for the mountains\n    for (var i=0; i&lt;(width\/5)+1; i+=1) {\n        var n=noise(noiseParam);\n        var value=map(n,0,1,0,height);\n        mountain[i]=value;\n        noiseParam+=noiseStep;\n    }\n    \/\/for the mountains\n    for (var i=0; i&lt;(width\/5)+1; i+=1) {\n        var n=noise(noiseParam2);\n        var value=map(n,0,1,0,height);\n        hill[i]=value;\n        noiseParam2+=noiseStep2;\n    }\n    \/\/inital collection of trees\n    for (var i=0; i&lt;10; i+=1) {\n        var rx = random(width);\n        trees[i]=makeTree(rx);\n    }\n}\n\nfunction draw() {\n    background(123, 196, 227); \/\/sky blue\n\n    \/\/sun\n    noStroke();\n    fill(255, 255, 227); \/\/very light yellow\n    ellipse(40,30,25);\n\n    mountains();\n    hills();\n\n    \/\/trees\n    updateTrees();\n    removeTrees();\n    addNewTrees();\n\n    \/\/goats\n    updateGoats();\n    removeGoats();\n    addNewGoats();\n\n    \/\/fence\n    var fenceX=0;\n    for (var i=0; i&lt;5; i+=1) {\n        image(fenceImg, fenceX+(i*200),115, 200,100);\n    }\n}\n<\/code><\/pre><\/p>\n\n\n\n<p> <\/p><\/body><\/html>\n","protected":false},"excerpt":{"rendered":"<p>I&rsquo;ve been missing my grandparents recently, so I knew I wanted to do something that reminds me of them. That means mountains. My grandfather is Austrian and he and my grandmother live in Colorado currently, so I wanted to make the scene feel like I was riding in the car in some mountainous area, complete &hellip; <a href=\"https:\/\/courses.ideate.cmu.edu\/15-104\/f2021\/2021\/11\/17\/project-11-generative-landscape-10\/\" class=\"more-link\">Continue reading<span class=\"screen-reader-text\"> &#8220;Project 11: Generative Landscape&#8221;<\/span><\/a><\/p>\n","protected":false},"author":644,"featured_media":0,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":[],"categories":[115,58],"tags":[],"_links":{"self":[{"href":"https:\/\/courses.ideate.cmu.edu\/15-104\/f2021\/wp-json\/wp\/v2\/posts\/69157"}],"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\/644"}],"replies":[{"embeddable":true,"href":"https:\/\/courses.ideate.cmu.edu\/15-104\/f2021\/wp-json\/wp\/v2\/comments?post=69157"}],"version-history":[{"count":3,"href":"https:\/\/courses.ideate.cmu.edu\/15-104\/f2021\/wp-json\/wp\/v2\/posts\/69157\/revisions"}],"predecessor-version":[{"id":69172,"href":"https:\/\/courses.ideate.cmu.edu\/15-104\/f2021\/wp-json\/wp\/v2\/posts\/69157\/revisions\/69172"}],"wp:attachment":[{"href":"https:\/\/courses.ideate.cmu.edu\/15-104\/f2021\/wp-json\/wp\/v2\/media?parent=69157"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/courses.ideate.cmu.edu\/15-104\/f2021\/wp-json\/wp\/v2\/categories?post=69157"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/courses.ideate.cmu.edu\/15-104\/f2021\/wp-json\/wp\/v2\/tags?post=69157"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}