{"id":67928,"date":"2021-10-17T20:28:27","date_gmt":"2021-10-18T00:28:27","guid":{"rendered":"https:\/\/courses.ideate.cmu.edu\/15-104\/f2021\/?p=67928"},"modified":"2021-10-17T20:28:27","modified_gmt":"2021-10-18T00:28:27","slug":"project-07-composition-with-curves-9","status":"publish","type":"post","link":"https:\/\/courses.ideate.cmu.edu\/15-104\/f2021\/2021\/10\/17\/project-07-composition-with-curves-9\/","title":{"rendered":"Project 07: Composition with Curves"},"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\" href=\"https:\/\/courses.ideate.cmu.edu\/15-104\/f2021\/wp-content\/uploads\/2021\/10\/sketch-122.js\">sketch<\/a><iframe src=\"https:\/\/courses.ideate.cmu.edu\/15-104\/f2021\/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\">var nPoints = 100;\nvar EPITROCHOID = 0; \nvar CRANIOID = 1; \n\nvar curveMode = EPITROCHOID;\n\n\nfunction setup() {\n    createCanvas(480, 480);\n    frameRate(5);\n}\n\n\nfunction draw() {\n    background(200,200,255);\n    \n    \/\/ curve\n    push();\n    translate(width \/ 2, height \/ 2);\n    switch (curveMode) {\n    case EPITROCHOID:\n        drawEpitrochoidCurve();\n        break;\n    case CRANIOID:\n        drawCranioidCurve();\n        break;\n    }\n    pop();\n\n    \/\/moving shape\n    let x = mouseX;\n     let y = mouseY;\n     let ix = width - mouseX;  \/\/ Inverse X\n    let iy = height - mouseY; \/\/ Inverse Y\n    ellipse(x, height\/2, y, y);\n     fill(255);\n     noStroke();\n    ellipse(ix, height\/2, iy, iy);\n}\n\nfunction drawEpitrochoidCurve() {\n\n    var x;\n    var y;\n    \n    var a = mouseY;\n    var b = mouseX;\n\n    noStroke();\n    fill(255,200,200);\n\n    beginShape();\n    for (var i = 0; i &lt; nPoints; i++) {\n        var t = map(i, 0, nPoints, 0, TWO_PI);\n        \n        x = 4 * b * cos (t)* cos (t)* cos (t);\n        y = a * sin (t) *sin (t)* sin (t);\n        \n      vertex(x, y);\n    }\n    endShape(CLOSE);\n    \n}\n<\/code><\/pre><\/div><\/body><\/html>\n","protected":false},"excerpt":{"rendered":"","protected":false},"author":664,"featured_media":0,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":[],"categories":[108,57],"tags":[],"_links":{"self":[{"href":"https:\/\/courses.ideate.cmu.edu\/15-104\/f2021\/wp-json\/wp\/v2\/posts\/67928"}],"collection":[{"href":"https:\/\/courses.ideate.cmu.edu\/15-104\/f2021\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/courses.ideate.cmu.edu\/15-104\/f2021\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/courses.ideate.cmu.edu\/15-104\/f2021\/wp-json\/wp\/v2\/users\/664"}],"replies":[{"embeddable":true,"href":"https:\/\/courses.ideate.cmu.edu\/15-104\/f2021\/wp-json\/wp\/v2\/comments?post=67928"}],"version-history":[{"count":1,"href":"https:\/\/courses.ideate.cmu.edu\/15-104\/f2021\/wp-json\/wp\/v2\/posts\/67928\/revisions"}],"predecessor-version":[{"id":67931,"href":"https:\/\/courses.ideate.cmu.edu\/15-104\/f2021\/wp-json\/wp\/v2\/posts\/67928\/revisions\/67931"}],"wp:attachment":[{"href":"https:\/\/courses.ideate.cmu.edu\/15-104\/f2021\/wp-json\/wp\/v2\/media?parent=67928"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/courses.ideate.cmu.edu\/15-104\/f2021\/wp-json\/wp\/v2\/categories?post=67928"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/courses.ideate.cmu.edu\/15-104\/f2021\/wp-json\/wp\/v2\/tags?post=67928"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}