diff options
| author | nic-gaffney <gaffney_nic@protonmail.com> | 2023-04-14 04:57:53 -0500 |
|---|---|---|
| committer | nic-gaffney <gaffney_nic@protonmail.com> | 2023-04-14 04:57:53 -0500 |
| commit | 19fefeb732d559195edb01ebc36170c0cf9a0308 (patch) | |
| tree | 681bcb8d9d507024d15814032d3fbb1674677ddc /examples | |
| parent | f6e14f4b2b15b0ace8ed312252ae107f139bd33d (diff) | |
| download | sloth-19fefeb732d559195edb01ebc36170c0cf9a0308.tar.gz | |
eepy
Diffstat (limited to 'examples')
| -rw-r--r-- | examples/mandelbrot.sloth | 24 |
1 files changed, 24 insertions, 0 deletions
diff --git a/examples/mandelbrot.sloth b/examples/mandelbrot.sloth new file mode 100644 index 0000000..bc95e2f --- /dev/null +++ b/examples/mandelbrot.sloth @@ -0,0 +1,24 @@ +val size: int = 200; +val maxVal: float = 4.0; +val maxIter: int = 50; +val plane: float = 4.0; + +for x in 0 .. size { + for y in 0 .. size { + var cReal: float = (x * plane / size) - 2; + var cImg: float = (y * plane / size) - 2; + var zReal: float = 0; + var zImg: float = 0; + var count: float = 0; + while (zReal * zReal + zImg * zImg) <= maxVal && count < 4{ + var temp: float = (zReal * zReal) - (zImg * zImg) + cReal; + zImg = 2 * zReal * zImg + cImg; + zReal = temp; + count += 1; + } + if count == maxIter { + term_setpos(x, y); + print("*"); + } + } +} |
