Sub spiral()
' CorelDraw X5 Macro - Spiral
' Created by Alan Reeves
' Find me at http://bluecapra.com or http://bookwormlaser.com
'
' This macro was created to explore the automatic generation of a
' square spiral. The spiral is created using the following procedure:
'
' 1. A line of an initial length is drawn
' 2. Another line is drawn from the end point of the first line
' with a length of the previous line plus a line increase length
' to the coordinates that is basically the line rotated a specific
' angle.
' 3. Step 2 is repeated as many times as desired
'
' Example:
' 1. Draw a vertical line 1 unit long from top to bottom
' 2. Draw a line at 91 degrees to that line that is 1.1 units long
' 3. Draw a line at 91 degrees to that line that is 1.2 units long
' 4. etc, etc, etc
Dim initialLength As Double
Dim currentLength As Double
Dim newLength As Double
Dim increaseLength As Double
Dim newAngle As Double
Dim currentAngle As Double
Dim increaseAngle As Double
Dim newX As Double
Dim newY As Double
Dim currentX As Double
Dim currentY As Double
increaseAngle = 91
currentAngle = 0
initialLength = 0.25
increaseLength = 0.05
currentLength = initialLength * multiply
currentX = 0
currentY = 0
newX = 0 + currentLength
newY = 0
Dim s1 As Shape
Set s1 = ActiveLayer.CreateLineSegment(currentX, currentY, newX, newY)
For i = 0 To 100
newAngle = currentAngle + increaseAngle
newLength = currentLength + increaseLength
newY = Sin(newAngle * (3.14159 / 180)) * newLength
newX = Cos(newAngle * (3.14159 / 180)) * newLength
Set s1 = ActiveLayer.CreateLineSegment(currentX, currentY, newX, newY)
currentX = newX
currentY = newY
currentAngle = newAngle
currentLength = newLength
Next i
End Sub