D2BackColor Variable

Requires: Direct2D.lg32

Purpose

Exported variable that allows to set the window background colour using an ARGB colour.

Syntax

D2BackColor = argb or argb = D2BackColor

argb: integer

Description

The windows background color is initialized to white. D2BackColor is only used in D2Clear as the default clearing color.

The variable must be initialized with an ARGB color value. The GB Direct2D library defines the Direct2D ARGB color constants for many colors. The names of these ARGB color constants start with D2C_ and are formatted as D2C_Colorname. An alternative is to use the ARGB conversion function.

Example

'

' D2BackColor sample (dpi-unaware)

'

$Library "direct2d"

Global Object Win1RT

OpenW 1, 0, 0, 320, 260, ~15

Set Win1RT = D2GetRT(Me.hWnd, 640, 480) ' window

' Here: create Win_1 render target resources

Do

Sleep

Until Me Is Nothing

 

Sub Win_1_Paint

D2BeginDraw Win1RT

D2BackColor = D2C_Bisque

D2Clear

D2ForeColor = D2C_Chocolate

D2DefLine , 4

D2Circle 320, 240, 100

D2EndDraw

EndSub

Remarks

Setting D2BackColor will not immediately clear the window as the Form property BackColor does. To clear the render target use D2Clear.

{Created by Sjouke Hamstra; Last updated: 07/03/2021 by James Gaite}