Home All Groups Group Topic Archive Search About

containment of a rectangle in an irregular region

Author
26 Jan 2006 8:19 PM
PJ6
I've Googled this but come up short... I have a non-rectangular region that
contains a moveable rectangle. I want to restrict the rectangle's movement
to have it always fully contained in this region. Would seem pretty simple
to do this with a region's IsVisible function, but no, IsVisible returns
true if any portion of the rectangle is visible.

I know I'll eventually get this just by messing around but don't want to
unnecesssarily re-invent the wheel... is there something built into the
Framework that I can use?

Paul

Author
26 Jan 2006 8:30 PM
PJ6
Sometimes I think I post just because Murphy's Law dictates that I must then
find the solution myself sortly thereafter...

    Private Function DoesPathFullyContain( _
        ByVal p As GraphicsPath, ByVal rect As Rectangle) As Boolean
        Dim ret As Boolean
        Dim r1 As New Region(p)
        Dim r2 As New Region
        r2.MakeInfinite()
        r2.Exclude(r1)
        ret = Not r2.IsVisible(rect)
        Return ret
    End Function


Show quoteHide quote
"PJ6" <nob***@nowhere.net> wrote in message
news:Oj1DYXrIGHA.1388@TK2MSFTNGP11.phx.gbl...
> I've Googled this but come up short... I have a non-rectangular region
> that contains a moveable rectangle. I want to restrict the rectangle's
> movement to have it always fully contained in this region. Would seem
> pretty simple to do this with a region's IsVisible function, but no,
> IsVisible returns true if any portion of the rectangle is visible.
>
> I know I'll eventually get this just by messing around but don't want to
> unnecesssarily re-invent the wheel... is there something built into the
> Framework that I can use?
>
> Paul
>