Basic256 Programme Barnsley Farn
Quellcode
Basiswissen
Das untenstehende Programm kann direkt in Basic256 ausgeführt werden.
Quellcode
# Basic256 Programme Barnsley Farn
#
# Basic256-Quellcode zu Erzeugung eines fraktalen Barnsley Farns
#
cls # Löscht Bildschirm
clg # Löscht Grafikausgabe
x=0
y=0
counter=0
while counter < 1000000
zufallszahl=rand*100
# The following coordinate transformation is chosen 1% of the time:
if zufallszahl < 1 then
x = 0
y = 0.16*y
endif
# The nex coordinate transformation is chosen 85% of the time:
if zufallszahl < 86 and zufallszahl > 1 then
x = 0.85*x + 0.04*y
y = (-1)*0.04*x+0.85*y+1.6
endif
# The next coordinate transformation is chosen 7% of the time:
if zufallszahl < 93 and zufallszahl > 86 then
x = 0.2*x - 0.26*y
y = 0.23*x+0.22*y+1.6
endif
# The last coordinate transformation is chosen 7% of the time:
if zufallszahl > 93 then
x = (-1)*0.15*x+0.28*y
y = 0.26*x+0.24*y+0.44
endif
xplot=x*400
yplot=y*400-200
plot xplot,yplot
# print counter
counter = counter+1
end while