Last post Apr 18, 2005 07:10 AM by mironline
Apr 14, 2005 11:29 AM|mironline|LINK
dim test as string = "124,215,54,53,85,65,84,54,35,15,26,36,26,21,54,50"
is it possibel to use this String as
pen to DrawPolygon ?
Apr 15, 2005 10:16 PM|Caddre|LINK
Looks like Fibonacci to me but I could be wrong. You could run into stack overflow exception. Hope this helps.
Apr 16, 2005 06:50 AM|imagemaker|LINK
If I'm correct in my assumption that pairs of numbers in the comma delimited string represent the verticies of the polygon, this should work (but has not been tested):
Public Sub DrawPolygonFromString(ByVal p As Pen, ByVal g As Graphics, ByVal s As String) Dim strPoints() As String Dim n, i, j As Integer strPoints = s.Split(","c) n = strPoints.Length If n Mod 2 <> 0 Then Throw New ArgumentException("Comma delimited string must contain an even number of values") End If n = (n \ 2) - 1 Dim Points(n) As Point For i = 0 To n j = i * 2 Points(i) = New Point(Convert.ToInt32(strPoints(j)), Convert.ToInt32(strPoints(j + 1))) Next g.DrawPolygon(p, Points)End Sub
If by "use this String as pen" you meen that the numbers represent properties of a pen object, that's something entirely different.
Apr 18, 2005 07:10 AM|mironline|LINK
thank you very very much