'=========================================================================== ' Subject: MARTIN FRACTALS FOR BASEC Date: 03-23-99 (08:41) ' Author: Jernej Simoncic Code: BEC ' Origin: jernej.simoncic@guest.arnes.si Packet: BASEC.ABC '=========================================================================== ' Martin fractal program, by Alan Meiss ' Converted to basic by Jernej Simoncic ' This code is designed for BASEC 0.15 by William Yu ' ' Formula from "Dynamical Systems and Fractals", ' by Karl-Heinz Becker and Michael D”rfler, ' Cambridge University Press, 1990 ' DIM xmax as integer, ymax as integer, t as integer, tcmax as integer dim tc as integer, clr as integer, cx as integer, cy as integer, code as integer DIM sa AS DOUBLE, sav AS DOUBLE, sb AS DOUBLE, sc AS DOUBLE DIM ch AS STRING * 1, a as double, b as double, c as double, s as double dim x as double,y as double,tmp1 as double, tmp2 as double, tmp as double dim xold as double, yold as double,xnew as double, ynew as double dim xc as double, yc as double, signn as double, sign as double dim px as double, py as double,keypressed as integer, k$ as string RANDOMIZE TIMER xmax = 639 ymax = 479 cx = INT(.5 + xmax / 2!) cy = INT(.5 + ymax / 2!) SCREEN 12 tcmax=100 sa = RND * 100! - 50! sb = RND * 100! - 50! sc = RND * 100! - 50! sav = (ABS(sa) + ABS(sb) + ABS(sc)) / 3! 'martin1 sa, sb, sc, 6! - ABS(sav / 10!) goto martin1 SCREEN 0 martin1:' (a AS DOUBLE, b AS DOUBLE, c AS DOUBLE, s AS DOUBLE) a=sa b=sb c=sc tmp=ABS(sav / 10!) s=6-tmp 'DIM xold AS DOUBLE, yold AS DOUBLE, xnew AS DOUBLE, ynew AS DOUBLE xold = 0 yold = 0 clr = INT(RND * 256) t = 0 tc = 0 ch = "a" DO px=xold * s py=yold * s gosub plot signn=xold gosub getsign xnew = yold - sign * SQR(ABS(b * xold - c)) '{ <- This is it! These two } ynew = a - xold ' { <- lines generate the } xold = xnew ' { entire fractal! } yold = ynew t = t + 1 IF t > 500 THEN tc = tc + 1 clr = clr + 1 IF clr > 255 THEN clr = 1 t = 0 END IF k$ = INKEY$ IF k$ <>"" THEN end LOOP UNTIL keypressed or ((tc > (tcmax - 1)) AND (tcmax > 0)) screen 0 end 'SUB plot (x AS DOUBLE, y AS DOUBLE, clr) plot: xc=.5+px xc=int(xc) xc=xc+cx yc=.5+py yc=int(yc) yc=yc+cy PSET (xc, yc), clr return 'FUNCTION sign (x AS DOUBLE) getsign: if signn= 0 then sign = 0 if signn < 0 then sign=-1 if signn>0 then sign = 1 'END FUNCTION return