2018-09-18 21:14:32 +00:00
|
|
|
%option enable_floats
|
|
|
|
|
|
|
|
~ main {
|
|
|
|
|
|
|
|
sub start() -> () {
|
|
|
|
|
2018-09-19 23:13:21 +00:00
|
|
|
const word width = 320
|
|
|
|
const word height = 256
|
2018-09-18 21:14:32 +00:00
|
|
|
word pixelx
|
|
|
|
byte pixely
|
|
|
|
float xx
|
|
|
|
float yy
|
|
|
|
float x
|
|
|
|
float y
|
|
|
|
float x2
|
|
|
|
byte iter
|
|
|
|
word plotx
|
|
|
|
byte ploty
|
|
|
|
|
2018-09-19 00:41:35 +00:00
|
|
|
_vm_write_str("Calculating Mandelbrot fractal, have patience...\n")
|
2018-09-18 21:14:32 +00:00
|
|
|
_vm_gfx_clearscr(11)
|
|
|
|
|
2018-09-19 23:13:21 +00:00
|
|
|
for pixely in 0 to height-1 {
|
|
|
|
for pixelx in 0 to width-1 {
|
|
|
|
xx = pixelx/width/3+0.2
|
|
|
|
yy = pixely/height/3.6+0.4
|
2018-09-18 21:14:32 +00:00
|
|
|
|
2018-09-19 23:13:21 +00:00
|
|
|
x = 0.0
|
|
|
|
y = 0.0
|
2018-09-18 21:14:32 +00:00
|
|
|
|
|
|
|
for iter in 0 to 31 {
|
2018-09-19 23:13:21 +00:00
|
|
|
if (x*x + y*y > 4) break
|
2018-09-18 21:14:32 +00:00
|
|
|
x2 = x*x - y*y + xx
|
2018-09-19 23:13:21 +00:00
|
|
|
y = x*y*2 + yy
|
|
|
|
x = x2
|
2018-09-18 21:14:32 +00:00
|
|
|
}
|
|
|
|
|
2018-09-19 23:13:21 +00:00
|
|
|
_vm_gfx_pixel(pixelx, pixely, iter)
|
|
|
|
; plotx = pixelx*2
|
|
|
|
; ploty = pixely*2
|
|
|
|
; _vm_gfx_pixel(plotx, ploty, iter)
|
|
|
|
; _vm_gfx_pixel(plotx+1, ploty, iter)
|
|
|
|
; _vm_gfx_pixel(plotx, ploty+1, iter)
|
|
|
|
; _vm_gfx_pixel(plotx+1, ploty+1, iter)
|
2018-09-18 21:14:32 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
_vm_gfx_text(5, 5, 7, "Mandelbrot Fractal")
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|