Created
October 15, 2022 12:34
-
-
Save terremoth/8318583b0cfd74d9084b6f592608c143 to your computer and use it in GitHub Desktop.
Mandelbrot Algorithm
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
let canvas = document.getElementById('universe').getContext('2d') | |
let atom = (x,y,c) => {canvas.fillStyle = c; canvas.fillRect(x,y,3,3)}; | |
window.CP.PenTimer.MAX_TIME_IN_LOOP_WO_EXIT = 10000; | |
for (y=1; y < 1000; y++) { | |
for (x=1; x < 1000; x++) { | |
dx = (x-500)/200 | |
dy = (y-500)/200 | |
a = dx | |
b = dy | |
for (t = 1; t < 200; t++) { | |
d = (a*a) - (b*b) + dx | |
b = 2*(a*b) + dy | |
a = d | |
H = d > 200 | |
if (H) { | |
atom(x,y, 'rgb('+t*5+','+t*2+','+ t*0.9 +')'); | |
break; | |
} | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment