FRACTALES ET CHAOS - SOFTLAB® MANDELBROT SET EXPLORER - Core Prog

*--------------------------------------
* Prog      : Mandelbrot set explorer
* Author    : The Mag
* Version 1 : Jan 01, 2003
* Version 2 : Nov 15, 2003
* Comments -------------------------------
* Encapsulated method in object : 'F2=Run'
* You might need entire source code to understand everything 
* especially for visual interface issue. Download Free source code below :
* http://www.softlabo.org/TheMag/Informatics/Mandelbrot/MagDelBrotCode.zip 
*--------------------------------------
*--- Introduction 
oSLFormSet.slGraf.slEdit.VISIBLE=.F. 
oSLFormSet.slGraf.Picture=""
oSLFormSet.slGraf.Cls()
xWidth =oSLFormSet.slGraf.WIDTH &&-> X axe 
yHeight=oSLFormSet.slGraf.HEIGHT &&-> Y axe 
oSLFormSet.slGraf.ForeColor=RGB(255,255,255)-aColors[12] && Inverse video of BackColor
nXCenter=xWidth/2
nYCenter=yHeight/2

*--- Beg Mapping ---*
xRange=X2-X1
xDelta =xRange/xWidth && 3.2/780=0.0041 <=> 1 pixel corresponds = delta(x)=0.0041 = xSlFoxel
yRange=Y1-Y2 && A l'envers. 
yDelta=yRange/yHeight && 2.4/400=0.0060 <=> 1 pixel correspond = delta(y)=0.0060= ySlFoxel
*--- End Mapping ---*

* Visual Point : Plot Axes (0,0)
vX0=(0-X1)/xDelta 
vY0=(Y1-0)/yDelta 

*--- Explore selected area and plot point with the inherent color
xRef=X1 
xDeltaStep=xDelta*xStep
yDeltaStep=yDelta*yStep
oSLFormSet.slGraf.DrawWidth=PenWidth
isRuning=.T. 
FOR x=0 TO xWidth STEP xStep 
    isRuning=.T. && is drawing
    xRef=xRef+xDeltaStep && Adjusted to step and scale 
    yRef=Y1 && Cartesian value of Y corresponding to current pixel
    FOR y=0 TO yHeight STEP yStep && STEP yDelta
        yRef=yRef-yDeltaStep && «Minus cause downstairs»
        a =0.0
        b =0.0
        c2=0.0
        FOR k=1 TO MaxiIter
            *Mandelbrot's dynamic formula : Z(t)=(Z(t-1))^2+Z(0)
            a_temp=a && Save it here since the following line changes everything
            a=(a*a)-(b*b) +xRef
            b=(2*a_temp*b) +yRef
            *-- Test based on Norm(Z)
            c2=(a*a)+(b*b) && No need to use SQRT : c=SQRT(a*a+b*b)
            *--- Beg T order Transient : Plot it and exit ---*
            IF c2>MBroide && A paramter. Mandelbrot=4
                *-- Plot it with the adequat color
		nColor=aColors[CEILING(10*k/MaxiIter)]
		oSLFormSet.slGraf.ForeColor = nColor
                oSLFormSet.slGraf.PSet(x,y)
                EXIT
            ENDIF c2>MBroide
            *--- End T order Transient : Plot it and exit ---*
        ENDFOR k=1 TO MaxiIter
    ENDFOR y=Y1 TO Y2
ENDFOR x=X1 TO X2

RETURN
© 1993-2003 by SOFTLAB® karen@softlabo.org www.softlabo.org + 229 33 53 43 05 B.P. 566 Cotonou - BENIN