{"id":74052,"date":"2022-10-08T22:10:55","date_gmt":"2022-10-09T02:10:55","guid":{"rendered":"https:\/\/courses.ideate.cmu.edu\/15-104\/f2022\/?p=74052"},"modified":"2022-10-08T22:10:55","modified_gmt":"2022-10-09T02:10:55","slug":"project-06-7","status":"publish","type":"post","link":"https:\/\/courses.ideate.cmu.edu\/15-104\/f2022\/2022\/10\/08\/project-06-7\/","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><p>This is my duck clock<\/p>\n\n\n\n<p>the amount of ducks corresponds to the 24 hours and they spin once a minute and blink once a second<\/p>\n\n\n\n<div><a class=\"p5_sketch_link\" href=\"https:\/\/courses.ideate.cmu.edu\/15-104\/f2022\/wp-content\/uploads\/2022\/10\/sketch-84.js\" data-width=\"400\" data-height=\"400\">sketch<\/a><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\">\/\/Evette LaComb \n\/\/elacomb@andrew.cmu.edu\n\/\/ Section D \n\/\/ Project 06 - Duck Clock \n\n    \/\/Concept: grid of 5 x 5, 24 ducks, every hour a new duck swims onto screen. \n    \/\/each duck rotates once a minute.\n    \/\/need a function to draw the ducks\n    \/\/need a loop for the ducks- where do they enter from, where do they go each hour\n    \/\/need a transformation to roate each duck around its center axis- part of function\n\/\/ b for bubbles in water:\nvar b = [];\n\/\/angle of roatation:\nvar angleR = 0;\nvar direction = 1;\n\/\/starting array for x position of ducks; \nvar stx = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0];\n\/\/starting array for y position of ducks;\nvar sty = [200, 280, 200, 120, 280, 200, 120, 120, 280, 200, 120, 360, 40, 280, 40, 200, 360, 40, 280, 360, 360, 120, 40, 360];\n\/\/end position array for position of ducks;\nvar endx = [200, 120, 280, 200, 200, 120, 280, 120, 280, 40, 360, 200, 280, 40, 360, 360, 120, 200, 360, 40, 280, 40, 120, 360];\nvar speed = 1;\n\nfunction setup() {\n    createCanvas(400, 400);\n    \/\/ object and Array for water texture: \n    for (i = 0; i &lt; 1000; i ++) {\n        b[i] = new Object();\n        b[i].c = random(255);\n        b[i].x = random(5, width-5);\n        b[i].y = random(5, height-5);\n        \/\/speed that water moves: \n        b[i].dx = random(-0.1, 0.1);\n        b[i].dy = random(-0.1, 0.1);\n    }  \n    frameRate(60);\n}\n\nfunction draw() {\n    background(\"lightblue\");\n    var h = hour();\n    \/\/loops to create water texture\n    for (i = 0; i &lt;= 24; i ++) {\n        bubble(b[i]);\n        update_bubble(b[i]);\n    }\n    \/\/loops t ocreate ducks corresponding to arrays \n    for (i = 0; i &lt;= hour() - 1; i ++){\n        duck(stx[i], sty[i]);\n        stx[i] += speed;\n        if(stx[i] &gt;= endx[i]){ stx[i] = endx[i]};\n    }\n    \/\/beach details:\n    push();\n    rotate(radians(-45));\n    fill(255, 255, 255, 60);\n    ellipse(0, 0, 320, 150);\n    fill(200, 190, 160)\n    ellipse(0, 0, 300, 130)\n    pop();\n    stroke(0);\n    strokeWeight(2);\n    \/\/text('Current hour:\\n' + h, 5, 50);\n}\n\n\nfunction duck(stx, sty){\n\/\/duck stuff: \n    \/\/draw duck at coordinate x, y\n    push();\n    translate(stx, sty);\n    \/\/rotate the duck; \n    rotate(radians(angleR));\n    angleR += 0.007;\n    \/\/cosmetics for duck:\n    noStroke();\n    fill(\"lightBlue\");\n    ellipse(0, 0, 80, 70);\n    fill(230);\n    ellipse(0, 0, 70, 60);\n    fill(230);\n    triangle(10, 30, 10, -30, 45, 0)\n    fill(\"orange\");\n    ellipse(-25, 0, 30);\n    fill(\"white\");\n    \/\/stuff to make ducks blink according to seconds \n    ellipse(-10, 0, 40);\n    var s = second();\n    if (s % 2 == 0){\n        fill(\"black\");\n    }else{\n        fill(\"white\");\n    }\n    ellipse(-15, 17, 5);\n    ellipse(-15, -17, 5);\n    pop();\n\n}\n\nfunction bubble(b){\n\/\/cosmetics of water texture:\n    noFill();\n    strokeWeight(10);\n    stroke(255, 255, 255, 20)\n    ellipse(b.x, b.y, 70, 70);\n}\n\nfunction update_bubble(b){\n\/\/tecnical stuff for water texture:\n    \/\/water movement:\n    b.x += b.dx;\n    b.y += b.dy;\n    \/\/if reach edge of screen change direction: \n    if ( b.x &gt;= width || b.x &lt; 0){\n        b.dx = -b.dx;\n    }\n\n    if (b.y &gt;= height || b.y &lt; 0){\n        b.dy = -b.dy;\n    }\n}\n<\/code><\/pre><\/div><\/body><\/html>\n","protected":false},"excerpt":{"rendered":"<p>This is my duck clock the amount of ducks corresponds to the 24 hours and they spin once a minute and blink once a second<\/p>\n","protected":false},"author":732,"featured_media":0,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":[],"categories":[106,58,1],"tags":[],"_links":{"self":[{"href":"https:\/\/courses.ideate.cmu.edu\/15-104\/f2022\/wp-json\/wp\/v2\/posts\/74052"}],"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\/732"}],"replies":[{"embeddable":true,"href":"https:\/\/courses.ideate.cmu.edu\/15-104\/f2022\/wp-json\/wp\/v2\/comments?post=74052"}],"version-history":[{"count":4,"href":"https:\/\/courses.ideate.cmu.edu\/15-104\/f2022\/wp-json\/wp\/v2\/posts\/74052\/revisions"}],"predecessor-version":[{"id":74065,"href":"https:\/\/courses.ideate.cmu.edu\/15-104\/f2022\/wp-json\/wp\/v2\/posts\/74052\/revisions\/74065"}],"wp:attachment":[{"href":"https:\/\/courses.ideate.cmu.edu\/15-104\/f2022\/wp-json\/wp\/v2\/media?parent=74052"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/courses.ideate.cmu.edu\/15-104\/f2022\/wp-json\/wp\/v2\/categories?post=74052"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/courses.ideate.cmu.edu\/15-104\/f2022\/wp-json\/wp\/v2\/tags?post=74052"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}