Help Center

GdipIsVisiblePathPointfunction

Determines whether a specified point lies in the area that is filled when this path is filled by a specified **Graphics** object.

Graphicsfunctiondocumented

Syntax

FUNCTION GdipIsVisiblePathPoint (BYVAL path AS GpPath PTR, BYVAL x AS REAL, BYVAL y AS REAL, BYVAL graphics AS GpGraphics PTR, BYVAL result AS BOOL PTR) AS GpStatus
Also documented as GdipIsVisiblePathPointI — one description covers them all.

Parameters

NameDescription
path[in] Pointer to the GraphicsPath object.
x[in] The x-coordinate of the point to be tested.
y[in] The y-coordinate of the point to be tested.
graphics[in] Pointer to a Graphics object that specifies a world-to-device transformation. If the value of this parameter is NULL, the test is done in world coordinates; otherwise, the test is done in device coordinates. The default value is NULL.
result[out] Pointer to a variable that receives a boolean value indicating whether test point lies in the interior of this path (TRUE) or not (FALSE).

Description

Determines whether a specified point lies in the area that is filled when this path is filled by a specified Graphics object.

Examples

' ======================================================================================== ' This example checks if a point lies inside the filled area of a GraphicsPath. ' ======================================================================================== SUB Example_IsVisiblePathPoint (BYVAL hdc AS HDC)

DIM hStatus AS LONG

' // Create a graphics object from the device context DIM graphics AS GpGraphics PTR hStatus = GdipCreateFromHDC(hdc, @graphics)

' // Get the DPI scaling ratios DIM dpiX AS SINGLE hStatus = GdipGetDpiX(graphics, @dpiX) DIM rxRatio AS SINGLE = dpiX / 96 DIM dpiY AS SINGLE hStatus = GdipGetDpiY(graphics, @dpiY) Dim ryRatio AS SINGLE = dpiY / 96 ' // Set the scale transform hStatus = GdipScaleWorldTransform(graphics, rxRatio, ryRatio, MatrixOrderPrepend)

' // Create GraphicsPath DIM path AS GpPath PTR hStatus = GdipCreatePath(FillModeAlternate, @path) hStatus = GdipAddPathEllipse(path, 100, 80, 150, 100)

' // Check if point is on the path ' // Returns error 5 (StatusObjectBusy) DIM isVisible AS BOOL hStatus = GdipIsVisiblePathPoint(path, 150, 120, graphics, @isVisible) IF isVisible THEN

AfxMsg "Point is visible"

ELSE

AfxMsg "Point is not visible"

END IF

' // Create a Pen DIM pen AS GpPen PTR hStatus = GdipCreatePen1(ARGB_BLACK, 5, UnitWorld, @pen)

' // Draw the path hStatus = GdipDrawPath(graphics, pen, path)

' // Cleanup IF pen THEN GdipDeleteBrush(pen) IF path THEN GdipDeletePath(path) IF graphics THEN GdipDeleteGraphics(graphics)

END SUB ' ========================================================================================

' ======================================================================================== ' The following example creates an elliptical path and draws that path with a wide yellow pen. ' Then the code tests each point in an array to see whether the point touches the outline ' (as it would be drawn by the wide yellow pen) of the path. Points that touch the outline ' are painted green, and points that don't touch the outline are painted red. ' ======================================================================================== SUB Example_IsVisiblePathPoint (BYVAL hdc AS HDC)

DIM hStatus AS LONG

' // Create a graphics object from the device context DIM graphics AS GpGraphics PTR hStatus = GdipCreateFromHDC(hdc, @graphics)

' // Get the DPI scaling ratios DIM dpiX AS SINGLE hStatus = GdipGetDpiX(graphics, @dpiX) DIM rxRatio AS SINGLE = dpiX / 96 DIM dpiY AS SINGLE hStatus = GdipGetDpiY(graphics, @dpiY) Dim ryRatio AS SINGLE = dpiY / 96 ' // Set the scale transform hStatus = GdipScaleWorldTransform(graphics, rxRatio, ryRatio, MatrixOrderPrepend)

' // Create the pen and brush DIM yellowPen AS GpPen PTR hStatus = GdipCreatePen1(ARGB_YELLOW, 20, UnitWorld, @yellowPen) DIM brush AS GpBrush PTR hStatus = GdipCreateSolidFill(ARGB_RED, @brush)

' // Create GraphicsPath DIM path AS GpPath PTR hStatus = GdipCreatePath(FillModeAlternate, @path) ' // Add an ellipse hStatus = GdipAddPathEllipse(path, 50, 50, 200, 100) ' // Draw the path hStatus = GdipDrawPath(graphics, yellowPen, path)

' // Create an array of four points, and determine whether each ' // point in the array touches the outline of the path. ' // If a point touches the outline, paint it green. ' // If a point does not touch the outline, paint it red. DIM pts(3) AS GpPointF pts(0).x = 50 : pts(0).y = 100 pts(1).x = 270 : pts(1).y = 100 pts(2).x = 150 : pts(2).y = 170 pts(3).x = 180 : pts(3).y = 60

FOR i AS LONG = 0 TO 3

DIM result AS BOOL
  hStatus = GdipIsVisiblePathPoint(path, pts(i).x, pts(i).y, graphics, @result)
  IF result THEN
     hStatus = GdipSetSolidFillColor(brush, ARGB_LIGHTGREEN)
  ELSE
     hStatus = GdipSetSolidFillColor(brush, ARGB_RED)
  END IF
  hStatus = GdipFillEllipse(graphics, brush, pts(i).x - 3, pts(i).y - 3, 6, 6)

NEXT

' // Cleanup IF yellowPen THEN GdipDeleteBrush(yellowPen) IF brush THEN GdipDeleteBrush(brush) IF path THEN GdipDeletePath(path) IF graphics THEN GdipDeleteGraphics(graphics)

END SUB ' ========================================================================================

Reference

  • Defined in AfxNova/AfxGdiPlus.bi:2058
  • Documented in Graphics/GdiPlus Flat Api/GdiPlusGraphicsPath.md
  • Topic: GraphicsPath Functions