R


Basic256 Programme Mandelbrotalgorithmus


Quellcode


Basiswissen


Das untenstehende Programm kann direkt in Basic256 ausgeführt werden.

Quellcode


# Basic256 Programme Mandelbrotalgorithmus
#
# Credits to https://rosettacode.org

Rechenanleitung zur Erzeugung von Mandelbrot-Figuren (Fraktale).

fastgraphics

graphsize 384,384
refresh
kt=319 : m = 4.0
xmin=2.1 : xmax=-0.6 : ymin=-1.35 : ymax=1.35
dx=(xmax-xmin)/graphwidth : dy=(ymax-ymin)/graphheight

for x=0 to graphwidth
jx = xmin+x*dx
for y=0 to graphheight
jy = ymin+y*dy
k = 0 : wx = 0.0 : wy = 0.0
do
tx = wx*wx-(wy*wy+jx)
ty = 2.0*wx*wy+jy
wx = tx
wy = ty
r = wx*wx+wy*wy
k = k+1
until r>m or k>kt

if k>kt then
color black
else
if k<16 then color k*8,k*8,128+k*4
if k>=16 and k<64 then color 128+k-16,128+k-16,192+k-16
if k>=64 then color kt-k,128+(kt-k)/2,kt-k
end if
plot x,y
next y
refresh
next x
imgsave "Mandelbrot_BASIC-256.png", "PNG"