{"id":72174,"date":"2022-09-17T22:19:02","date_gmt":"2022-09-18T02:19:02","guid":{"rendered":"https:\/\/courses.ideate.cmu.edu\/15-104\/f2022\/?p=72174"},"modified":"2022-09-17T22:19:02","modified_gmt":"2022-09-18T02:19:02","slug":"project-03-cube-y","status":"publish","type":"post","link":"https:\/\/courses.ideate.cmu.edu\/15-104\/f2022\/2022\/09\/17\/project-03-cube-y\/","title":{"rendered":"project 03: cube-y"},"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>the hardest part for me was sticking with an idea, and resisting the urge to scrap my code constantly. it was also tricky to keep my variables in check without rewriting them with each function&hellip; anyway, try moving your mouse around the canvas and clicking!<\/p>\n\n\n\n<div><a class=\"p5_sketch_link\" href=\"https:\/\/courses.ideate.cmu.edu\/15-104\/f2022\/wp-content\/uploads\/2022\/09\/sketch-292.js\" data-width=\"600\" data-height=\"450\">sketch<\/a><iframe src=\"https:\/\/courses.ideate.cmu.edu\/15-104\/f2022\/wp-content\/plugins\/p5-embedder\/p5_iframe.html\" class=\"p5_exampleFrame\" width=\"600\" height=\"450\"><\/iframe><pre class=\"language-javascript\"><code class=\"p5_editor language-javascript\">\/\/ Jaden Luscher\n\/\/ section A\n\/\/ project 03\n\nvar x = 0;\nvar y = 0;\nvar square1 = 0;\nvar square2 = 0;\nvar rot1 = 0;\nvar rot2 = 0;\nvar col = 200;\n\nfunction setup() {\n    createCanvas(600, 450);\n    background(200,200,100);\n}\n\nfunction draw() {\n  background(200,200,100);\n  rectMode(CENTER);\n  noStroke();\n  fill(col);\n  translate(width\/2, height\/2); \/\/ move origin to center of canvas\n\n  square1 = (mouseX + mouseY) \/ 2; \/\/ move mouse to change square size\n  rot1 += 0.01; \/\/ makes square 1 spin\n  rotate(rot1);\n  rect(x, y, square1, square1); \/\/ center square (square 1)\n\n  square2 = (mouseX - mouseY); \/\/ size of four squares differs from square 1\n  if(mouseX &gt; mouseY) {\n    rot2 = 2 * rot1; \/\/ spins clockwise\n  } else {\n    rot2 = -2 * rot1; \/\/ spins counter clockwise\n  }\n  rotate(rot2);\n  rect(x + square2, y + square2, square2, square2);\n  rect(x - square2, y - square2, square2, square2);\n  rect(x + square2, y - square2, square2, square2);\n  rect(x - square2, y + square2, square2, square2); \/\/ four squares at corners\n\n  if (mouseIsPressed) { \/\/ squares \"jitter\" & turn white\n    rot1 *= -1;\n    col = 255;\n  } else {\n    col = 0;\n  }\n\n  print(\"square2 = \", square2);\n\n}\n<\/code><\/pre><\/div><\/body><\/html>\n","protected":false},"excerpt":{"rendered":"<p>the hardest part for me was sticking with an idea, and resisting the urge to scrap my code constantly. it was also tricky to keep my variables in check without rewriting them with each function&hellip; anyway, try moving your mouse around the canvas and clicking! sketch \/\/ Jaden Luscher \/\/ section A \/\/ project 03 &hellip; <a href=\"https:\/\/courses.ideate.cmu.edu\/15-104\/f2022\/2022\/09\/17\/project-03-cube-y\/\" class=\"more-link\">Continue reading<span class=\"screen-reader-text\"> &#8220;project 03: cube-y&#8221;<\/span><\/a><\/p>\n","protected":false},"author":741,"featured_media":0,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":[],"categories":[100,55],"tags":[],"_links":{"self":[{"href":"https:\/\/courses.ideate.cmu.edu\/15-104\/f2022\/wp-json\/wp\/v2\/posts\/72174"}],"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\/741"}],"replies":[{"embeddable":true,"href":"https:\/\/courses.ideate.cmu.edu\/15-104\/f2022\/wp-json\/wp\/v2\/comments?post=72174"}],"version-history":[{"count":3,"href":"https:\/\/courses.ideate.cmu.edu\/15-104\/f2022\/wp-json\/wp\/v2\/posts\/72174\/revisions"}],"predecessor-version":[{"id":72179,"href":"https:\/\/courses.ideate.cmu.edu\/15-104\/f2022\/wp-json\/wp\/v2\/posts\/72174\/revisions\/72179"}],"wp:attachment":[{"href":"https:\/\/courses.ideate.cmu.edu\/15-104\/f2022\/wp-json\/wp\/v2\/media?parent=72174"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/courses.ideate.cmu.edu\/15-104\/f2022\/wp-json\/wp\/v2\/categories?post=72174"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/courses.ideate.cmu.edu\/15-104\/f2022\/wp-json\/wp\/v2\/tags?post=72174"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}