Last active
May 3, 2020 19:26
-
-
Save georgesb/69c2f1c619a2fc47727c85daabb19079 to your computer and use it in GitHub Desktop.
Golden Spiral
This file contains 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
<script src="https://cdn.jsdelivr.net/npm/p5"></script> | |
<script src="script.js"></script> |
This file contains 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
function setup() { | |
let x, y; | |
let fibonacci = [1, 1, 2, 3, 5, 8, 13, 21]; | |
createCanvas(650, 450); | |
translate(40, 40); | |
for (let i = 7; i >= 0; i--) { | |
x = fibonacci[i] * 17; | |
y = x; | |
stroke('red'); | |
rect(0, 0, x, y); | |
push(); | |
translate(x, 0); | |
stroke('black'); | |
arc(0, 0, x * 2, y * 2, radians(90), radians(180)); | |
pop(); | |
translate(x, y); | |
rotate(radians(270)); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment