Mira.bas


Title: Mira
Description: Generate Mira fractals.

Category: Graphics/Fractals
Copyright: Martin Latter
Email: martinlatter@hotmail.com
Created: 2 January 2005
Version: 1.0
Sbver: 0.8


''' Mira fractals
'' Martin Latter
'' Converted to SB from my old 1992 version in Archimedes BASIC - SB and modern computers thankfully plot a bit faster.
'' (Run/f9 to replot)

dim ca(6)
randomize
a=rnd
b=0.9998
c=2-2*a
dots=12000
x=j=0
y=rnd*12+0.1
col=2

for
pc=0 to 5
ca(pc)=round(rnd*15)
next

for
i=0 to dots

z=x
x=b*y+j
j=a*x+c*(x^2)/(1+x^2)
y=j-z

xp=(x*20)+300
yp=(y*20)+300

if i>1000 then col=ca(0)
if i>3000 then col=ca(1)
if i>5000 then col=ca(2)
if i>7000 then col=ca(3)
if i>9000 then col=ca(4)
if i>11000 then col=ca(5)

pset xp,yp,col

next
i
'

Comments

This should offer more variety, color and convenience to original code.


'Mira.bas for SmallBASIC 0.12.8 [B+=MGA] update 2017-02-20

''update Mira fractals from SmallBASIC
'' Martin Latter
'' Converted to SB from my old 1992 version in Archimedes BASIC
'' - SB and modern computers thankfully plot a bit faster.

'In most Mira all the interesting stuff happens immediately.

'This code will stay with one Mira until you press a key

randomize
xc = xmax/2
yc = ymax/2
dots = 10000 'for one round on Mira
dim ca(int(dots/100))

while 1
'set round
a = rnd
b = rnd * .008 + .993 'originally held const .9998
c = 2 - 2 * a
x = j = 0
y = rnd * 12 + .1

'set palette (originally only 6 colors)
for pc = 0 to int(dots/100)
red = int(rnd*2)*(rnd*195+60)
green = int(rnd*2)*(rnd*195+60)
blue = int(rnd*2)*(rnd*195+60)
ca(pc) = rgb(red, green, blue)
next

'the outer loop here waits for keypress to move out to new mira
? "Start: a = ";a;" b = ";b
while len(inkey) = 0
for i=0 to dots
z = x
x = b * y + j
j = a * x + c * (x ^ 2) / (1 + x ^ 2)
y = j - z
xp = (x * 20) + xc
yp = (y * 20) + yc
pset xp, yp, ca(int(i/100))
next
delay 100
wend
cls
wend