mirror of
https://github.com/irmen/prog8.git
synced 2024-11-01 00:10:48 +00:00
e35cfd4971
Unfortunately a few routines (minf, maxf, clampf) remain unchanged, because removing the 'f' would make them clash with a builtin function. floats.rndf -> floats.rnd floats.parse_f -> floats.parse floats.rndseedf -> floats.rndseed floats.print_f -> floats.print floats.str_f -> floats.tostr
48 lines
1.2 KiB
Lua
48 lines
1.2 KiB
Lua
%import textio
|
|
%import floats
|
|
%zeropage basicsafe
|
|
|
|
main {
|
|
const uword width = 60
|
|
const uword height = 50
|
|
const ubyte max_iter = 16
|
|
|
|
sub start() {
|
|
txt.print("calculating mandelbrot fractal...\n\n")
|
|
cbm.SETTIM(0,0,0)
|
|
|
|
ubyte pixelx
|
|
ubyte pixely
|
|
|
|
for pixely in 0 to height-1 {
|
|
float yy = (pixely as float)/0.40/height - 1.3
|
|
|
|
for pixelx in 0 to width-1 {
|
|
float xx = (pixelx as float)/0.32/width - 2.2
|
|
|
|
float xsquared = 0.0
|
|
float ysquared = 0.0
|
|
float x = 0.0
|
|
float y = 0.0
|
|
ubyte iter = 0
|
|
|
|
while iter<max_iter and xsquared+ysquared<4.0 {
|
|
y = x*y*2.0 + yy
|
|
x = xsquared - ysquared + xx
|
|
xsquared = x*x
|
|
ysquared = y*y
|
|
iter++
|
|
}
|
|
txt.color2(1, max_iter-iter)
|
|
txt.spc()
|
|
}
|
|
txt.nl()
|
|
}
|
|
|
|
float duration = (cbm.RDTIM16() as float) / 60
|
|
txt.print("\nfinished in ")
|
|
floats.print(duration)
|
|
txt.print(" seconds!\n")
|
|
}
|
|
}
|