Public Sub IsVisibleExample(ByVal e As PaintEventArgs)
Dim myPath As New GraphicsPath
myPath.AddEllipse(0, 0, 100, 100)
Dim visible As Boolean = myPath.IsVisible(50, 50, e.Graphics)
MessageBox.Show(visible.ToString())
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 IsVisibleExample(ByVal e As PaintEventArgs)
Dim myPath As New GraphicsPath
myPath.AddEllipse(0.0, 0.0, 1.0, 1.0)
Dim visible As Boolean = myPath.IsVisible(0.5, 0.5, e.Graphics)
MessageBox.Show(visible.ToString())
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?
The GraphicsPath will draw one pixel less in width and height when filling,
if antialiasing is off. The IsVisible method seems consistent with that
interpretation.
Regards,
Frank Hileman
check out VG.net: http://www.vgdotnet.com
Animated vector graphics system
Integrated Visual Studio graphics editor
"Mike" <Mi...@discussions.microsoft.com> wrote in message
news:AF5CB9E0-AF09-4E75...@microsoft.com...
Following your example:
(sorry if the syntax is not correct. I usually use C#)
Public Sub IsVisibleExample(ByVal e As PaintEventArgs)
Dim myPath As New GraphicsPath
myPath.AddEllipse(0.0, 0.0, 1.0, 1.0)
myPath.Transform(new Matrix(100, 0, 0, 100, 0, 0)) '(1)
Dim visible As Boolean = myPath.IsVisible(0.5 * 100, 0.5 * 100, e.Graphics) '(2)
MessageBox.Show(visible.ToString())
End Sub
(1) Scale by 100 units in both the x and y dimensions. NOTE: If yopu´re planning to use the GraphicsPath again (for drawing it for example) do not scale it, scale a copy instead. The Transform method transforms the object that calls it.
(2) To scale a point just multiply the x and y coordinates by the desired factor.
So, that´s it. The higher the number you use as scale factor the more precise your IsVisible approach will be.
---
Posted using Wimdows.net Newsgroups - http://www.wimdows.net/newsgroups/