Syntax
Mode = DrawGetBlendMode()
Description
Retrieves the current blend mode set for the active drawing context. The blend mode determines how the colors of newly drawn shapes (source) are combined with the existing colors on the drawing target (destination).
Parameters
This command takes no parameters.
Return Value
Returns the current blend mode, which will be one of the following constants:
#PG_Blend_SourceOver : (Default) The source color is blended over the destination color based on the source alpha. Formula: result = source + destination * (1 - source_alpha).
#PG_Blend_Copy : The source color completely replaces the destination color, ignoring alpha. Formula: result = source.
#PG_Blend_Min : The minimum color component value between source and destination is used. Formula: result = min(source, destination). (Direct2D only)
#PG_Blend_Add : Source and destination color components are added together, clamped at 1.0. Formula: result = min(1.0, source + destination). (Direct2D only)
#PG_Blend_Max : The maximum color component value between source and destination is used. Formula: result = max(source, destination). (Direct2D only)
Returns #False if called outside a BeginDraw() / EndDraw() block.
Remarks
This function allows querying the current blend mode, which might have been changed using DrawSetBlendMode(). The default #PG_Blend_SourceOver
is standard alpha blending. Other modes can be used for specific effects but might only be available on
certain backends (like Direct2D).
Example
IncludeFile "ProGUI_PB.pbi"
StartProGUI()
Procedure DrawHandler(Window, EventType, *EventData.PG_EventDraw, *UserData)
DrawClear(RGB(0, 0, 0), 1) ; Black background
CurrentMode = DrawGetBlendMode()
Debug "Initial Blend Mode: " + Str(CurrentMode) ; Should be #PG_Blend_SourceOver (0)
; Draw semi-transparent boxes with default blending
DrawBox(10, 10, 100, 100, RGB(255, 0, 0), 0.7)
DrawBox(60, 60, 100, 100, RGB(0, 0, 255), 0.7)
; Change to Additive blending (if supported)
DrawSetBlendMode(#PG_Blend_Add)
CurrentMode = DrawGetBlendMode()
Debug "Changed Blend Mode: " + Str(CurrentMode) ; Might be #PG_Blend_Add (3) on Direct2D
; Draw overlapping boxes with additive blending
DrawBox(180, 10, 100, 100, RGB(255, 0, 0), 0.7)
DrawBox(230, 60, 100, 100, RGB(0, 0, 255), 0.7) ; Overlap area should appear brighter/magenta
; Restore default
DrawSetBlendMode(#PG_Blend_SourceOver)
EndProcedure
MyWindow = CreateWindow(0, 0, 400, 200, "Get BlendMode 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
DrawSetBlendMode, BeginDraw, EndDraw
Supported OS
Windows, Linux (Note: Some modes like Add, Min, Max are Direct2D specific)