Created
March 11, 2021 11:30
-
-
Save bogoreh/c838fbe083b6331bbf062826597c2c36 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
| //converting mode to degrees | |
| angleMode = "radians"; | |
| //displaying the slinky on the canvas | |
| var drawSlinky = function(centerX, startY, endY) { | |
| noFill(); | |
| colorMode(HSB); | |
| strokeWeight(2); | |
| ellipseMode(CENTER); | |
| var overlap = 0.8; | |
| var space = (endY/overlap - startY)/30; | |
| for (var i = 0; i < 30; i++) { | |
| stroke(i*9, 200, 255); | |
| ellipse(centerX, i*space*overlap + startY, 60, space); | |
| } | |
| }; | |
| draw = function() { | |
| background(255); | |
| //applying simple harmonic motion (oscillating) | |
| var y = sin(TWO_PI * frameCount /80); | |
| var m = map(y, -1, 1, 200, 400); | |
| drawSlinky(width/2, 10, m); | |
| }; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment