aboutsummaryrefslogtreecommitdiff
path: root/mandelbrot.py
diff options
context:
space:
mode:
authornic-gaffney <gaffney_nic@protonmail.com>2023-06-27 01:59:59 -0500
committernic-gaffney <gaffney_nic@protonmail.com>2023-06-27 01:59:59 -0500
commit29bdd10ee3621ed875bfa34a0faa42c35a1e39ed (patch)
tree97f7605b53fc77277d98d5ea8127391edefc4ab5 /mandelbrot.py
parent9c2d8f5a10b8affd604cec6e394d43514ef93ca1 (diff)
downloadsloth-29bdd10ee3621ed875bfa34a0faa42c35a1e39ed.tar.gz
Standard library methinks
Diffstat (limited to 'mandelbrot.py')
-rw-r--r--mandelbrot.py22
1 files changed, 22 insertions, 0 deletions
diff --git a/mandelbrot.py b/mandelbrot.py
new file mode 100644
index 0000000..82aa65c
--- /dev/null
+++ b/mandelbrot.py
@@ -0,0 +1,22 @@
+size = 200
+
+# constants:
+MaxValue = 4
+MaxIterations = 50
+planeWidth = 4
+
+for x in range(0, size):
+ for y in range(0, size): # for each pixel do:
+ cReal = (x * planeWidth / size) - 2
+ cImg = (y * planeWidth / size) - 2
+ zReal = 0
+ zImg = 0
+ count = 0
+ while (zReal*zReal + zImg*zImg) <= MaxValue and count < MaxIterations:
+ temp = (zReal * zReal) - (zImg * zImg) + cReal
+ zImg = 2 * zReal * zImg + cImg
+ zReal = temp
+ count += 1
+
+ if count == MaxIterations:
+ print(f"\x1b[{x};{y}H*")