D2Clip command

Requires: Direct2D.lg32

Purpose

Enables or disables clipping.

Syntax

D2Clip x0!, y0!, x1!, y1!
D2Clip

x0!, y0!, x1!, y1!: float expression

Description

D2Clip clips an image with an axis-aligned clip rectangle. This approach produces only rectangular clips, because the content bounds are aligned to the axis of the clipping rectangle.

Enable the clipping by specifying a rectangle and disable clipping by using D2Clip without parameters.

Example

'

' D2Clip sample (dpi-unaware)

'

$Library "direct2d"

Global Object Win1RT

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

' DC 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

D2Clip 10, 10, 200, 60

D2DefFill D2C_Cyan

D2PBox 10, 10, 300, 100

'  D2Clip  ' not mandatory, D2EndDraw disables clipping

D2EndDraw

EndSub

Remarks

To set the clipping ID2D1RenderTarget::PushAxisAlignedClip is invoked, to disable clipping the library calls ID2D1RenderTarget::PopAxisAlignedClip. These methods are used in pairs, but that is not necessary with the Direct2D library, which pops the previous clipping when a new clipping rectangle is defined. In addition, D2EndDraw disables any clipping set.

D2Clip must be placed between the D2BeginDraw and D2EndDraw commands.

See Also

D2Transform

{Created by Sjouke Hamstra; Last updated: 20/03/2020 by James Gaite}