DrawGetAntialias

Syntax

Mode = DrawGetAntialias()

Description

Retrieves the current anti-aliasing mode set for the active drawing context.

Parameters

This command takes no parameters.

Return Value

Returns the current anti-aliasing mode, which will be one of the following constants:

#PG_Antialias_PerPrimitive : (Default) Anti-aliasing is determined based on the primitive being drawn. Text is always anti-aliased (unless disabled in font options). Primitives like lines and curves are anti-aliased, while axis-aligned rectangles are typically not.
#PG_Antialias_Aliased      : All rendering is forced to be aliased (no anti-aliasing).

Returns #False if called outside a BeginDraw() / EndDraw() block.

Remarks

This function allows querying the current anti-aliasing setting, which might have been changed using DrawSetAntialias(). Anti-aliasing smooths the edges of shapes and text, generally improving visual quality at the cost of some performance.

Example

IncludeFile "ProGUI_PB.pbi"

StartProGUI()

Procedure DrawHandler(Window, EventType, *EventData.PG_EventDraw, *UserData)
  
    DrawClear(RGB(255, 255, 255), 1)

    CurrentMode = DrawGetAntialias()
    Debug "Initial Antialias Mode: " + Str(CurrentMode) ; Should be #PG_Antialias_PerPrimitive (0)

    ; Draw with default anti-aliasing
    DrawEllipse(50, 50, 40, 40, RGB(255, 0, 0))

    ; Change to aliased mode
    DrawSetAntialias(#PG_Antialias_Aliased)
    CurrentMode = DrawGetAntialias()
    Debug "Changed Antialias Mode: " + Str(CurrentMode) ; Should be #PG_Antialias_Aliased (1)

    ; Draw aliased
    DrawEllipse(150, 50, 40, 40, RGB(0, 0, 255))

    ; Restore default
    DrawSetAntialias(#PG_Antialias_PerPrimitive)

EndProcedure

MyWindow = CreateWindow(0, 0, 250, 150, "Get Antialias 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

DrawSetAntialias, BeginDraw, EndDraw

Supported OS

Windows, Linux