|
web
newsgroups
|
|||||||||||||||||||||||
|
|||||||||||||||||||||||
GraphicsPath.IsVisible broken?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? Mike wrote:
Show quoteHide quote > The .NET class libary presents this as an example of GraphicsPath.IsVisible: I wouldn't be so sure about that. Remember that in GDI+ the unit of> > 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. 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_Paint(ByVal sender As Object, ByVal e As System.Windows.Forms.PaintEventArgs) Handles PictureBox1.Paint With e.Graphics .FillEllipse(Brushes.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
ASCII Character code for the 6th power
Threading Lost my Design view for a Windows Form (VB 2005) Last Modified date for the Source code. Export CR to Excel problem Launch new instance of IE?? text file to datatable to SQL2005 table not working Placeholder Object Question Can RichTextBox Control Render HTML?? Delete a DataSource in vs.net |
|||||||||||||||||||||||