{"id":74467,"date":"2022-10-15T18:18:07","date_gmt":"2022-10-15T22:18:07","guid":{"rendered":"https:\/\/courses.ideate.cmu.edu\/15-104\/f2022\/?p=74467"},"modified":"2022-10-15T18:18:07","modified_gmt":"2022-10-15T22:18:07","slug":"project-07-curves-3","status":"publish","type":"post","link":"https:\/\/courses.ideate.cmu.edu\/15-104\/f2022\/2022\/10\/15\/project-07-curves-3\/","title":{"rendered":"Project 07 &#8211; 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><p>Using a rose curve function I created two overlapping shapes. Moving the cursor to the left side of the canvas decreases the petal count and changes its rotation direction to counterclockwise; to the left, the petal count increases, and the rotation direction is clockwise. Clicking the canvas will pause its motion.<\/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-123.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\">\/\/ Emily Franco\n\/\/ Section C\n\/\/ efranco@andrew.cmu.edu\n\/\/ Project-07\n \n\/\/num of petals\nvar n=3;\n\n\/\/track move clickes\nvar state = 0;\n\/\/tracks when petals function runs\nvar petalState =0;\n\n\/\/store x and y cordinates of petal\nvar petalPointX = [];\nvar petalPointY = [];\n\nfunction setup() {\n    createCanvas(400, 400);\n }\n\nfunction draw() { \n    background (0);\n\n    \/\/move origin to center canvas\n    translate(width\/2,height\/2);\n\n    \/\/outter rose\n    fill(167,1187,232,120);\n    rose(n,200,5);\n\n    \/\/inner rose\n    fill(252,219,3,120);\n    rose(-n,120,3);\n\n\n    petals();\n} \n\n\/\/only call petals mouse house is clicked    \nfunction mousePressed(){\n    if(petalState == 0){\n        state = 1;\n    }\n\n    if(petalState == 1){\n        state = 0;\n        petalState = 0;\n    }\n}\n\n\/\/make rose shape\nfunction rose(n,radius,rate){\n    var x; \n    var y;\n    var newRad;\n    \/\/make rose shape\n    beginShape();\n    for (var a=0; a&lt;=360; a++){\n        newRad = radius*sin(n*radians(a));\n        x = newRad*cos(radians(a)); \n        y = newRad*sin(radians(a)); \n        petalPointX[a] = x;\n        petalPointY[a] = y;\n        vertex (x,y);\n    }\n    endShape();\n    petalLines(rate);\n}\n\n\/\/draw lines at determine increments from center to petal coordinate\nfunction petalLines(rate){\n    stroke(\"black\");\n    for(var i=0; i&lt;=petalPointX.length;i = i+rate){\n        line (petalPointX[i],petalPointY[i],0,0);\n    }\n            \n}\n\n\/\/add or subtract petal depending on mouse location\nfunction petals(){\n    if(state==1){\n        if(mouseX&gt;=width\/2){\n             n=n+0.01;\n        }if(mouseX&lt;width\/2){\n             n=n-0.01;\n        }\n        \n        petalState=1;\n    }   \n}\n\n\n<\/code><\/pre><\/div><\/body><\/html>\n","protected":false},"excerpt":{"rendered":"<p>Using a rose curve function I created two overlapping shapes. Moving the cursor to the left side of the canvas decreases the petal count and changes its rotation direction to counterclockwise; to the left, the petal count increases, and the rotation direction is clockwise. Clicking the canvas will pause its motion. sketch \/\/ Emily Franco &hellip; <a href=\"https:\/\/courses.ideate.cmu.edu\/15-104\/f2022\/2022\/10\/15\/project-07-curves-3\/\" class=\"more-link\">Continue reading<span class=\"screen-reader-text\"> &#8220;Project 07 &#8211; Curves&#8221;<\/span><\/a><\/p>\n","protected":false},"author":719,"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\/f2022\/wp-json\/wp\/v2\/posts\/74467"}],"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\/719"}],"replies":[{"embeddable":true,"href":"https:\/\/courses.ideate.cmu.edu\/15-104\/f2022\/wp-json\/wp\/v2\/comments?post=74467"}],"version-history":[{"count":5,"href":"https:\/\/courses.ideate.cmu.edu\/15-104\/f2022\/wp-json\/wp\/v2\/posts\/74467\/revisions"}],"predecessor-version":[{"id":75175,"href":"https:\/\/courses.ideate.cmu.edu\/15-104\/f2022\/wp-json\/wp\/v2\/posts\/74467\/revisions\/75175"}],"wp:attachment":[{"href":"https:\/\/courses.ideate.cmu.edu\/15-104\/f2022\/wp-json\/wp\/v2\/media?parent=74467"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/courses.ideate.cmu.edu\/15-104\/f2022\/wp-json\/wp\/v2\/categories?post=74467"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/courses.ideate.cmu.edu\/15-104\/f2022\/wp-json\/wp\/v2\/tags?post=74467"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}