473,395 Members | 1,574 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,395 software developers and data experts.

GraphicsPath.IsVisible broken?

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

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?
Jun 9 '06 #1
1 2133

Mike wrote:
The .NET class libary presents this as an example of GraphicsPath.IsVisible:

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.


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_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

Jun 12 '06 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

11
by: Altramagnus | last post by:
I have a complicated Region object, which I need to draw the outline, but not fill How can I convert the Region object to GraphicsPath object? or How can I draw the outline of the Region object?
6
by: Altramagnus | last post by:
I have n number of circles. Some of them might overlap. I need to draw the outline of all circles but not those overlap areas. Initially, I am try to use a Region, because a Region object has a...
1
by: jay | last post by:
I have a bitmap and a graphicspath object. I draw pixels on m_Bitmap and I'm drawing text using m_Graphics GraphicsPath object. However, saving my work with m_Bitmap.Save doesn't save...
7
by: Crirus | last post by:
Hi Is that true that this IsVisible method is incredible slow? Seems that my app is much slower with only this added as a condition to draw something Crirus
2
by: Martijn Mulder | last post by:
/* GraphicsPath.IsVisible() gives unexpected results. I fill a System.Drawing.Drawing2D.GraphicsPath-object with PointF-structures that define the unit-square (0,0), (1,0), (1,1) and (0,1). Then I...
3
by: iwasinnihon | last post by:
I have created a form that has a list box that displays information queried from a table. I then have a textbox under the form and three buttons under that(Add, Update, Delete). When the form is...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.