{"id":73858,"date":"2022-10-07T22:59:39","date_gmt":"2022-10-08T02:59:39","guid":{"rendered":"https:\/\/courses.ideate.cmu.edu\/15-104\/f2022\/?p=73858"},"modified":"2022-10-07T23:05:26","modified_gmt":"2022-10-08T03:05:26","slug":"project-06","status":"publish","type":"post","link":"https:\/\/courses.ideate.cmu.edu\/15-104\/f2022\/2022\/10\/07\/project-06\/","title":{"rendered":"Project 06"},"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=\"450\" data-height=\"450id=\" wp-block-file--media-c373bcc3-812d-4464-9e18-89b12fc2c9c0 href=\"https:\/\/courses.ideate.cmu.edu\/15-104\/f2022\/wp-content\/uploads\/2022\/10\/sketch-59.js\">sketch<\/a><a href=\"https:\/\/courses.ideate.cmu.edu\/15-104\/f2022\/wp-content\/uploads\/2022\/10\/sketch-59.js\" class=\"wp-block-file__button\" download aria-describedby=\"wp-block-file--media-c373bcc3-812d-4464-9e18-89b12fc2c9c0\">Download<\/a><iframe src=\"https:\/\/courses.ideate.cmu.edu\/15-104\/f2022\/wp-content\/plugins\/p5-embedder\/p5_iframe.html\" class=\"p5_exampleFrame\" width=\"450\" height=\"450id=\"><\/iframe><pre class=\"language-javascript\"><code class=\"p5_editor language-javascript\">\/\/ Ilia Urgen\n\/\/ Section B\n\/\/ iurgen@andrew.cmu.edu\n\/\/ Project-06\n\nfunction setup() {\n    createCanvas (450,450); \n}\n\nfunction draw() { \n    \/\/ 0:00 to 8:00\n    if (hour() &gt;= 0 & hour() <= 8) {\n        sleep(); \n    }\n\n    \/\/ 8:00 to 20:00\n    else if (hour() &gt;= 8 & hour() <= 20) {\n        daytime();\n    }\n\n    \/\/ 20:00 to 24:00\n    else if (hour() &gt;= 20 & hour() <= 24) {\n        sleep();\n    }\n\n}\n\n\/\/ 0:00 to 8:00 and 20:00 to 24:00\nfunction sleep() {\n    \n    var s = map (minute(), 0, 60, 0, 3600) + second();\n    var c = map (hour(), 0, 20, 0, 70);\n    var h = map (s, 0, 3600, 0, 90);\n\n    \n    color_1 = color (120,29,173);\n    color_2 = color (0);\n\n    \/\/ ombre \n    for (var y = 0; y &lt; height; y++ ) {\n        n = map (y,0, height, 0, 1);\n        var color_3 = lerpColor (color_1, color_2, n);\n        stroke (color_3);\n        line (0, y, width, y);\n    }\n\n    stroke (0);\n    strokeWeight (8);\n\n    \/\/ canvas border lines\n    line (1,1,1,449);\n    line (1,1,449,1);\n    line (1,449,449,449);\n    line (449,1,449,449); \n\n    \/\/ window\n    fill (11,11,10 + c);\n    rect (width\/2, height\/2 - 180, 200, 200);\n\n    \/\/ moon\n    noStroke();\n    fill (230,230,180);\n    ellipse (320,120,100,100);\n    fill (11,11,10 + c);\n    ellipse (375 - h,120,95,110);\n\n    \/\/ bed\n    fill (152,118,84);\n    strokeWeight (0.5);\n    rect (width\/2 - 200, height\/4 + 210, 300, 100);\n    rect (width\/2 - 200, height\/4 + 310, 40, 40);\n    rect (width\/2 + 60, height\/4 + 310, 40, 40);\n\n    \/\/ hair on head\n    fill (255);\n    ellipse (280,315,100,40);\n\n    \/\/ pillow\n    fill (0);\n    ellipse (280,300,70,45);\n\n    \/\/blanket\n    strokeWeight (2);\n    fill (123,24,26);\n    square (width\/2 - 200, height\/4 + 170, 50);\n    square (width\/2 - 150, height\/4 + 220, 50);\n    square (width\/2 - 100, height\/4 + 170, 50);\n    square (width\/2 - 50, height\/4 + 220, 50);\n    square (width\/2, height\/4 + 170, 50);\n    square (width\/2 - 200, height\/4 + 270, 50);\n    square (width\/2 - 100, height\/4 + 270, 50);\n    square (width\/2, height\/4 + 270, 50);\n\n    fill (0,65,169);\n    square (width\/2 - 200, height\/4 + 220, 50);\n    square (width\/2 - 150, height\/4 + 170, 50);\n    square (width\/2 - 100, height\/4 + 220, 50);\n    square (width\/2 - 50, height\/4 + 170, 50);\n    square (width\/2, height\/4 + 220, 50);\n    square (width\/2 - 150, height\/4 + 270, 50);\n    square (width\/2 - 50, height\/4 + 270, 50);\n    \n    \/\/ Flickering Zzz's\n    zzz();\n}\n\nfunction zzz() {\n    \n    if (second () % 2 == 0) {\n        stroke (255);\n        strokeWeight (4);\n        line (280,270,320,270);\n        line (280,230,320,230);\n        line (280,270,320,230);\n\n        push();\n        translate (40, -20);\n        line (280,270,320,270);\n        line (280,230,320,230);\n        line (280,270,320,230);\n        pop();\n\n        push();\n        translate (80, -40);\n        line (280,270,320,270);\n        line (280,230,320,230);\n        line (280,270,320,230);\n        pop();\n    }   \n}\n\n\/\/ 8:00 to 20:00\nfunction daytime () {\n    \n    var s = map (minute (), 0, 60, 0, 3600) + second();\n    var m = floor (map (minute (), 2, 60, 2, 10));\n    var x = map (s, 0, 3600, 0, 340);\n    var c = map (hour (), 3, 20, 0, 100);\n    \n    \n    color_1 = color (25,206,255 - m);\n    color_2 = color (0,129,150 - m);\n\n    \/\/ ombre\n    for (var y = 0; y &lt; height; y++ ) {\n        n = map (y,0, height, 0, 1);\n        var color_3 = lerpColor (color_1, color_2, n);\n        stroke (color_3);\n        line (0, y, width, y);\n    } \n    \n    \/\/ moving clouds\n    noStroke();\n    fill (255);\n    circle (300 + c,120,50);\n    circle (300 + c,90,50);\n    circle (340 + c,120,50);\n    circle (340 + c,90,50);\n    circle (282 + c,105,50);\n    circle (358 + c,105,50);\n    \n    push();\n    translate (72,80);\n    circle (300 + c,120,50);\n    circle (300 + c,90,50);\n    circle (340 + c,120,50);\n    circle (340 + c,90,50);\n    circle (282 + c,105,50);\n    circle (358 + c,105,50);\n    pop();\n\n    stroke (0);\n    strokeWeight (8);\n    \n    \/\/ walls\n    noFill();\n    rect (width\/2, height\/2 - 180, 200, 200);\n    \n    fill (255,127,80);\n    noStroke();\n    rect (0, height\/6 - 80, 221, 260);\n    rect (height\/2 - 12, 0, 240, 41);\n    rect (0, height\/2 + 24, width, 202);\n    rect (height\/2 + 204, 0, 22, 300);\n\n    \n    \/\/ countertop\n    fill (255);\n    rect (0,width\/2 + 24, width, 30);\n\n    \/\/ cabinets\n    fill (86,60,40);\n    rect (0,width\/2 + 48, width, 200);\n\n    stroke (0);\n    noFill();\n    strokeWeight (2);\n    rect (28,width\/2 + 72, 80, 140);\n    rect (132,width\/2 + 72, 80, 140);\n    rect (236,width\/2 + 72, 80, 140);\n    rect (340,width\/2 + 72, 80, 140);\n\n    \/\/ doorknobs\n    noStroke();\n    fill (212,175,55);\n    circle (90,330,20);\n    circle (150,330,20);\n    circle (300,330,20);\n    circle (360,330,20);\n\n    strokeWeight (8);\n\n    \/\/ canvas border lines\n    line (1,1,1,449);\n    line (1,1,449,1);\n    line (1,449,449,449);\n    line (449,1,449,449);\n\n    \/\/ \"GOOD\"\n    if (second () % 2 == 0) {\n        \n        push();\n        translate (20,40);\n        stroke (0);\n        strokeWeight (4);\n        line (20,20,40,20);\n        line (20,20,20,60); \n        line (20,60,40,60);\n        line (40,60,40,40); \n        line (40,40,30,40); \n\n        line (60,20,80,20);\n        line (60,20,60,60); \n        line (60,60,80,60);\n        line (80,60,80,20);\n\n        push();\n        translate (40,0);\n        line (60,20,80,20);\n        line (60,20,60,60); \n        line (60,60,80,60);\n        line (80,60,80,20); \n        pop();\n\n        line (140,20,140,60);\n        line (140,20,160,40);\n        line (140,60,160,40);\n        pop();\n\n    }\n\n    \/\/ \"DAY!!!\"\n    if (second () % 2 == 1) {\n        \n        push();\n        translate (20,40);\n        stroke (0);\n        strokeWeight (4);\n        line (20,80,20,120);\n        line (20,80,40,100);\n        line (20,120,40,100);\n        \n        line (60,80,80,80);\n        line (60,80,60,120); \n        line (60,100,80,100);\n        line (80,120,80,80); \n\n        line (100,80,110,100); \n        line (110,100,120,80); \n        line (110,100,110,120); \n\n        line (140,80,140,110);\n        line (150,80,150,110);\n        line (160,80,160,110);\n\n        point (140,120);\n        point (150,120);\n        point (160,120);\n        pop();\n    }  \n}\n<\/code><\/pre><\/div><\/body><\/html>\n","protected":false},"excerpt":{"rendered":"","protected":false},"author":765,"featured_media":0,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":[],"categories":[106,56],"tags":[90,81],"_links":{"self":[{"href":"https:\/\/courses.ideate.cmu.edu\/15-104\/f2022\/wp-json\/wp\/v2\/posts\/73858"}],"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\/765"}],"replies":[{"embeddable":true,"href":"https:\/\/courses.ideate.cmu.edu\/15-104\/f2022\/wp-json\/wp\/v2\/comments?post=73858"}],"version-history":[{"count":4,"href":"https:\/\/courses.ideate.cmu.edu\/15-104\/f2022\/wp-json\/wp\/v2\/posts\/73858\/revisions"}],"predecessor-version":[{"id":73864,"href":"https:\/\/courses.ideate.cmu.edu\/15-104\/f2022\/wp-json\/wp\/v2\/posts\/73858\/revisions\/73864"}],"wp:attachment":[{"href":"https:\/\/courses.ideate.cmu.edu\/15-104\/f2022\/wp-json\/wp\/v2\/media?parent=73858"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/courses.ideate.cmu.edu\/15-104\/f2022\/wp-json\/wp\/v2\/categories?post=73858"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/courses.ideate.cmu.edu\/15-104\/f2022\/wp-json\/wp\/v2\/tags?post=73858"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}