{"id":74248,"date":"2022-10-10T13:08:09","date_gmt":"2022-10-10T17:08:09","guid":{"rendered":"https:\/\/courses.ideate.cmu.edu\/15-104\/f2022\/?p=74248"},"modified":"2022-10-10T13:08:09","modified_gmt":"2022-10-10T17:08:09","slug":"p-06-abstract-clock","status":"publish","type":"post","link":"https:\/\/courses.ideate.cmu.edu\/15-104\/f2022\/2022\/10\/10\/p-06-abstract-clock\/","title":{"rendered":"P-06 Abstract Clock"},"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=\"480\" data-height=\"480\" id=\"wp-block-file--media-e4f143c5-2385-455c-8668-a516bc83f7bb\" href=\"https:\/\/courses.ideate.cmu.edu\/15-104\/f2022\/wp-content\/uploads\/2022\/10\/sketch-105.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=\"480\" height=\"480\"><\/iframe><pre class=\"language-javascript\"><code class=\"p5_editor language-javascript\">\/\/ Bridget Doherty\n\/\/ bpdohert@andrew.cmu.edu \n\/\/ 104 Section C\n\n\nfunction setup() {\n    createCanvas(480, 480);\n    frameRate(5);\n    angleMode(DEGREES);\n}\n\nfunction draw() {\n    background(0); \/\/ black background\n    translate(width\/2, height\/2); \/\/ center-based coordinates\n\n    let s = second();\n    let m = minute();\n    let h = hour();\n\n    drawStars(h);\n    drawEarth(s);\n    drawSun(h);\n    \n}\n\nfunction drawSun(h){\n    if (h == 0) { \/\/ eclipse every night from 00:00 - 00:59\n        fill('black');\n        strokeWeight(2);\n        stroke('white');\n        circle(0, 0, 100);\n    } else {\n        fill('yellow'); \/\/ the sun!\n        noStroke();\n        circle(0, 0, 100);\n    }\n}\n\nfunction drawEarth(s){ \/\/ the earth completes a rotation every minute\n    noStroke(); \/\/ and moves every second\n    push();\n    rotate(s*6);\n    fill('blue');\n    circle(150, 0, 70);\n\n    \/\/ triangles to approximate land on earth \n    fill('green');\n    triangle(170, 0, 120, 0, 150, 20);\n    triangle(170, 10, 130, 10, 120, 20);\n    triangle(175, -10, 130, -20, 120, 10);\n\n    \/\/ ellipse to approximate Antarctica\n    fill(220);\n    ellipse(150, -30, 30, 10);\n    pop();\n}\n\nfunction drawStars(h){ \/\/ the amount of stars increases every hour\n    for (var i = 0; i&lt;(h*10); i++){ \/\/ there are no stars between 00:00 and 00:59\n        stroke('white');\n        point(random(-width\/2,width\/2), random(-width\/2, width\/2));\n    }\n}\n<\/code><\/pre><\/div>\n\n\n\n<p><\/p>\n\n\n\n<p>This is obviously based on Earth&rsquo;s rotation around the sun, but condensed so it makes one revolution every minute. The number of stars increase with every hour passed. Every night from 00:00-00:59 there is a solar eclipse which is so naturally impossible with how I&rsquo;ve set up the scene but looks cool nonetheless. <\/p><\/body><\/html>\n","protected":false},"excerpt":{"rendered":"<p>This is obviously based on Earth&rsquo;s rotation around the sun, but condensed so it makes one revolution every minute. The number of stars increase with every hour passed. Every night from 00:00-00:59 there is a solar eclipse which is so naturally impossible with how I&rsquo;ve set up the scene but looks cool nonetheless.<\/p>\n","protected":false},"author":715,"featured_media":0,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":[],"categories":[1],"tags":[126,61],"_links":{"self":[{"href":"https:\/\/courses.ideate.cmu.edu\/15-104\/f2022\/wp-json\/wp\/v2\/posts\/74248"}],"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\/715"}],"replies":[{"embeddable":true,"href":"https:\/\/courses.ideate.cmu.edu\/15-104\/f2022\/wp-json\/wp\/v2\/comments?post=74248"}],"version-history":[{"count":3,"href":"https:\/\/courses.ideate.cmu.edu\/15-104\/f2022\/wp-json\/wp\/v2\/posts\/74248\/revisions"}],"predecessor-version":[{"id":74252,"href":"https:\/\/courses.ideate.cmu.edu\/15-104\/f2022\/wp-json\/wp\/v2\/posts\/74248\/revisions\/74252"}],"wp:attachment":[{"href":"https:\/\/courses.ideate.cmu.edu\/15-104\/f2022\/wp-json\/wp\/v2\/media?parent=74248"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/courses.ideate.cmu.edu\/15-104\/f2022\/wp-json\/wp\/v2\/categories?post=74248"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/courses.ideate.cmu.edu\/15-104\/f2022\/wp-json\/wp\/v2\/tags?post=74248"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}