"The code is exactly
how I would like to write code and the algorithms used are very
efficient and well-documented."
Van T. Dinh, Microsoft MVP
|
|
Routines for drawing fractals, including the Mandelbrot and Julia fractals in VB6.
Procedure List
Procedure Name
|
Type
|
Description
|
(Declarations)
|
Declarations
|
Declarations and private variables for the modFractal module
|
Julia
|
Procedure
|
Draw a Julia fractal
|
MandelBrot
|
Procedure
|
Draws a Mandelbrot fractal
|
Example Code for Using Module: Fractal
' Example of modFractal
'
' To try this example, do the following:
' 1. Create a new form
' 2. Add a command button 'cmdDraw'
' 3. Add a slider named 'sldCX'
' 4. Add a slider named 'sldCY'
' 5. Add a slider named 'sldStartX'
' 6. Add a slider named 'sldStartY'
' 7. Add a slider named 'sldEndX'
' 8. Add a slider named 'sldEndY'
' 9. A control array of option buttons called 'optType'.
' There should be two option buttons in this group
' 10. Add an picture box called 'picFractal'
' Set the following properties
' ScaleMode Pixel
' 11. Paste all the code from this example to the new form's module
' 12. Run the form
Private Const mcintJulia As Integer = 0
Private Const mcintMandelBrot As Integer = 1
Private Sub cmdDraw_Click()
If optType(mcintJulia).Value = True Then
'Julia
Julia picFractal.hDC, sldCX / 1000, sldCY / 1000, sldStartX / 1000, sldStartY / 1000, sldEndX / 1000, sldEndY / 1000, picFractal.ScaleWidth, picFractal.ScaleHeight, 20
Else
'Mandelbrot
MandelBrot picFractal.hDC, sldStartX / 1000, sldStartY / 1000, sldEndX / 1000, sldEndY / 1000, picFractal.ScaleWidth, picFractal.ScaleHeight, 50
End If
End Sub
Private Sub Form_Load()
sldCX.Min = -2 * 1000
sldCX.Max = 2 * 1000
sldCY.Min = -2 * 1000
sldCY.Max = 2 * 1000
sldStartX.Min = -1.5 * 1000
sldStartX.Max = 1.5 * 1000
sldStartY.Min = -1.5 * 1000
sldStartY.Max = 1.5 * 1000
sldEndX.Min = -1.5 * 1000
sldEndX.Max = 1.5 * 1000
sldEndY.Min = -1.5 * 1000
sldEndY.Max = 1.5 * 1000
optType(mcintJulia).Caption = "Julia"
optType(mcintJulia).Value = True
optType(mcintMandelBrot).Caption = "MandelBrot"
cmdDraw.Caption = "Draw"
picFractal.ScaleMode = vbPixels
End Sub
Private Sub Option1_Click(Index As Integer)
Select Case Index
Case mcintJulia
' Set the range of values defined for the Julia set
sldCX.Enabled = True
sldCY.Enabled = True
sldCX.Min = -2 * 1000
sldCX.Max = 2 * 1000
sldCY.Min = -2 * 1000
sldCY.Max = 2 * 1000
sldStartX.Min = -1.5 * 1000
sldStartX.Max = 1.5 * 1000
sldStartY.Min = -1.5 * 1000
sldStartY.Max = 1.5 * 1000
sldEndX.Min = -1.5 * 1000
sldEndX.Max = 1.5 * 1000
sldEndY.Min = -1.5 * 1000
sldEndY.Max = 1.5 * 1000
Case mcintMandelBrot
' Set the range of values defined for the Mandelbrot set
sldCX.Enabled = False
sldCY.Enabled = False
sldStartX.Min = -2.25 * 1000
sldStartX.Max = 0.75 * 1000
sldStartY.Min = -1.5 * 1000
sldStartY.Max = 1.5 * 1000
sldEndX.Min = -2.25 * 1000
sldEndX.Max = 0.75 * 1000
sldEndY.Min = -1.5 * 1000
sldEndY.Max = 1.5 * 1000
End Select
End Sub
Overview of Total Visual SourceBook
The source code in Total Visual
SourceBook includes modules and classes for Microsoft Access, Visual
Basic 6 (VB6), and Visual Basic for Applications (VBA) developers. Easily
add this professionally written, tested, and documented royalty-free code
into your applications to simplify your application development efforts.
Additional Resources
|
|