Created
November 17, 2015 16:05
-
-
Save claytical/2175c93e082aca84b614 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| var x; | |
| var y; | |
| var adjustedX; | |
| var adjustedY; | |
| var angle = 0; | |
| var diameter; | |
| function setup() { | |
| createCanvas(windowWidth,windowHeight); | |
| x = width/2; | |
| y = height/2; | |
| diameter = 300; | |
| } | |
| function draw() { | |
| background(255,255,255); | |
| // origin + cosine of the angle times half the diameter | |
| adjustedX = x + cos( radians(angle) )* (diameter/2); | |
| // origin + sin of the angle times half of the diameter | |
| adjustedY = y + sin(radians(angle))*(diameter/2); | |
| //this draws a circular motion in red | |
| fill(255,0,0); | |
| ellipse(adjustedX, adjustedY, 10, 10); | |
| //this is just the cosine in green | |
| fill(0,255,0); | |
| ellipse(adjustedX, y, 10, 10); | |
| //this is just the sin in blue | |
| fill(0,0,255); | |
| ellipse(x, adjustedY, 10, 10); | |
| angle++; | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment