ClipPath()

Syntax

ClipPath([Flags])
Description
Clip the vector drawing output to the area defined by the current vector drawing path. Future drawing operations will only affect areas within the current path. The clipping will be combined with any clipping that previously existed on the drawing output.

By default, the path is reset after calling this function. This can be prevented with the appropriate flags.

Parameters

Flags (optional) Can be one of the following values:
  #PB_Path_Default     : No special behavior (default value)
  #PB_Path_Preserve    : Don't reset the path after this function

Return value

None.

Remarks

There is no "UnclipPath()" function: The clipping region of the drawing output can only be made smaller by adding further clipping, it cannot be made larger again. However, the clipping region can be saved and restored using the SaveVectorState() and RestoreVectorState() functions respectively. So in order to apply temporary clipping to the drawing output, first save the drawing state and later restore it to go back to the original clipping regions.

Example

  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)

    If StartVectorDrawing(CanvasVectorOutput(0))
    
      ; Setup a complex clipping path with nested ellipses (every second one will be clipped)
      For i = 10 To 150 Step 5
        AddPathEllipse(200, 100, 2*i, i)
      Next i
      ClipPath()
    
      ; Draw some text with this clipping
      VectorFont(FontID(0), 150)      
      VectorSourceColor(RGBA(255, 0, 0, 255))
      
      MovePathCursor(50, 25)
      DrawVectorText("Text")

      StopVectorDrawing()
    EndIf
    
    Repeat
      Event = WaitWindowEvent()
    Until Event = #PB_Event_CloseWindow
  EndIf

See Also

Supported OS

All

<- BeginVectorLayer() - VectorDrawing Index - ClosePath() ->