ClipOutput()

Syntax

ClipOutput(x, y, Width, Height)
Description
Define a bounding box that restricts all drawing to the current drawing output. Any pixels drawn outside of this box will be clipped.

Parameters

x, y, Width, Height The position and size of the clipping box. The (x, y) coordinates are always absolute and not affected by calls to SetOrigin().

Return value

None.

Remarks

This command only has an effect on drawing outputs created by ImageOutput() or CanvasOutput().

The drawing origin is not modified by a call to this function. To make all drawing relative to the upper left corner of the clipping box, a separate call to SetOrigin() must be made if this is desired.

The Plot() and Point() commands perform no bounds checking for performance reasons and therefore are also not affected by this command.

Example

  If OpenWindow(0, 0, 0, 200, 200, "2DDrawing Example", #PB_Window_SystemMenu | #PB_Window_ScreenCentered)
    If CreateImage(0, 200, 200, 24, $FFFFFF) And StartDrawing(ImageOutput(0))

      ClipOutput(50, 50, 100, 100) ; restrict all drawing to this region
      Circle( 50,  50, 50, $0000FF)  
      Circle( 50, 150, 50, $00FF00)  
      Circle(150,  50, 50, $FF0000)  
      Circle(150, 150, 50, $00FFFF)  
      
      DrawingMode(#PB_2DDrawing_Outlined)
      Box(50, 50, 100, 100, $000000)
         
      StopDrawing() 
      ImageGadget(0, 0, 0, 200, 200, ImageID(0))      
    EndIf
    
    Repeat
      Event = WaitWindowEvent()
    Until Event = #PB_Event_CloseWindow
  EndIf

See Also

UnclipOutput(), SetOrigin(), OutputWidth(), OutputHeight()

Supported OS

All

<- CircularGradient() - 2DDrawing Index - ConicalGradient() ->