Created
October 10, 2023 05:48
-
-
Save keiya/f74e1856867d81b68f493d25d3657e50 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
let fibSeq = [0, 1]; | |
function setup() { | |
createCanvas(400, 400); | |
for (let i = 2; i < 1000; i++) { | |
fibSeq[i] = fibSeq[i-1] + fibSeq[i-2]; // Generating Fibonacci sequence | |
} | |
} | |
function draw() { | |
background(0); | |
let n = 0; | |
let radius = 5; | |
let c = 5; // Scaling factor | |
noFill(); | |
let index = 0; // Index for accessing Fibonacci sequence | |
while (radius < width/2) { | |
let angle = n * TWO_PI * ((1 + Math.sqrt(5)) / 2); // Golden ratio | |
let x = width/2 + cos(angle) * radius; | |
let y = height/2 + sin(angle) * radius; | |
colorMode(HSB, 100); | |
stroke(noise(x*0.1,y*0.1)*100, 30, n%100); // Use Fibonacci sequence for color | |
ellipse(x, y, 5, 5); | |
n++; | |
radius = c * sqrt(n); | |
index++; // Increment index for Fibonacci sequence | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment