Maybe I’m doing something wrong but I did not get the same and worse.
I create a exemple app just to show two canvas that draw an hexagon.
The main method is
Dim points() As Double
g.PenSize = 4
points = HexToPoints(68)
g.DrawingColor = &c0000FF
if method = 1 then
// ALL SYSTEM one line
g.DrawPolygon(points)
elseif method = 2 then
// NEW SYSTEM....
Var p As New GraphicsPath
p.MoveToPoint (points(1),points(2)) // Start location
p.AddLineToPoint (points(3),points(4))
p.AddLineToPoint (points(5),points(6))
p.AddLineToPoint (points(7),points(8))
p.AddLineToPoint (points(9),points(10))
p.AddLineToPoint (points(11),points(12))
g.DrawingColor = &c0000FF
g.DrawPath(p, True)
else
end if
Yeah its because DrawPath draws the border in the middle of the path not inside like all standard drawing methods. Depending on PenSize this becomes more and more visible.
Have you checked how the PDF output looks like with PDFDocument/PDFGraphics? It supports GraphicPath since 2020r2.
I am not sure if this is wanted by Xojo or a bug. @William_Yu
There does appear to be a difference there, as Martin has noted. I’m not sure if this is intentional or not, so you should probably create a Feedback case.
In the meantime, a slight tweak to your code seems to get them drawing the same:
Var points() As Double
g.PenSize = 4
points = HexToPoints(68)
g.DrawingColor = &c0000FF
If method = 1 Then
// ALL SYSTEM one line
g.DrawPolygon(points)
ElseIf method = 2 Then
// NEW SYSTEM....
Var p As New GraphicsPath
For i As Integer = 1 To points.LastIndex Step 2
Var x As Integer = points(i) + g.PenSize / 2
Var y As Integer = points(i + 1) + g.PenSize / 2
If i = 1 Then
p.MoveToPoint(x, y)
Else
p.AddLineToPoint(x, y)
End If
Next
g.DrawingColor = &c0000FF
g.DrawPath(p, True)
Else
End If
The change you suggested works for PenSize = 4 (or others even values) but not for PenSize = 1, for example
Maybe “g.PenSize / 2 fractions up” will do.
It seems that the way it works is not intentionally as to get the same, the new system is much more code, and more confusing that the original DrawPolygon,
With drawpath it has to be down the middle, how does the system know what you expect to be the inside of the shape you eventually form if you even close the shape, as path can be open ended?
For example, an infinity symbol ∞ how does it know to draw to the right on the left portion, and the left on the right portion to remain on the “inside”?
In windows at least they look the same so is DrawPolygon on mac the odd one out here by drawing the border to the inside of a defined shape, poly, rect etc.?
Not really. The difference occurs with all Draw methods (DrawOval, DrawRectangle, DrawPolygon, DrawRoundRectangle) compared to DrawPath. In addition, as William himself noted in Feedback Case, there are different representations within the operating systems. The Xojo Framework is not consistent there therefore.