Class Definitions:
Public Class Path
Public Sub Constructor(Points() As Point)
// Clone the array since it's inherently byRef
For PointNum As Integer = 0 To Points.LastRowIndex // For-Each ordering is not guaranteed
Me.Points.Add Points(PointNum)
Next
End Sub
Public Property Points() As Point
End Class
Public Class Letter
Public Sub Constructor(Name As String, Paths() As Path)
Me.Name = Name
// Clone the array since it's inherently byRef
For PathNum As Integer = 0 To paths.LastRowIndex // For-Each ordering is not guaranteed
Me.Paths.Add Paths(PathNum)
Next
End Sub
Public Sub Draw()
// Iterate over the paths, drawing point to point
For PathNum As Integer = 0 To paths.LastRowIndex // For-Each ordering is not guaranteed
// Move the tool to start of this path, i.e. Paths(PathNum).Points(0)
// Engage the tool
For PointNum As Integer = 0 To Paths(PathNum).Points.LastRowIndex
// Move the tool from point to point
Next
// Disengage the tool
Next
End Sub
Public Property Name As String
Public Property Paths() As Path
End Class
Defining the letter “A”:
Dim Paths() As Path, Points() As Point
// Letter A first path: "/\"
Points.Append New Point(0,0)
Points.Append New Point(2.71,6.04)
Points.Append New Point(5.43,0)
Paths.Add New Path(Points)
// Letter A second path: "-"
Points.RemoveAllRows
Points.Append New Point(4.47,2.12)
Points.Append New Point(0.95,2.12)
Paths.Add New Path(Points)
Dim aLetter As new Letter("A", Paths)
allLetters.Add(aLetter)