By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
455,288 Members | 1,243 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 455,288 IT Pros & Developers. It's quick & easy.

Scaling Graphics (Fractal)

P: n/a
Hi all,

This is the following code i have,

Public Class Form1
Inherits System.Windows.Forms.Form

Dim A, B, c, U, x, y As Double
Dim Red, Green, Blue As Integer

'Bitmap holds picture of the form
Private b1 As Bitmap

'Graphics object (printing buffer)
Private g1 As Graphics
#Region " Windows Form Designer generated code "

Public Sub New()

'This call is required by the Windows Form Designer.

'Add any initialization after the InitializeComponent() call

End Sub

'Form overrides dispose to clean up the component list.
Protected Overloads Overrides Sub Dispose(ByVal disposing As
If disposing Then
If Not (components Is Nothing) Then
End If
End If
End Sub

'Required by the Windows Form Designer
Private components As System.ComponentModel.IContainer

'NOTE: The following procedure is required by the Windows Form
'It can be modified using the Windows Form Designer.
'Do not modify it using the code editor.
Friend WithEvents Timer1 As System.Windows.Forms.Timer
Friend WithEvents tmrColor As System.Windows.Forms.Timer
<System.Diagnostics.DebuggerStepThrough()> Private Sub
Me.components = New System.ComponentModel.Container
Me.Timer1 = New System.Windows.Forms.Timer(Me.components)
Me.tmrColor = New System.Windows.Forms.Timer(Me.components)
Me.Timer1.Enabled = True
Me.Timer1.Interval = 1
Me.tmrColor.Enabled = True
Me.tmrColor.Interval = 1000
Me.AutoScaleBaseSize = New System.Drawing.Size(5, 13)
Me.BackColor = System.Drawing.Color.Black
Me.ClientSize = New System.Drawing.Size(292, 266)
Me.Name = "Form1"
Me.Text = "Form1"

End Sub

#End Region

Private Sub Form1_Activated(ByVal sender As Object, _
ByVal e As System.EventArgs) Handles MyBase.Activated

Static done As Boolean = False

If Not done Then
'Size and describe the form
Me.Size = New Size(1000, 1000)
Me.Text = "Mira Dust Fractal"
'Create the initial bitmap from Form
b1 = New Bitmap(Width, Height, Me.CreateGraphics())
'Create the Graphics Object buffer
' which ties the bitmap to it so that
' when you draw something on the object
' the bitmap is updated
g1 = Graphics.FromImage(b1)

'Prevent reentry to initialization
done = True

A = 0.9
B = 0.9998
c = -0.234
x = 950 : y = 950 'Starting Point

Red = Green = Blue = 1

End If
End Sub

Private Sub Form1_Paint(ByVal sender As Object, _
ByVal e As System.Windows.Forms.PaintEventArgs) _
Handles MyBase.Paint

'Copy the bitmap to the form
e.Graphics.DrawImage(b1, 0, 0)
End Sub

Private Sub rnd_dots()
Dim C, Z, W As Double
W = (System.Math.Cos(((A * x * x) + (C + (x * x))) / ((100 +
Z = x

U = (x * x)
x = ((B * y + W))

W = (System.Math.Sin((A * x) + ((C * U)) / (1 + U)))
y = (W - Z)
Dim p As Pen
If (Red > 257) Then
Red = 1
Red = Red + 1
End If
Dim cl As Color =
System.Drawing.ColorTranslator.FromOle(RGB(Red, Blue, Green))
p = New Pen(cl)
g1.ScaleTransform(-1, 1)
Dim r As Rectangle = New Rectangle(x, y, 1, 1)
g1.DrawEllipse(p, r)
'Copy the bitmap to the form
Me.CreateGraphics.DrawImage(b1, 0, 0)

End Sub

Private Sub Timer1_Tick(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles Timer1.Tick
End Sub

End Class
when i run this the fractal generated is too big, i.e it goes out the
boundary of the Form.

I remember with VB6 there was Form1.Scale(x1,y1)-(x2,y2) but so far i
have found no equivalent to this in VB.NET.

Could any one please help me with this problem. i want to be able to
scale a part of the fractal so that the other parts are not generated!

Please keep in mind im new to VB.NET!
thanks in advance

Feb 14 '06 #1
Share this Question
Share on Google+
1 Reply

P: n/a
"placid" <Bu****> schrieb
I remember with VB6 there was Form1.Scale(x1,y1)-(x2,y2) but so far
i have found no equivalent to this in VB.NET.

Feb 14 '06 #2

This discussion thread is closed

Replies have been disabled for this discussion.