D2RBox and D2PRBox commands

Requires: Direct2D.lg32

Purpose

D2RBox draws a rounded rectangle in the render target's drawing area, while D2PRBox draws a filled rounded rectangle in the render target's drawing area.

Syntax

D2RBox x1!, y1!, x2!, y2! [,rx!, ry!] [,D2Brush]
D2PRBox x1!, y1!, x2!, y2! [,rx!, ry!] [,D2Brush]

x1!, y!, x2!, y2!, rx!, ry!: float expression
D2Brush: Object expression

Description

D2RBox draws the outline of a rounded rectangle from x1,y1 to x2,y2 in device-independent pixels. By default, the outline is drawn using a solid color brush created from the current foreground color D2ForeColor. If the application passes a D2Brush object, the stroke (line) is painted with that brush. Use D2DefLine to set the line style and width.

D2PRBox draws a filled rounded rectangle from x1,y1 to x2,y2 in device-independent pixels. By default, the rectangle's interior is painted using the brush set with D2DefFill. If the application specified a brush object with the D2PRBox command, the interior is painted with that brush. The outline of the rectangle is painted using the current foreground color. To prevent the painting of the outline set line-width to zero using D2DefLine , 0.

The radius of the rounding rx! and ry! default to 10 device-independent pixels for both commands.

Example

'

' D2(P)RBox sample (dpi-unaware)

'

$Library "direct2d"

Global Object Win1RT

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

' Rendertarget same size as clientarea

Set Win1RT = D2GetRT()

' Here: Create Win_1 render target resources

Do

Sleep

Until Me Is Nothing

 

Sub Win_1_Paint

D2BeginDraw Win1RT, D2C_White

D2ForeColor = D2C_Brown

D2Box 20, 20, 120, 120

D2DefFill D2C_Beige

D2PRBox 150, 20, 250, 120

D2EndDraw

EndSub

Remarks

Requires an active render target, either set with D2BeginDraw or D2SetRT.

All drawing commands must be placed between D2BeginDraw and D2EndDraw.

D2RBox invokes the ID2D1RenderTarget::DrawRoundedRectangle method and D2PRBox invokes the ID2D1RenderTarget::FillRoundedRectangle method.

See Also

D2PBox, D2Box, D2Line, D2SetRT, D2DefFill, D2DefLine, D2Brush, D2BeginDraw, D2EndDraw

{Created by James Gaite; Last updated: 15/03/2021 by James Gaite}