Howdy, Y'all...
The below code draws a spiral...code shows that there are 4 textboxes asking for information for the user to vary the spiral, and a "go" button. It seems to work fine.
However, I want the spiral to go from "out" to "in" rather than the way it is being drawn now ("in" to "out").
What is the best way to accomplish this Is a different formula in order, or can I store the points in some slick temporary fashion to be fed back into to the graphics paint in reverse order
I don't expect you to do it for me...just help me point the way to the alternatives...
Thanks,
Nightowly
------------------------------
Imports
system.drawingImports
system.drawing.drawing2DPublic
Class Form1Public Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
'size Form1
Dim workingRectangle As System.Drawing.Rectangle = Screen.PrimaryScreen.WorkingArea
Me.MaximumSize = New System.Drawing.Size(workingRectangle.Width - 15, workingRectangle.Height - 15)
'locate Form1
Me.Location = New System.Drawing.Point(5, 5)
End Sub
Public Sub Form1_Paint(ByVal sender As Object, ByVal e As System.Windows.Forms.PaintEventArgs) Handles Me.Paint
End Sub
Public Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
Dim skyBluePen As New Pen(Brushes.DeepSkyBlue)
skyBluePen.Width = 2.0F
Dim a As Double = 0.1
Dim b As Double = 0.1
Dim ang As Double = 360
Dim i As Integer = 0
Dim iMax As Integer = 50
Dim spiralLine As Graphics = Me.CreateGraphics
If TextBox1.Text = "" Then
MessageBox.Show("Please enter a numeral between 0 and 1")
Else
a = CDbl(TextBox1.Text)
End If
If TextBox2.Text = "" Then
MessageBox.Show("Please enter a numeral between 0 and 1")
Else
b = CDbl(TextBox2.Text)
End If
If TextBox3.Text = "" Then
MessageBox.Show("Please enter a numeral between 0 and 1800")
Else
ang = CDbl(TextBox3.Text)
End If
If TextBox4.Text = "" Then
MessageBox.Show("Please enter a numeral between 0 and 25000")
Else
iMax = CInt(TextBox4.Text)
End If
Dim cX, X1, X2 As Double
Dim cY, Y1, Y2 As Double
'get the center of the form to start the spiral there
cX = CLng(Me.ClientRectangle.Width / 2)
cY = CLng(Me.ClientRectangle.Height / 2)
'loop round to plot the points of the spiral.
For i = 0 To iMax
ang = (Math.PI / 720) * i
If X1 = 0 And Y1 = 0 Then
X1 = cX + ((a * Math.Cos(ang)) * Math.Exp(b * ang))
Y1 = cY - ((a * Math.Sin(ang)) * Math.Exp(b * ang))
i += 1
X2 = cX + ((a * Math.Cos(ang)) * Math.Exp(b * ang))
Y2 = cY - ((a * Math.Sin(ang)) * Math.Exp(b * ang))
Else
X1 = X2 'X4
Y1 = Y2 'Y4
X2 = cX + ((a * Math.Cos(ang)) * Math.Exp(b * ang))
Y2 = cY - ((a * Math.Sin(ang)) * Math.Exp(b * ang))
Dim Spt1 As New Point(CInt(X1), CInt(Y1))
Dim Spt2 As New Point(CInt(X2), CInt(Y2))
spiralLine.DrawLine(skyBluePen, CInt(X1), CInt(Y1), CInt(X2), CInt(Y2))
End If
Next i
End Sub
End Class

spiral draw change
Leon Mayne
Would the following code not work for you.
For i = iMax to 0 step -1
Steve9753
Sometimes the simple solutions are right in front of you and we think writing code has to be more complex than it really is.
piknik
spotty...yes, it will, and does. I just didn't happen on that approach.
For the others, I just commented out the current "For..." line, and replaced it with this one.
Yet again I'm amazed at the simplicity of the solutions to my problems.
Thank you...