IsInsidePath()

Syntax

Result = IsInsidePath(x.d, y.d [, CoordinateSystem])
Description
Tests if the given coordinates are within a closed figure in the current vector drawing path. That is, this function returns non-zero if the given point would be filled by a call to FillPath().

Parameters

x.d, y.d Specifies the coordinates of the point to test.
CoordinateSystem (optional) Specifies the coordinate system for the point to test. This can be one of the following values:
  #PB_Coordinate_Device: The coordinate system of the output device
  #PB_Coordinate_Output: The coordinate system as it was created with the drawing output function
  #PB_Coordinate_User  : The coordinate system for points in the drawing path (default)
  #PB_Coordinate_Source: The coordinate system for the vector drawing source

Return value

Returns non-zero if the point is within the path and zero if not.

Remarks

See the vectordrawing overview for an introduction to the different coordinate systems.

Example

  
  ; This example uses the IsInsidePath() function to color the figure in green
  ; while the mouse is inside of it and blue otherwise
  ;
  Procedure Draw()    
    x = GetGadgetAttribute(0, #PB_Canvas_MouseX)
    y = GetGadgetAttribute(0, #PB_Canvas_MouseY)
  
    If StartVectorDrawing(CanvasVectorOutput(0))
      VectorSourceColor(RGBA(255, 255, 255, 255))   ; erase previous content
      FillVectorOutput()
      
      AddPathEllipse(200, 100, 150, 75)             ; prepare path
      
      If IsInsidePath(x, y, #PB_Coordinate_Device)  ; check if the mouse is inside
        VectorSourceColor(RGBA(0, 255, 0, 255))
      Else
        VectorSourceColor(RGBA(0, 0, 255, 255))
      EndIf
      
      FillPath()                                    ; fill path
      StopVectorDrawing()
    EndIf      
  EndProcedure
  
  If OpenWindow(0, 0, 0, 400, 200, "VectorDrawing", #PB_Window_SystemMenu | #PB_Window_ScreenCentered)
    CanvasGadget(0, 0, 0, 400, 200)
    LoadFont(0, "Times New Roman", 20, #PB_Font_Bold)
    Draw()
    
    Repeat
      Event = WaitWindowEvent()
      
      If Event = #PB_Event_Gadget And EventGadget() = 0 And EventType() = #PB_EventType_MouseMove
        Draw()
      EndIf
      
    Until Event = #PB_Event_CloseWindow
  EndIf

See Also

IsInsideStroke(), FillPath(), ClosePath(), ResetPath()

Supported OS

All

<- FlipCoordinatesY() - VectorDrawing Index - IsInsideStroke() ->