GraphicsPath.IsOutlineVisible Method (Int32, Int32, Pen, Graphics)


Indicates whether the specified point is contained within (under) the outline of this GraphicsPath when drawn with the specified Pen and using the specified Graphics.

Namespace:   System.Drawing.Drawing2D
Assembly:  System.Drawing (in System.Drawing.dll)

public bool IsOutlineVisible(
	int x,
	int y,
	Pen pen,
	Graphics graphics


Type: System.Int32

The x-coordinate of the point to test.

Type: System.Int32

The y-coordinate of the point to test.

Type: System.Drawing.Pen

The Pen to test.

Type: System.Drawing.Graphics

The Graphics for which to test visibility.

Return Value

Type: System.Boolean

This method returns true if the specified point is contained within the outline of this GraphicsPath as drawn with the specified Pen; otherwise, false.

This method tests to see if the outline of a given path is rendered visible at the specified point. The coordinates of the point to be tested are given in world coordinates. The transform matrix of graphics is temporarily applied before testing for visibility.

The following code example is designed for use with Windows Forms, and it requires PaintEventArgse, an OnPaint event. The code performs the following actions:

  • Creates a path.

  • Adds a rectangle to the path.

  • Creates a wide pen and widens the path with that pen (to make the example clearer),

  • Tests a point (100, 50) to see if it lies within (under) one of the edges of the rectangle by calling IsOutlineVisible.

The result is shown in the message box (in this case, true). In other words the edge is rendered over that point.

public void IsOutlineVisibleExample(PaintEventArgs e)
    GraphicsPath myPath = new GraphicsPath();
    Rectangle rect = new Rectangle(20, 20, 100, 100);
    Pen testPen = new Pen(Color.Black, 20);
    e.Graphics.FillPath(Brushes.Black, myPath);
    bool visible = myPath.IsOutlineVisible(100, 50, testPen,
    MessageBox.Show("visible = " + visible.ToString());

.NET Framework
Available since 1.1
Return to top