|
web
newsgroups
|
|||||||||||||||||||||||
|
|||||||||||||||||||||||
Scaling Graphics (Fractal)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() MyBase.New() 'This call is required by the Windows Form Designer. InitializeComponent() '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 Boolean) If disposing Then If Not (components Is Nothing) Then components.Dispose() End If End If MyBase.Dispose(disposing) End Sub 'Required by the Windows Form Designer Private components As System.ComponentModel.IContainer 'NOTE: The following procedure is required by the Windows Form Designer '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 InitializeComponent() Me.components = New System.ComponentModel.Container Me.Timer1 = New System.Windows.Forms.Timer(Me.components) Me.tmrColor = New System.Windows.Forms.Timer(Me.components) ' 'Timer1 ' Me.Timer1.Enabled = True Me.Timer1.Interval = 1 ' 'tmrColor ' Me.tmrColor.Enabled = True Me.tmrColor.Interval = 1000 ' 'Form1 ' 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 + (x))))) 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 Else 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 rnd_dots() 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 "placid" <Bul***@gmail.com> schrieb
http://msdn.microsoft.com/library/en-us/cpguide/html/_gdiplus_coordinate_systems_and_transformations_about.asp
> 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. Armin |
|||||||||||||||||||||||