'===========================================================================
' Subject: QMANDEL COMPONENT                  Date: 10-25-99 (13:36)       
'  Author: Erlend Rovik                       Code: RAPIDQ                 
'  Origin: e-rovik@online.no                Packet: RAPIDQ.ABC
'===========================================================================
'QMandel By Erlend Rovik (Preacher / Bizarre Designz)
'-------------------------------------
'There is no zoom, havent got the time
'to implement it yet
'-------------------
$APPTYPE GUI
$TYPECHECK ON

TYPE QMandel EXTENDS QCanvas
  xmin as Double
  ymin as Double
  xmax As Double
  ymax As Double

  SUB DrawMandel
   Dim Q as Integer
   Dim P As Integer
   Dim h as Double
   dim w as Double
   dim m as Double
   dim n as Double
   dim v as Double
   dim i as integer
   dim x as Double
   dim y as Double
   dim z as Double
   dim r as Double
   dim k as integer
   k=15
   h=(QMandel.xmax-QMandel.xmin)/QMandel.Width
   v=(QMandel.ymax-QMandel.ymin)/QMandel.Height
   For Q=0 To QMandel.Height Step 1
    For P=0 to QMandel.Width Step 1
     m=QMandel.xmin+p*h:n=QMandel.ymin+q*v:i=0:x=0:y=0
     Do
      w=x*x:z=y*y:r=w+z:y=2*x*y+n:x=w-z+m:i=i+1
     Loop Until (i>k) or (r>4)
     QMandel.PSet(p,q,i*1000)
    Next p
   Next q
  END SUB
  '-- Default values
  CONSTRUCTOR
   Width=200
   Height=100
   XMin=-2.00
   YMin=-1.25
   XMax=1.25
   YMax=1.25
  END CONSTRUCTOR
END TYPE

'Test Source
DIM Form AS QForm
DIM Mandelbrot AS QMandel
MandelBrot.Parent = Form
MandelBrot.OnClick=MandelBrot.DrawMandel
Form.ShowModal
END
