GraphicsPath.IsVisible broken?

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Mike

    #1

    GraphicsPath.IsVisible broken?

    The .NET class libary presents this as an example of GraphicsPath.Is Visible:

    Public Sub IsVisibleExampl e(ByVal e As PaintEventArgs)
    Dim myPath As New GraphicsPath
    myPath.AddEllip se(0, 0, 100, 100)
    Dim visible As Boolean = myPath.IsVisibl e(50, 50, e.Graphics)
    MessageBox.Show (visible.ToStri ng())
    End Sub

    This seems to work quite well, it pops up a box that is true, as it should
    be. However, if you alter the code:

    Public Sub IsVisibleExampl e(ByVal e As PaintEventArgs)
    Dim myPath As New GraphicsPath
    myPath.AddEllip se(0.0, 0.0, 1.0, 1.0)
    Dim visible As Boolean = myPath.IsVisibl e(0.5, 0.5, e.Graphics)
    MessageBox.Show (visible.ToStri ng())
    End Sub

    To use those floating points on a smaller scale, the returned value is
    false. Now, obviously, that point is within the bounds of the ellipse, and
    method explicitly takes Singles, it's not doing a conversion here or anything.

    Does anyone know what the reason for this discrepancy is?
  • Larry Lard

    #2
    Re: GraphicsPath.Is Visible broken?


    Mike wrote:[color=blue]
    > The .NET class libary presents this as an example of GraphicsPath.Is Visible:
    >
    > Public Sub IsVisibleExampl e(ByVal e As PaintEventArgs)
    > Dim myPath As New GraphicsPath
    > myPath.AddEllip se(0, 0, 100, 100)
    > Dim visible As Boolean = myPath.IsVisibl e(50, 50, e.Graphics)
    > MessageBox.Show (visible.ToStri ng())
    > End Sub
    >
    > This seems to work quite well, it pops up a box that is true, as it should
    > be. However, if you alter the code:
    >
    > Public Sub IsVisibleExampl e(ByVal e As PaintEventArgs)
    > Dim myPath As New GraphicsPath
    > myPath.AddEllip se(0.0, 0.0, 1.0, 1.0)
    > Dim visible As Boolean = myPath.IsVisibl e(0.5, 0.5, e.Graphics)
    > MessageBox.Show (visible.ToStri ng())
    > End Sub
    >
    > To use those floating points on a smaller scale, the returned value is
    > false. Now, obviously, that point is within the bounds of the ellipse, and
    > method explicitly takes Singles, it's not doing a conversion here or anything.[/color]

    I wouldn't be so sure about that. Remember that in GDI+ the unit of
    measure is the pixel. If you check what an ellipse produced with those
    arguments actually looks like (eg, new WinForms project, drop a
    picturebox on the form, add this code

    Private Sub PictureBox1_Pai nt(ByVal sender As Object, ByVal e As
    System.Windows. Forms.PaintEven tArgs) Handles PictureBox1.Pai nt
    With e.Graphics
    .FillEllipse(Br ushes.Red, 0, 0, 1.0, 1.0)
    End With
    End Sub

    and play with the parameters) you will see that it doesn't actually
    include any pixels at all, so IsVisible will always return false (I
    suspect). These aren't idealised mathematical coordinates - they are
    very much tied to the actual pixels produced.

    --
    Larry Lard
    Replies to group please

    Comment

    Working...