{"id":74031,"date":"2022-10-08T21:20:48","date_gmt":"2022-10-09T01:20:48","guid":{"rendered":"https:\/\/courses.ideate.cmu.edu\/15-104\/f2022\/?p=74031"},"modified":"2022-10-08T21:23:18","modified_gmt":"2022-10-09T01:23:18","slug":"project-06-abstract-clock-srauch","status":"publish","type":"post","link":"https:\/\/courses.ideate.cmu.edu\/15-104\/f2022\/2022\/10\/08\/project-06-abstract-clock-srauch\/","title":{"rendered":"Project 06 &#8211; Abstract Clock &#8211; srauch"},"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>Here is my abstract clock. It&rsquo;s a beach with tides: high tide is at noon and low tide is at midnight. The grass rustles in the breeze, and the beach is strewn with starfish and shells. It&rsquo;s dark from 8 pm to 5am. Sunrise is from 6am to 7am, and sunset is from 7pm to 8pm.<\/p>\n<div><a class=\"p5_sketch_link\" href=\"https:\/\/courses.ideate.cmu.edu\/15-104\/f2022\/wp-content\/uploads\/2022\/10\/sketch-80.js\" data-width=\"400\" data-height=\"400\">sketch<\/a>\n\n\n\n<p><\/p><iframe src=\"https:\/\/courses.ideate.cmu.edu\/15-104\/f2022\/wp-content\/plugins\/p5-embedder\/p5_iframe.html\" class=\"p5_exampleFrame\" width=\"400\" height=\"400\"><\/iframe><pre class=\"language-javascript\"><code class=\"p5_editor language-javascript\">\/\/Sam Rauch, section B, srauch@andrew.cmu.edu, project 06: abstract clock\n\/\/this code creates a beach with a tide. High tide is at noon, and low tide is at midnight.\n\/\/the grass rustles in the sea breeze. it gets darker from 7pm 8 pm and lighter from 6 to 7am. \n\nvar grasslength = []; \/\/length of blades of grass\nvar sandspotX = []; \/\/x position of specks in sand\nvar sandspotY = []; \/\/y position of specks in sand\nvar waveY; \/\/height of the tide\nvar waveShift; \/\/amount the water's edge fluctuates by \nvar daytime; \/\/the time of day in minutes\nvar darkness; \/\/amount of darkness it is\n\nfunction setup() {\n    createCanvas(400, 400);\n    background(220);\n    text(\"p5.js vers 0.9.0 test.\", 10, 15);\n\n    \/\/initializing x position of specks in sand\n    for (var i = 0; i &lt; 50; i++){\n        sandspotX[i] = random(0, width);\n    }\n\n    \/\/initializing y position of specks in sand\n    for (var i = 0; i &lt; 50; i++){\n        sandspotY[i] = random(200, 400);\n    }\n\n    frameRate(5);\n\n    \/\/creating y position of tide. High tide is at noon, low tide is at midnight\n    daytime = hour()*60 + minute(); \/\/time of day, in minutes\n    if (daytime &lt; 690) { \/\/if before noon\n        waveY = map(daytime, 0, 690, 400, 200); \/\/before noon, wave gets higher with time\n    } else { \/\/if after noon\n        waveY = map(daytime, 690, 1380, 200, 400); \/\/after noon, wave gets lower with time\n    }\n\n    \/\/making it get lighter and darker at sunrise and sunset\n    if (daytime &gt;= 300 & daytime < 360) { \/\/if from 5 to 6 am, it gets lighter\n        darkness = map(daytime, 300, 360, 120, 0);\n    } else if (daytime &gt;= 1140 & daytime < 1200) { \/\/from 7 to 8 pm, it gets darker\n        darkness = map(daytime, 1140, 1200, 0, 120);\n    } else if (daytime &gt;= 360 & daytime < 1140) { \/\/in the middle of the day, it's not dark\n        darkness = 0;\n    } else { \/\/in the middle of the night, it's dark\n        darkness = 120;\n    }\n}\n\nfunction draw() {\n    noStroke();\n    background(155, 207, 207);\n\n    \/\/row of grass bunches\n    for (var i = 0; i &lt;2; i++){\n        for(var j = 0; j&lt;=width; j += 20) {\n        grass(j, 220);\n        }\n    }\n    \n    \/\/sand\n    fill(196, 178, 122);\n    rect(0, 200, width, 200);\n\n    \/\/little specks in sand\n    strokeWeight(3);\n    stroke(146, 128, 72)\n    for (var i = 0; i&lt;50; i++){\n        point(sandspotX[i], sandspotY[i]);\n    }\n    noStroke();\n\n    \/\/assorted shells and starfish\n    starfish(250, 250, color(120, 130, 120), 10);\n    starfish(50, 340, color(50, 74, 64), 50);\n    starfish(180, 370, color(120, 79, 97), 5);\n    shell(140, 260, color(60, 50, 70), color(100, 80, 107), 60);\n    shell(300, 300, color(80, 50, 50), color(120, 80, 97), -5);\n\n    \/\/waves\n    waveShift = randomGaussian(1, 2);\n    fill(30, 100, 155, 240);\n    rect(0, waveY+waveShift, width, 300);\n    fill(30, 100, 155, 100);\n    rect(0, waveY-(random(1,3))+waveShift, width, 300);\n\n    \/\/rectangle that makes darkness and lightness of environment using alpha channel\n    blendMode(MULTIPLY);\n    fill(35, 50, 70, darkness);\n    rect(0,0,width,height);\n    blendMode(BLEND);\n}\n\n\/\/makes starfish\nfunction starfish(x,y, color, spin){\n    push();\n    translate(x,y);\n    rotate(radians(spin));\n    strokeWeight(4);\n    stroke(color);\n    for (var i = 0; i&lt;5; i++){ \/\/draw five arms from 0,0, rotating after each one\n        line(0,0,0,-10);\n        rotate(radians(72));\n    }\n    noStroke();\n    pop();\n}\n\n\/\/makes seashells\nfunction shell(x,y, color1, color2, spin) {\n    push();\n    translate(x,y);\n    rotate(radians(spin));\n    strokeWeight(1);\n    stroke(color1);\n    fill(color2);\n\n    var radius = 7; \/\/radius of seashell, ie distance from circles to center\n    var size = 12; \/\/size of circles themselves\n    var angle = radians(0); \/\/theta of circle location\n    for (var i = 0; i&lt;20; i++) { \/\/draw circles that get smaller as they get closer to the center\n        ellipse ( cos(angle)*radius, sin(angle)*radius, size);\n        angle-=radians(24);\n        size -= i\/20; \/\/decrease size of circles\n        radius -= i\/30; \/\/decrease radius of seashell       \n    }\n    noStroke();\n    pop();\n}\n\n\/\/makes a bunch of grass\nfunction grass(x,y){\n    push();\n    translate(x,y);\n    stroke(65, 100, 52);\n    strokeWeight(2);\n    rotate(radians(-40));\n    for (var i = 0; i &lt; 20; i++){ \/\/creating each blade of grass in a bunch\n        for (var j = 0; j &lt; 20; j++){ \/\/creating random lengths for each blade of grass\n            grasslength[j] = random(35, 40);\n        }\n        line(0,0,0, -1*grasslength[i]);\n        rotate(radians(4));\n    }\n\n    pop();\n}<\/code><\/pre><\/div><\/body><\/html>\n","protected":false},"excerpt":{"rendered":"<p>Here is my abstract clock. It&rsquo;s a beach with tides: high tide is at noon and low tide is at midnight. The grass rustles in the breeze, and the beach is strewn with starfish and shells. It&rsquo;s dark from 8 pm to 5am. Sunrise is from 6am to 7am, and sunset is from 7pm to &hellip; <a href=\"https:\/\/courses.ideate.cmu.edu\/15-104\/f2022\/2022\/10\/08\/project-06-abstract-clock-srauch\/\" class=\"more-link\">Continue reading<span class=\"screen-reader-text\"> &#8220;Project 06 &#8211; Abstract Clock &#8211; srauch&#8221;<\/span><\/a><\/p>\n","protected":false},"author":754,"featured_media":0,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":[],"categories":[106,56,1],"tags":[],"_links":{"self":[{"href":"https:\/\/courses.ideate.cmu.edu\/15-104\/f2022\/wp-json\/wp\/v2\/posts\/74031"}],"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\/754"}],"replies":[{"embeddable":true,"href":"https:\/\/courses.ideate.cmu.edu\/15-104\/f2022\/wp-json\/wp\/v2\/comments?post=74031"}],"version-history":[{"count":4,"href":"https:\/\/courses.ideate.cmu.edu\/15-104\/f2022\/wp-json\/wp\/v2\/posts\/74031\/revisions"}],"predecessor-version":[{"id":74040,"href":"https:\/\/courses.ideate.cmu.edu\/15-104\/f2022\/wp-json\/wp\/v2\/posts\/74031\/revisions\/74040"}],"wp:attachment":[{"href":"https:\/\/courses.ideate.cmu.edu\/15-104\/f2022\/wp-json\/wp\/v2\/media?parent=74031"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/courses.ideate.cmu.edu\/15-104\/f2022\/wp-json\/wp\/v2\/categories?post=74031"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/courses.ideate.cmu.edu\/15-104\/f2022\/wp-json\/wp\/v2\/tags?post=74031"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}