Results 1 to 4 of 4

Thread: [RESOLVED] Region troubles

  1. #1

    Thread Starter
    eXtreme Programmer .paul.'s Avatar
    Join Date
    May 2007
    Location
    Chelmsford UK
    Posts
    25,479

    Resolved [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?

  2. #2
    PowerPoster boops boops's Avatar
    Join Date
    Nov 2008
    Location
    Holland/France
    Posts
    3,201

    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

  3. #3

    Thread Starter
    eXtreme Programmer .paul.'s Avatar
    Join Date
    May 2007
    Location
    Chelmsford UK
    Posts
    25,479

    Re: Region troubles

    Quote Originally Posted by boops boops View Post
    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)

  4. #4
    PowerPoster boops boops's Avatar
    Join Date
    Nov 2008
    Location
    Holland/France
    Posts
    3,201

    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
  •  



Click Here to Expand Forum to Full Width