diff options
| author | Cody <cody@codyq.dev> | 2023-07-20 18:07:48 -0500 |
|---|---|---|
| committer | Cody <cody@codyq.dev> | 2023-07-20 18:07:48 -0500 |
| commit | 7c53e65cad365ec112d2ec1bd9c3091dbed05720 (patch) | |
| tree | dbcac7754608949e6f454726d56b9cea427468d8 /mandelbrot.c | |
| parent | ee2133a13d61b3b3fb8fcf88f9c9781debd77d9e (diff) | |
| download | sloth-7c53e65cad365ec112d2ec1bd9c3091dbed05720.tar.gz | |
Changes
Diffstat (limited to 'mandelbrot.c')
| -rw-r--r-- | mandelbrot.c | 32 |
1 files changed, 32 insertions, 0 deletions
diff --git a/mandelbrot.c b/mandelbrot.c new file mode 100644 index 0000000..a6eff9e --- /dev/null +++ b/mandelbrot.c @@ -0,0 +1,32 @@ +#include <stdio.h> + +int main() { + float size = 800.0; + float maxVal = 4.0; + float maxIter = 50.0; + float plane = 4.0; + int x = 0; + while (x < size) { + int y = 0; + while (y < size) { + float cReal = (x * plane / size) - 2.0; + float cImg = (y * plane / size) - 2.0; + float zReal = 0.0; + float zImg = 0.0; + float count = 0.0; + while ((zReal * zReal + zImg * zImg) <= maxVal && count < maxIter) { + float temp = (zReal * zReal) - (zImg * zImg) + cReal; + zImg = 2.0 * zReal * zImg + cImg; + zReal = temp; + count = count + 1; + if (count == maxIter) { + printf("\x1b[%d;%dH", x, y); + printf("█"); + } + } + y = y + 1; + } + x = x + 1; + } + return 0; +} |
