DrawClear

Syntax

DrawClear(Color=0, Opacity.f=0)

Description

Clears the entire current drawing target (window or image) with the specified color and opacity.

Parameters

Color (optional)
The color to clear the target with, in RGB format (e.g., using RGB(r, g, b)). Default is 0 (black).

Opacity.f (optional)
The opacity of the clear operation, ranging from 0.0 (fully transparent) to 1.0 (fully opaque). Default is 0.0 (fully transparent). Setting this to 1.0 results in a solid color background.

Return Value

This command does not return a value.

Remarks

It's typically the first drawing command used in a draw handler to set the background color or ensure transparency before drawing other elements. When clearing with an opacity less than 1.0, the underlying content (if any) will show through. Clearing with an opacity of 0.0 makes the target completely transparent.

Example

IncludeFile "ProGUI_PB.pbi"

StartProGUI()

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

    ; Clear the window background to light blue
    DrawClear(RGB(200, 220, 255), 1.0)

    ; Draw something on top
    DrawBox(10, 10, 100, 50, RGB(255, 0, 0))

EndProcedure

MyWindow = CreateWindow(0, 0, 200, 100, "DrawClear Example")

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

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

StopProGUI()

See Also

BeginDraw, EndDraw, RGB()

Supported OS

Windows, Linux