|
-
Aug 29th, 2021, 01:29 AM
#1
[RESOLVED] Region troubles
I have arrays of points that i'm using to create polygonal regions on panels. This works, but the polygon is narrowed slightly...
Code:
Dim gp As New Drawing2D.GraphicsPath
gp.AddPolygon(ShipPoints(arrayIndex))
Me.Region = New Region(gp)
To compensate for that, i'm trying to widen the graphicspath...
Code:
Dim gp As New Drawing2D.GraphicsPath
gp.AddPolygon(ShipPoints(arrayIndex))
gp.Widen(p1px)
Me.Region = New Region(gp)
My panels effectively disappear. All i see is an outline where a solid polygon shape should be.
Can anyone help solve this problem?
- Coding Examples:
- Features:
- Online Games:
- Compiled Games:
-
Aug 29th, 2021, 08:30 AM
#2
Re: Region troubles
The GraphicsPath.Widen(pen) method does indeed create an outline, not a "solid" shape. For example, if your graphics path shape is a circle, the Widen function will convert the path into a hollow ring. The Pen argument determines the thickness of the ring. It also opens up a lot of possibilities (such as dashed lines, arrow heads etc.) but it's not much use for creating a circular Region. The Region corresponds to the Fill area, which in this case would be the hollow ring itself.
Instead, use the original path to widen the Region. Among other ways you could stretch, translate or rotate the shape using GraphicsPath.Transform(Matrix) in a similar way to Graphics.Transform.
BB
-
Aug 29th, 2021, 09:28 AM
#3
Re: Region troubles
 Originally Posted by boops boops
The GraphicsPath.Widen(pen) method does indeed create an outline, not a "solid" shape. For example, if your graphics path shape is a circle, the Widen function will convert the path into a hollow ring. The Pen argument determines the thickness of the ring. It also opens up a lot of possibilities (such as dashed lines, arrow heads etc.) but it's not much use for creating a circular Region. The Region corresponds to the Fill area, which in this case would be the hollow ring itself.
Instead, use the original path to widen the Region. Among other ways you could stretch, translate or rotate the shape using GraphicsPath.Transform(Matrix) in a similar way to Graphics.Transform.
BB
I found a workaround. It’s a hack, but it works…
Code:
Dim gp As New Drawing2D.GraphicsPath
gp.AddPolygon(ShipPoints(arrayIndex))
gp.Widen(p1px)
‘ add the original polygon again
gp.AddPolygon(ShipPoints(arrayIndex))
Me.Region = New Region(gp)
- Coding Examples:
- Features:
- Online Games:
- Compiled Games:
-
Aug 29th, 2021, 01:42 PM
#4
Re: Region troubles
Good idea. It results in a dilation of the original shape (opposite to erosion). That's not quite the same as widening by scaling, but there's nothing hacky about it if it's the effect you want. BB
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|