EndClip

Syntax

EndClip()

Description

Restores the clipping region that was active before the most recent call to either BeginClipBox() or BeginClipPath().

Parameters

This command takes no parameters.

Return Value

This command does not return a value.

Remarks

Every call to BeginClipBox() or BeginClipPath() must be balanced with a corresponding call to EndClip() to remove the clipping region and restore the previous clipping state from the internal stack.

Example

IncludeFile "ProGUI_PB.pbi"

StartProGUI()

Procedure DrawHandler(Window, EventType, *EventData.PG_EventDraw, *UserData)

    DrawClear(RGB(255, 255, 255), 1)

    ; Draw a red box partially clipped
    DrawBox(50, 50, 200, 150, RGB(255, 0, 0), 0.5) ; Draw background box first

    ; Set a clipping region
    BeginClipBox(100, 80, 100, 100)

    ; Draw a blue box - only the part inside the clip region will be visible
    DrawBox(50, 50, 200, 150, RGB(0, 0, 255), 1)

    ; Restore the previous clipping state (remove the clip box)
    EndClip()

    ; Draw text outside the clipped area (this will be fully visible)
    DrawTxt(*UserData, 50, 220, RGB(0,0,0))

EndProcedure

MyWindow = CreateWindow(0, 0, 300, 300, "Clipping Example")
MyText = CreateText("Text after EndClip()", "Arial", 12)

If MyWindow
  AddEventHandler(MyWindow, #PG_Event_Draw, @DrawHandler(), MyText)
  WindowShow(MyWindow, #True, #PG_Window_ScreenCentered)

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

FreeText(MyText)
StopProGUI()

See Also

BeginClipBox, BeginClipPath, BeginDraw, EndDraw, DrawSave, DrawRestore

Supported OS

Windows, Linux