Skip to content

SysWin Direct2D Helpers

Paul Squires edited this page Oct 31, 2026 · 1 revision

Home › All Categories › sys/win › sys/win/direct2d › Direct2D helpers

Direct2D helpers

Builds the points, rectangles, colours, matrices and property records Direct2D calls take.

Direct2D methods take small structures by value or by reference: a D2D1_POINT_2F, a D2D1_RECT_F, a D2D1_COLOR_F, a D2D1_MATRIX_3X2_F, a D2D1_RENDER_TARGET_PROPERTIES. Each function on this page fills one of them from its arguments and returns it, so it can be written straight into a call: pTarget->FillEllipse( D2D1_EllipseF( 60, 35, 50, 25 ), pBrush ). They allocate nothing and need nothing released, apart from D2D1_SafeRelease, which releases an interface.

Coordinates are device-independent pixels (DIPs): 1/96 inch, so a render target at 96 DPI maps one DIP to one pixel. Colours are four single values from 0 to 1, red, green, blue and alpha. Angles are in degrees, clockwise on screen because y grows downwards.

The 3 × 2 matrices are row-vector affine transforms: a point is multiplied on the left, p * m, and a * b means "apply a, then b". The m31 and m32 cells hold the translation.

Importing

#import "sys/win"
#import "sys/win/direct2d"
using win, direct2d

Example

A transform built from two helpers, applied to a point and undone, and the colour and shape records a drawing call takes:

#import "sys/win"
#import "sys/win/direct2d"
using win, direct2d

' a transform: scale by 2 about (50, 50), then move 10 to the right
dim m as D2D1_MATRIX_3X2_F = D2D1_MatrixScale( 2, 2, D2D1_Point2F( 50, 50 ) ) * D2D1_MatrixTranslation( 10, 0 )
dim p as D2D1_POINT_2F = D2D1_Point2F( 60, 60 ) * m
print "(60, 60) maps to"; p.x; ","; p.y

' and back again
D2D1_InvertMatrix( m )
p = p * m
print "and back to"; p.x; ","; p.y

' a named colour as the four floats Direct2D uses
dim c as D2D1_COLOR_F = D2D1_ColorF( D2D1_Orange, 0.5 )
print "orange at half opacity:"; c.r; c.g; c.b; c.a

' the shapes the drawing calls take
dim rr as D2D1_ROUNDED_RECT = D2D1_RoundedRect( 10, 10, 110, 60, 8, 8 )
dim e as D2D1_ELLIPSE = D2D1_EllipseF( 60, 35, 50, 25 )
print "rounded rect"; rr.rect.left; rr.rect.top; rr.rect.right; rr.rect.bottom; ", ellipse radii"; e.radiusX; e.radiusY

It prints:

(60, 60) maps to 80, 70
and back to 60, 60
orange at half opacity: 1 0.6470588 0 0.5
rounded rect 10 10 110 60, ellipse radii 50 25

Functions

Function Does
D2D1_SafeRelease Releases an interface pointer and sets it to NULL.
D2D1_Point2F Makes a point with single coordinates.
D2D1_Point2U Makes a point with unsigned coordinates.
D2D1_Point2L Makes a point with signed 32-bit coordinates.
D2D1_SizeF Makes a single width and height.
D2D1_SizeU Makes an unsigned width and height.
D2D1_RectF Makes a rectangle with single edges.
D2D1_RectU Makes a rectangle with unsigned edges.
D2D1_RectL Makes a rectangle with signed 32-bit edges.
D2D1_InfiniteRect Makes a rectangle that covers the whole plane.
D2D1_InfiniteRectU Makes the largest unsigned rectangle.
D2D1_FloatMax Returns the largest single value.
D2D1_Vector2F Makes a two-component vector.
D2D1_Vector3F Makes a three-component vector.
D2D1_Vector_4F Makes a four-component vector.
D2D1_EllipseF Makes an ellipse from a centre and two radii.
D2D1_RoundedRect Makes a rectangle with rounded corners.
D2D1_ArcSegment Makes an elliptical arc segment for a path.
D2D1_BezierSegment Makes a cubic Bézier segment for a path.
D2D1_QuadraticBezierSegment Makes a quadratic Bézier segment for a path.
KnowColor The named colours, as &hRRGGBB values.
sc_redShift, sc_greenShift, sc_blueShift, sc_redMask, sc_greenMask, sc_blueMask Where each channel sits in an &hRRGGBB value.
D2D1_InitColorF Turns an &hRRGGBB value and an alpha into a colour.
D2D1_ColorF Makes a colour from &hRRGGBB or from four channels.
D2D1_GradientStop Makes one stop of a gradient.
D2D1_BrushProperties Makes the opacity and transform of a brush.
D2D1_BitmapBrushProperties Makes the extend and interpolation modes of a bitmap brush.
D2D1_LinearGradientBrushProperties Makes the start and end of a linear gradient.
D2D1_RadialGradientBrushProperties Makes the centre and radii of a radial gradient.
D2D1_StrokeStyleProperties Makes the caps, join and dashes of a stroke style.
D2D1_StrokeStyleProperties1 The same, with a stroke transform type.
D2D1_PixelFormat Makes a pixel format and alpha mode.
D2D1_BitmapProperties Makes the pixel format and DPI of a bitmap.
D2D1_BitmapProperties1 The same, with bitmap options and a colour context.
D2D1_RenderTargetProperties Makes the type, format, DPI and usage of a render target.
D2D1_HwndRenderTargetProperties Makes the window, size and present options of a window render target.
D2D1_LayerParameters Makes the bounds, mask and opacity of a layer.
D2D1_LayerParameters1 The same, with the newer layer options.
D2D1_DrawingStateDescription Makes the state a drawing state block saves.
D2D1_DrawingStateDescription1 The same, with primitive blend and unit mode.
D2D1_ImageBrushProperties Makes the source rectangle and modes of an image brush.
D2D1_ImageBrushProperties1 Makes the extend and interpolation modes of a newer bitmap brush.
D2D1_PrintControlProperties Makes the settings of a print control.
D2D1_RenderingControls Makes the buffer precision and tile size of a device context.
D2D1_EffectInputDescription Names an effect input and a rectangle on it.
D2D1_CreationProperties Makes the threading, debug and options of a new device.
D2D1_IdentityMatrix Returns the 3 × 2 identity matrix.
D2D1_Matrix3x2F Makes a 3 × 2 matrix from six values.
D2D1_MatrixTranslation Makes a translation.
D2D1_MatrixScale Makes a scale about a centre point.
D2D1_MatrixRotation Makes a rotation about a centre point.
D2D1_MatrixSkew Makes a skew about a centre point.
D2D1_MatrixDeterminant Returns the determinant of a 3 × 2 matrix.
D2D1_IsInvertibleMatrix Tells whether a 3 × 2 matrix can be inverted.
D2D1_InvertMatrix Inverts a 3 × 2 matrix in place.
D2D1_IsIdentityMatrix Tells whether a 3 × 2 matrix is the identity.
D2D1_MultiplyMatrices Multiplies two 3 × 2 matrices.
D2D1_MatrixTransformPoint Applies a 3 × 2 matrix to a point.
Operator * Multiplies matrices, or a point by a matrix.
D2D1_ComputeFlatteningTolerance Works out the flattening tolerance for a transform and DPI.
D2D1_Matrix4x3F Makes a 4 × 3 matrix.
D2D1_Matrix4x4F Makes a 4 × 4 matrix.
D2D1_Matrix4x4FTranslation Makes a 3D translation.
D2D1_Matrix4x4FScale Makes a 3D scale.
D2D1_Matrix4x4FRotationX Makes a rotation about the x axis.
D2D1_Matrix4x4FRotationY Makes a rotation about the y axis.
D2D1_Matrix4x4FRotationZ Makes a rotation about the z axis.
D2D1_Matrix4x4FRotationArbitraryAxis Makes a rotation about any axis.
D2D1_Matrix4x4FSkewX Makes a 3D skew along x.
D2D1_Matrix4x4FSkewY Makes a 3D skew along y.
D2D1_Matrix4x4FPerspectiveProjection Makes a perspective projection.
D2D1_Matrix4x4FDeterminant Returns the determinant of a 4 × 4 matrix.
D2D1_Matrix4x4FIsIdentity Tells whether a 4 × 4 matrix is the identity, within a tolerance.
D2D1_Matrix4x4FSetProduct Multiplies two 4 × 4 matrices.
D2D1_Matrix5x4F Makes a 5 × 4 colour matrix.
D2D1_GradientMeshPatch Makes a gradient mesh patch from 16 points and 4 colours.
D2D1_GradientMeshPatchFromCoonsPatch Makes a gradient mesh patch from the 12 points of a Coons patch.
D2D1_InkPoint Makes a point of an ink stroke.
D2D1_InkBezierSegment Makes a Bézier segment of an ink stroke.
D2D1_InkStyleProperties Makes the nib of an ink style.
D2D1_SimpleColorProfile Makes a colour profile from primaries, white point and gamma.

Reference

D2D1_SafeRelease

function D2D1_SafeRelease( byref pv as any ptr ) as ULONG

Calls Release on the interface pv points to and then sets pv to NULL, so the same variable can be released twice without harm. pv is taken by reference: pass the pointer variable itself, of any interface type (ID2D1Factory ptr, ID2D1SolidColorBrush ptr …). A NULL pointer is left alone.

Parameter Meaning
pv The interface pointer variable; it is NULL afterwards.

Returns the reference count after the release (meant for diagnostics only), or 0 when pv was already NULL.

Example

dim pFactory as ID2D1Factory ptr
D2D1CreateFactory( D2D1_FACTORY_TYPE_SINGLE_THREADED, IID_ID2D1Factory, byval NULL, pFactory )
D2D1_SafeRelease( pFactory )   ' pFactory is NULL now

Microsoft Learn: IUnknown::Release

D2D1_Point2F

function D2D1_Point2F( byval x as FLOAT = 0.0, byval y as FLOAT = 0.0 ) as D2D1_POINT_2F

Returns a point with single coordinates; with no arguments, (0, 0). This is the point type the drawing calls take.

Returns the D2D1_POINT_2F.

Example

dim pt as D2D1_POINT_2F = D2D1_Point2F( 10, 20 )
print pt.x; pt.y   ' 10 20

Microsoft Learn: Point2F

D2D1_Point2U

function D2D1_Point2U( byval x as DWORD = 0, byval y as DWORD = 0 ) as D2D1_POINT_2U

Returns a point with unsigned 32-bit coordinates, as taken by the bitmap copy calls.

Returns the D2D1_POINT_2U.

Example

dim pt as D2D1_POINT_2U = D2D1_Point2U( 3, 4 )

Microsoft Learn: Point2U

D2D1_Point2L

function D2D1_Point2L( byval x as INT32 = 0, byval y as INT32 = 0 ) as D2D1_POINT_2L

Returns a point with signed 32-bit coordinates. D2D1_POINT_2L is the Windows POINT structure, so the result can be passed wherever a POINT is wanted.

Returns the D2D1_POINT_2L.

Example

dim pt as D2D1_POINT_2L = D2D1_Point2L( -5, 6 )

Microsoft Learn: Point2L

D2D1_SizeF

function D2D1_SizeF( byval nWidth as FLOAT = 0.0, byval nHeight as FLOAT = 0.0 ) as D2D1_SIZE_F

Returns a width and height as single values.

Returns the D2D1_SIZE_F.

Example

dim sz as D2D1_SIZE_F = D2D1_SizeF( 640, 480 )
print sz.width; sz.height   ' 640 480

Microsoft Learn: SizeF

D2D1_SizeU

function D2D1_SizeU( byval nWidth as UINT32 = 0, byval nHeight as UINT32 = 0 ) as D2D1_SIZE_U

Returns a width and height as unsigned 32-bit values: the pixel size of a window render target or a bitmap.

Returns the D2D1_SIZE_U.

Example

var (l, t, r, b) = GetWindowClientRect( hwnd )
dim pixels as D2D1_SIZE_U = D2D1_SizeU( r, b )

Microsoft Learn: SizeU

D2D1_RectF

function D2D1_RectF( byval nLeft as FLOAT = 0.0, byval nTop as FLOAT = 0.0, byval nRight as FLOAT = 0.0, byval nBottom as FLOAT = 0.0 ) as D2D1_RECT_F

Returns a rectangle from its four edges (not from a width and height). This is the rectangle type the drawing calls take.

Returns the D2D1_RECT_F.

Example

dim rc as D2D1_RECT_F = D2D1_RectF( 10, 20, 110, 70 )   ' 100 x 50 at (10, 20)

Microsoft Learn: RectF

D2D1_RectU

function D2D1_RectU( byval nLeft as UINT32 = 0, byval nTop as UINT32 = 0, byval nRight as UINT32 = 0, byval nBottom as UINT32 = 0 ) as D2D1_RECT_U

Returns a rectangle with unsigned 32-bit edges, as taken by the bitmap copy calls.

Returns the D2D1_RECT_U.

Example

dim rc as D2D1_RECT_U = D2D1_RectU( 0, 0, 64, 64 )

Microsoft Learn: RectU

D2D1_RectL

function D2D1_RectL( byval nLeft as INT32 = 0, byval nTop as INT32 = 0, byval nRight as INT32 = 0, byval nBottom as INT32 = 0 ) as D2D1_RECT_L

Returns a rectangle with signed 32-bit edges. D2D1_RECT_L is the Windows RECT structure.

Returns the D2D1_RECT_L.

Example

dim rc as D2D1_RECT_L = D2D1_RectL( -1, -2, 3, 4 )

Microsoft Learn: RectL

D2D1_InfiniteRect

function D2D1_InfiniteRect() as D2D1_RECT_F

Returns a rectangle from (−3.402823e+38, −3.402823e+38) to (3.402823e+38, 3.402823e+38): the largest single value on each side, which Direct2D treats as "no bounds". It is the default content bounds of a layer.

Returns the D2D1_RECT_F.

Example

dim rc as D2D1_RECT_F = D2D1_InfiniteRect()
print rc.right   ' 3.402823e+038

Microsoft Learn: InfiniteRect

D2D1_InfiniteRectU

function D2D1_InfiniteRectU() as D2D1_RECT_U

Returns the unsigned rectangle from (0, 0) to (&hFFFFFFFF, &hFFFFFFFF), the largest UINT32 on both sides.

Returns the D2D1_RECT_U.

Example

dim rc as D2D1_RECT_U = D2D1_InfiniteRectU()
print rc.right   ' 4294967295, that is &hFFFFFFFF

Microsoft Learn: InfiniteRectU

D2D1_FloatMax

function D2D1_FloatMax() as FLOAT

Returns the largest finite single value, 3.402823e+38.

Returns the value.

Example

print D2D1_FloatMax()   ' 3.402823e+038

Microsoft Learn: FloatMax

D2D1_Vector2F

function D2D1_Vector2F( byval x as FLOAT = 0.0, byval y as FLOAT = 0.0 ) as D2D1_VECTOR_2F

Returns a two-component vector, as some effect properties take.

Returns the D2D1_VECTOR_2F.

Example

dim v as D2D1_VECTOR_2F = D2D1_Vector2F( 1, 2 )

Microsoft Learn: Vector2F

D2D1_Vector3F

function D2D1_Vector3F( byval x as FLOAT = 0.0, byval y as FLOAT = 0.0, byval z as FLOAT = 0.0 ) as D2D1_VECTOR_3F

Meant to return a three-component vector. As written it stores x in x and z in y, and leaves z at 0: D2D1_Vector3F( 1, 2, 3 ) gives (1, 3, 0). Set the fields yourself when all three matter.

Returns the D2D1_VECTOR_3F.

Example

dim v as D2D1_VECTOR_3F
v.x = 1 : v.y = 2 : v.z = 3   ' D2D1_Vector3F( 1, 2, 3 ) would give 1 3 0

Microsoft Learn: Vector3F

D2D1_Vector_4F

function D2D1_Vector_4F( byval x as FLOAT = 0.0, byval y as FLOAT = 0.0, byval z as FLOAT = 0.0, byval w as FLOAT = 0.0 ) as D2D1_VECTOR_4F

Meant to return a four-component vector (note the underscore in the name). As written it stores x in x and w in y, and leaves z and w at 0: D2D1_Vector_4F( 1, 2, 3, 4 ) gives (1, 4, 0, 0). Set the fields yourself when they matter.

Returns the D2D1_VECTOR_4F.

Example

dim v as D2D1_VECTOR_4F
v.x = 1 : v.y = 2 : v.z = 3 : v.w = 4   ' D2D1_Vector_4F( 1, 2, 3, 4 ) would give 1 4 0 0

Microsoft Learn: Vector4F

D2D1_EllipseF

function D2D1_EllipseF overload( byval center as D2D1_POINT_2F, byval radiusX as FLOAT, byval radiusY as FLOAT ) as D2D1_ELLIPSE
function D2D1_EllipseF overload( byval x as FLOAT, byval y as FLOAT, byval radiusX as FLOAT, byval radiusY as FLOAT ) as D2D1_ELLIPSE

Returns an ellipse from its centre, given as a point or as x and y, and its horizontal and vertical radii. Equal radii give a circle. DrawEllipse and FillEllipse take it.

Parameter Meaning
center or x, y The centre.
radiusX, radiusY Half the width and half the height.

Returns the D2D1_ELLIPSE.

Example

dim pTarget as ID2D1RenderTarget ptr, pBrush as ID2D1SolidColorBrush ptr
if pTarget then pTarget->FillEllipse( D2D1_EllipseF( 100, 100, 50, 30 ), pBrush )

Microsoft Learn: Ellipse

D2D1_RoundedRect

function D2D1_RoundedRect overload( byref rc as D2D1_RECT_F, byval radiusX as FLOAT, byval radiusY as FLOAT ) as D2D1_ROUNDED_RECT
function D2D1_RoundedRect overload( byval nLeft as FLOAT, byval nTop as FLOAT, byval nRight as FLOAT, byval nBottom as FLOAT, byval radiusX as FLOAT, byval radiusY as FLOAT ) as D2D1_ROUNDED_RECT

Returns a rectangle, given as a D2D1_RECT_F or as four edges, with the horizontal and vertical radii of its corners. DrawRoundedRectangle and FillRoundedRectangle take it.

Returns the D2D1_ROUNDED_RECT.

Example

dim rr as D2D1_ROUNDED_RECT = D2D1_RoundedRect( D2D1_RectF( 0, 0, 100, 50 ), 8, 8 )

Microsoft Learn: RoundedRect

D2D1_ArcSegment

function D2D1_ArcSegment( byref pf as D2D1_POINT_2F, byref sf as D2D1_SIZE_F, byval rotationAngle as FLOAT, byval sweepDirection as D2D1_SWEEP_DIRECTION, byval arcSize as D2D1_ARC_SIZE ) as D2D1_ARC_SEGMENT

Returns an elliptical arc for a geometry sink's AddArc: the arc runs from the sink's current point to pf along an ellipse of radii sf.

Parameter Meaning
pf The end point of the arc.
sf The x and y radii of the ellipse.
rotationAngle Rotation of the ellipse, in degrees, clockwise.
sweepDirection D2D1_SWEEP_DIRECTION_CLOCKWISE or D2D1_SWEEP_DIRECTION_COUNTER_CLOCKWISE.
arcSize D2D1_ARC_SIZE_SMALL (180° or less) or D2D1_ARC_SIZE_LARGE.

Returns the D2D1_ARC_SEGMENT.

Example

dim seg as D2D1_ARC_SEGMENT = D2D1_ArcSegment( D2D1_Point2F( 100, 50 ), D2D1_SizeF( 50, 25 ), 0, D2D1_SWEEP_DIRECTION_CLOCKWISE, D2D1_ARC_SIZE_SMALL )

Microsoft Learn: ArcSegment

D2D1_BezierSegment

function D2D1_BezierSegment( byref point1 as D2D1_POINT_2F, byref point2 as D2D1_POINT_2F, byref point3 as D2D1_POINT_2F ) as D2D1_BEZIER_SEGMENT

Returns a cubic Bézier segment for a geometry sink's AddBezier: point1 and point2 are the control points and point3 the end point; the start is the sink's current point.

Returns the D2D1_BEZIER_SEGMENT.

Example

dim bz as D2D1_BEZIER_SEGMENT = D2D1_BezierSegment( D2D1_Point2F( 30, 0 ), D2D1_Point2F( 70, 100 ), D2D1_Point2F( 100, 50 ) )

Microsoft Learn: BezierSegment

D2D1_QuadraticBezierSegment

function D2D1_QuadraticBezierSegment( byref point1 as D2D1_POINT_2F, byref point2 as D2D1_POINT_2F ) as D2D1_QUADRATIC_BEZIER_SEGMENT

Returns a quadratic Bézier segment for a geometry sink's AddQuadraticBezier: point1 is the control point and point2 the end point.

Returns the D2D1_QUADRATIC_BEZIER_SEGMENT.

Example

dim q as D2D1_QUADRATIC_BEZIER_SEGMENT = D2D1_QuadraticBezierSegment( D2D1_Point2F( 50, 0 ), D2D1_Point2F( 100, 50 ) )

Microsoft Learn: QuadraticBezierSegment

KnowColor

enum KnowColor
   D2D1_AliceBlue = &HF0F8FF
   ...
   D2D1_YellowGreen = &H9ACD32
end enum

The 140 named web colours, from D2D1_AliceBlue to D2D1_YellowGreen, each an &hRRGGBB value with red in the high byte: D2D1_Red is &hFF0000, D2D1_CornflowerBlue is &h6495ED. This is the opposite byte order from a GDI COLORREF, so pass these to D2D1_ColorF or D2D1_GradientStop, not to GDI. D2D1_Aqua and D2D1_Cyan, and D2D1_Fuchsia and D2D1_Magenta, are the same colour.

Example

dim c as D2D1_COLOR_F = D2D1_ColorF( D2D1_CornflowerBlue )
print c.r; c.g; c.b   ' 0.3921569 0.5843138 0.9294118

Microsoft Learn: ColorF

sc_redShift, sc_greenShift, sc_blueShift, sc_redMask, sc_greenMask, sc_blueMask

const as UINT32 sc_redShift = 16
const as UINT32 sc_greenShift = 8
const as UINT32 sc_blueShift = 0
const as UINT32 sc_redMask = &H00FF0000
const as UINT32 sc_greenMask = &H0000FF00
const as UINT32 sc_blueMask = &H000000FF

The bit position and mask of each channel in an &hRRGGBB value, as D2D1_InitColorF reads it.

Example

dim green as UINT32 = ( D2D1_Orange and sc_greenMask ) shr sc_greenShift
print green   ' 165

D2D1_InitColorF

function D2D1_InitColorF( byval urgb as UINT32, byval alpha as FLOAT ) as D2D1_COLOR_F

Splits an &hRRGGBB value into red, green and blue, divides each by 255 and adds alpha. It is the worker behind the first form of D2D1_ColorF, which is usually the one to call.

Returns the D2D1_COLOR_F.

Example

dim c as D2D1_COLOR_F = D2D1_InitColorF( &h0000FF, 0.75 )   ' 0 0 1 0.75

D2D1_ColorF

function D2D1_ColorF overload( byval urgb as UINT32, byval a as FLOAT = 1.0 ) as D2D1_COLOR_F
function D2D1_ColorF overload( byval red as FLOAT, byval green as FLOAT, byval blue as FLOAT, byval alpha as FLOAT = 1.0 ) as D2D1_COLOR_F

Returns a colour. The first form takes an &hRRGGBB value, such as a KnowColor name, and an opacity; the second takes the four channels as numbers from 0 to 1. Alpha defaults to 1, fully opaque.

The colour is straight (not premultiplied) alpha; Direct2D premultiplies it itself where the target needs it.

Parameter Meaning
urgb Red, green and blue as &hRRGGBB.
a, alpha Opacity, 0 (transparent) to 1 (opaque).
red, green, blue Each channel, 0 to 1.

Returns the D2D1_COLOR_F.

Example

dim pTarget as ID2D1RenderTarget ptr
if pTarget then pTarget->Clear( D2D1_ColorF( D2D1_White ) )
dim c as D2D1_COLOR_F = D2D1_ColorF( &hFF8000, 0.5 )   ' 1 0.5019608 0 0.5

Microsoft Learn: ColorF

D2D1_GradientStop

function D2D1_GradientStop overload( byval position as FLOAT, byref clr as D2D1_COLOR_F ) as D2D1_GRADIENT_STOP
function D2D1_GradientStop overload( byval position as FLOAT, byval clr as UINT32, byval alpha as FLOAT = 1.0 ) as D2D1_GRADIENT_STOP

Returns one stop of a gradient: a colour, as a D2D1_COLOR_F or as &hRRGGBB and an alpha, and its position along the gradient from 0 to 1. An array of stops goes to CreateGradientStopCollection.

Returns the D2D1_GRADIENT_STOP.

Example

dim stops(1) as D2D1_GRADIENT_STOP
stops(0) = D2D1_GradientStop( 0, D2D1_Yellow )
stops(1) = D2D1_GradientStop( 1, D2D1_ColorF( 0, 0, 1 ) )

Microsoft Learn: GradientStop

D2D1_BrushProperties

function D2D1_BrushProperties( byval opacity as FLOAT = 1.0, byref transform as D2D1_MATRIX_3X2_F = D2D1_IdentityMatrix() ) as D2D1_BRUSH_PROPERTIES

Returns the opacity (0 to 1) and transform shared by every kind of brush. The defaults, opaque and untransformed, are what most brushes want, so D2D1_BrushProperties() is the usual second argument to CreateSolidColorBrush.

Returns the D2D1_BRUSH_PROPERTIES.

Example

dim pTarget as ID2D1RenderTarget ptr, pBrush as ID2D1SolidColorBrush ptr
if pTarget then pTarget->CreateSolidColorBrush( D2D1_ColorF( D2D1_Navy ), D2D1_BrushProperties( 0.5 ), pBrush )

Microsoft Learn: BrushProperties

D2D1_BitmapBrushProperties

function D2D1_BitmapBrushProperties( byval extendModeX as D2D1_EXTEND_MODE = D2D1_EXTEND_MODE_CLAMP, byval extendModeY as D2D1_EXTEND_MODE = D2D1_EXTEND_MODE_CLAMP, byref interpolationMode as D2D1_BITMAP_INTERPOLATION_MODE = D2D1_BITMAP_INTERPOLATION_MODE_LINEAR ) as D2D1_BITMAP_BRUSH_PROPERTIES

Returns how a bitmap brush paints beyond its bitmap in each direction (D2D1_EXTEND_MODE_CLAMP, _WRAP to tile, _MIRROR) and how the bitmap is sampled when scaled.

Returns the D2D1_BITMAP_BRUSH_PROPERTIES.

Example

dim bbp as D2D1_BITMAP_BRUSH_PROPERTIES = D2D1_BitmapBrushProperties( D2D1_EXTEND_MODE_WRAP, D2D1_EXTEND_MODE_WRAP )

Microsoft Learn: BitmapBrushProperties

D2D1_LinearGradientBrushProperties

function D2D1_LinearGradientBrushProperties( byref startPoint as const D2D1_POINT_2F, byref endPoint as const D2D1_POINT_2F ) as D2D1_LINEAR_GRADIENT_BRUSH_PROPERTIES

Returns the line a linear gradient runs along: stop position 0 is drawn at startPoint and 1 at endPoint, in the brush's coordinates.

Returns the D2D1_LINEAR_GRADIENT_BRUSH_PROPERTIES.

Example

dim lg as D2D1_LINEAR_GRADIENT_BRUSH_PROPERTIES = D2D1_LinearGradientBrushProperties( D2D1_Point2F( 0, 0 ), D2D1_Point2F( 200, 0 ) )

Microsoft Learn: LinearGradientBrushProperties

D2D1_RadialGradientBrushProperties

function D2D1_RadialGradientBrushProperties( byref center as D2D1_POINT_2F, byref gradientOriginOffset as D2D1_POINT_2F, byval radiusX as FLOAT, byval radiusY as FLOAT ) as D2D1_RADIAL_GRADIENT_BRUSH_PROPERTIES

Returns the ellipse a radial gradient fills: stop 1 lies on the ellipse of radii radiusX, radiusY around center, and stop 0 at the gradient origin, which is center moved by gradientOriginOffset.

Returns the D2D1_RADIAL_GRADIENT_BRUSH_PROPERTIES.

Example

dim rg as D2D1_RADIAL_GRADIENT_BRUSH_PROPERTIES = D2D1_RadialGradientBrushProperties( D2D1_Point2F( 100, 100 ), D2D1_Point2F( 0, 0 ), 80, 60 )

Microsoft Learn: RadialGradientBrushProperties

D2D1_StrokeStyleProperties

function D2D1_StrokeStyleProperties( byval startCap as D2D1_CAP_STYLE = D2D1_CAP_STYLE_FLAT, byval endCap as D2D1_CAP_STYLE = D2D1_CAP_STYLE_FLAT, byval dashCap as D2D1_CAP_STYLE = D2D1_CAP_STYLE_FLAT, byval lineJoin as D2D1_LINE_JOIN = D2D1_LINE_JOIN_MITER, byval miterLimit as FLOAT = 10.0, byval dashStyle as D2D1_DASH_STYLE = D2D1_DASH_STYLE_SOLID, byval dashOffset as FLOAT = 0.0 ) as D2D1_STROKE_STYLE_PROPERTIES

Returns the settings of a stroke style for the factory's CreateStrokeStyle. The defaults give a plain solid line with flat ends and mitred corners.

Parameter Meaning
startCap, endCap Shape of the two ends of an open figure: D2D1_CAP_STYLE_FLAT, _SQUARE, _ROUND, _TRIANGLE.
dashCap Shape of the ends of each dash.
lineJoin Corners: D2D1_LINE_JOIN_MITER, _BEVEL, _ROUND, _MITER_OR_BEVEL.
miterLimit How far a mitred corner may stick out, in multiples of half the stroke width.
dashStyle D2D1_DASH_STYLE_SOLID, _DASH, _DOT, _DASH_DOT, _DASH_DOT_DOT, _CUSTOM.
dashOffset Where in the dash pattern the line starts, in stroke widths.

Returns the D2D1_STROKE_STYLE_PROPERTIES.

Example

dim ssp as D2D1_STROKE_STYLE_PROPERTIES = D2D1_StrokeStyleProperties( D2D1_CAP_STYLE_ROUND, D2D1_CAP_STYLE_ROUND, D2D1_CAP_STYLE_ROUND, D2D1_LINE_JOIN_ROUND, 10, D2D1_DASH_STYLE_DASH )

Microsoft Learn: StrokeStyleProperties

D2D1_StrokeStyleProperties1

function D2D1_StrokeStyleProperties1( byval startCap as D2D1_CAP_STYLE = D2D1_CAP_STYLE_FLAT, byval endCap as D2D1_CAP_STYLE = D2D1_CAP_STYLE_FLAT, byval dashCap as D2D1_CAP_STYLE = D2D1_CAP_STYLE_FLAT, byval lineJoin as D2D1_LINE_JOIN = D2D1_LINE_JOIN_MITER, byval miterLimit as FLOAT = 10, byval dashStyle as D2D1_DASH_STYLE = D2D1_DASH_STYLE_SOLID, byval dashOffset as FLOAT = 0.0, byval transformType as D2D1_STROKE_TRANSFORM_TYPE = D2D1_STROKE_TRANSFORM_TYPE_NORMAL ) as D2D1_STROKE_STYLE_PROPERTIES1

The same as D2D1_StrokeStyleProperties, for ID2D1Factory1's CreateStrokeStyle, plus transformType: D2D1_STROKE_TRANSFORM_TYPE_NORMAL scales the stroke with the world transform, _FIXED keeps its width, _HAIRLINE draws it one pixel wide.

Returns the D2D1_STROKE_STYLE_PROPERTIES1.

Example

dim ssp as D2D1_STROKE_STYLE_PROPERTIES1 = D2D1_StrokeStyleProperties1( , , , , , , , D2D1_STROKE_TRANSFORM_TYPE_FIXED )

Microsoft Learn: StrokeStyleProperties1

D2D1_PixelFormat

function D2D1_PixelFormat( byval dxgiFormat as DXGI_FORMAT = DXGI_FORMAT_UNKNOWN, byval alphaMode as D2D1_ALPHA_MODE = D2D1_ALPHA_MODE_UNKNOWN ) as D2D1_PIXEL_FORMAT

Returns a pixel format and alpha mode. With no arguments both are "unknown" (0), which lets a render target choose its own format.

Returns the D2D1_PIXEL_FORMAT.

Example

dim pf as D2D1_PIXEL_FORMAT = D2D1_PixelFormat( DXGI_FORMAT_B8G8R8A8_UNORM, D2D1_ALPHA_MODE_PREMULTIPLIED )

Microsoft Learn: PixelFormat

D2D1_BitmapProperties

function D2D1_BitmapProperties( byref pixelFormat as D2D1_PIXEL_FORMAT = D2D1_PixelFormat(), byval dpiX as FLOAT = 96.0, byval dpiY as FLOAT = 96.0 ) as D2D1_BITMAP_PROPERTIES

Returns the pixel format and resolution of a bitmap for CreateBitmap and its relatives. The DPI defaults to 96, so one bitmap pixel is one DIP.

Returns the D2D1_BITMAP_PROPERTIES.

Example

dim bp as D2D1_BITMAP_PROPERTIES = D2D1_BitmapProperties( D2D1_PixelFormat( DXGI_FORMAT_B8G8R8A8_UNORM, D2D1_ALPHA_MODE_PREMULTIPLIED ) )

Microsoft Learn: BitmapProperties

D2D1_BitmapProperties1

function D2D1_BitmapProperties1( byval bitmapOptions as D2D1_BITMAP_OPTIONS = D2D1_BITMAP_OPTIONS_NONE, byval pixelFormat as const D2D1_PIXEL_FORMAT = D2D1_PixelFormat(), byval dpiX as FLOAT = 96.0, byval dpiY as FLOAT = 96.0, byval colorContext as ID2D1ColorContext ptr = NULL ) as D2D1_BITMAP_PROPERTIES1

Returns the properties of an ID2D1Bitmap1 for a device context: how the bitmap may be used (D2D1_BITMAP_OPTIONS_TARGET, _CPU_READ, _CANNOT_DRAW, _GDI_COMPATIBLE, combined with or), its format, DPI and an optional colour context. The colour context is stored as given, without an extra reference.

Returns the D2D1_BITMAP_PROPERTIES1.

Example

dim bp as D2D1_BITMAP_PROPERTIES1 = D2D1_BitmapProperties1( D2D1_BITMAP_OPTIONS_TARGET, D2D1_PixelFormat( DXGI_FORMAT_B8G8R8A8_UNORM, D2D1_ALPHA_MODE_PREMULTIPLIED ) )

Microsoft Learn: BitmapProperties1

D2D1_RenderTargetProperties

function D2D1_RenderTargetProperties( byval nType as D2D1_RENDER_TARGET_TYPE = D2D1_RENDER_TARGET_TYPE_DEFAULT, byref pixelFormat as D2D1_PIXEL_FORMAT = D2D1_PixelFormat(), byval dpiX as FLOAT = 0.0, byval dpiY as FLOAT = 0.0, byval usage as D2D1_RENDER_TARGET_USAGE = D2D1_RENDER_TARGET_USAGE_NONE, byval minLevel as D2D1_FEATURE_LEVEL = D2D1_FEATURE_LEVEL_DEFAULT ) as D2D1_RENDER_TARGET_PROPERTIES

Returns the settings every render target is created with. The defaults ask for hardware rendering where available, the target's own pixel format and the desktop DPI (0 means "use the default"), which suits a window render target. A DC render target needs an explicit format, such as DXGI_FORMAT_B8G8R8A8_UNORM with D2D1_ALPHA_MODE_IGNORE.

Parameter Meaning
nType D2D1_RENDER_TARGET_TYPE_DEFAULT, _SOFTWARE or _HARDWARE.
pixelFormat The pixel format and alpha mode.
dpiX, dpiY The DPI; 0 for the default.
usage D2D1_RENDER_TARGET_USAGE_* flags, such as _GDI_COMPATIBLE.
minLevel The lowest Direct3D feature level accepted for hardware rendering.

Returns the D2D1_RENDER_TARGET_PROPERTIES.

Example

dim rtp as D2D1_RENDER_TARGET_PROPERTIES = D2D1_RenderTargetProperties( D2D1_RENDER_TARGET_TYPE_DEFAULT, D2D1_PixelFormat( DXGI_FORMAT_B8G8R8A8_UNORM, D2D1_ALPHA_MODE_IGNORE ) )

Microsoft Learn: RenderTargetProperties

D2D1_HwndRenderTargetProperties

function D2D1_HwndRenderTargetProperties overload( byval hwnd as HWND, byref pixelSize as D2D1_SIZE_U = D2D1_SizeU(0, 0), byval presentOptions as D2D1_PRESENT_OPTIONS = D2D1_PRESENT_OPTIONS_NONE ) as D2D1_HWND_RENDER_TARGET_PROPERTIES
function D2D1_HwndRenderTargetProperties overload( byval hwnd as HWND, byref pixelWidth as UINT32 = 0, byref pixelHeight as UINT32 = 0, byval presentOptions as D2D1_PRESENT_OPTIONS = D2D1_PRESENT_OPTIONS_NONE ) as D2D1_HWND_RENDER_TARGET_PROPERTIES

Returns the window a window render target draws into, its size in pixels (usually the client area's), and how it presents. D2D1_PRESENT_OPTIONS_IMMEDIATELY does not wait for the display refresh; _RETAIN_CONTENTS keeps the previous frame.

The two forms have the same defaults after hwnd, so a call that passes only the window matches both and does not compile: pass the size as well. In the second form pixelWidth and pixelHeight are byref UINT32, so pass numbers or UINT32 variables; a long variable does not convert, which is why the example uses the D2D1_SizeU form for the client size.

Returns the D2D1_HWND_RENDER_TARGET_PROPERTIES.

Example

var (l, t, r, b) = GetWindowClientRect( hwnd )
dim hp as D2D1_HWND_RENDER_TARGET_PROPERTIES = D2D1_HwndRenderTargetProperties( hwnd, D2D1_SizeU( r, b ) )
hp = D2D1_HwndRenderTargetProperties( hwnd, 320, 240, D2D1_PRESENT_OPTIONS_IMMEDIATELY )

Microsoft Learn: HwndRenderTargetProperties

D2D1_LayerParameters

function D2D1_LayerParameters( byref contentBounds as D2D1_RECT_F = D2D1_InfiniteRect(), byval geometricMask as ID2D1Geometry ptr = NULL, byval maskAntialiasMode as D2D1_ANTIALIAS_MODE = D2D1_ANTIALIAS_MODE_PER_PRIMITIVE, byref maskTransform as D2D1_MATRIX_3X2_F = D2D1_IdentityMatrix(), byref opacity as FLOAT = 1.0, byval opacityBrush as ID2D1Brush ptr = NULL, byval layerOptions as D2D1_LAYER_OPTIONS = D2D1_LAYER_OPTIONS_NONE ) as D2D1_LAYER_PARAMETERS

Returns the parameters of PushLayer: what is drawn until the matching PopLayer is kept inside contentBounds and geometricMask, and faded by opacity and opacityBrush. The defaults clip and fade nothing. The geometry and brush pointers are stored as given, without an extra reference.

Parameter Meaning
contentBounds Content outside this rectangle is dropped.
geometricMask A geometry to clip to, or NULL.
maskAntialiasMode Antialiasing of the mask's edge.
maskTransform Transform applied to the mask.
opacity Opacity of the layer, 0 to 1.
opacityBrush A brush whose alpha fades the layer, or NULL.
layerOptions D2D1_LAYER_OPTIONS_INITIALIZE_FOR_CLEARTYPE or none.

Returns the D2D1_LAYER_PARAMETERS.

Example

dim pTarget as ID2D1RenderTarget ptr, pLayer as ID2D1Layer ptr
if pTarget then pTarget->PushLayer( D2D1_LayerParameters( D2D1_RectF( 0, 0, 200, 100 ), , , , 0.5 ), pLayer )

Microsoft Learn: LayerParameters

D2D1_LayerParameters1

function D2D1_LayerParameters1( byref contentBounds as const D2D1_RECT_F = D2D1_InfiniteRect(), byval geometricMask as ID2D1Geometry ptr = NULL, byval maskAntialiasMode as D2D1_ANTIALIAS_MODE = D2D1_ANTIALIAS_MODE_PER_PRIMITIVE, byref maskTransform as D2D1_MATRIX_3X2_F = D2D1_IdentityMatrix(), byval opacity as FLOAT = 1.0, byval opacityBrush as ID2D1Brush ptr = NULL, byval layerOptions as D2D1_LAYER_OPTIONS1 = D2D1_LAYER_OPTIONS1_NONE ) as D2D1_LAYER_PARAMETERS1

The same as D2D1_LayerParameters, for a device context, with the Direct2D 1.1 options: D2D1_LAYER_OPTIONS1_INITIALIZE_FROM_BACKGROUND and D2D1_LAYER_OPTIONS1_IGNORE_ALPHA.

Returns the D2D1_LAYER_PARAMETERS1.

Example

dim lp as D2D1_LAYER_PARAMETERS1 = D2D1_LayerParameters1( , , , , 0.75 )

Microsoft Learn: LayerParameters1

D2D1_DrawingStateDescription

function D2D1_DrawingStateDescription( byval antialiasMode as D2D1_ANTIALIAS_MODE = D2D1_ANTIALIAS_MODE_PER_PRIMITIVE, byval textAntialiasMode as D2D1_TEXT_ANTIALIAS_MODE = D2D1_TEXT_ANTIALIAS_MODE_DEFAULT, byval tag1 as D2D1_TAG = 0, byval tag2 as D2D1_TAG = 0, byref transform as D2D1_MATRIX_3X2_F = D2D1_IdentityMatrix() ) as D2D1_DRAWING_STATE_DESCRIPTION

Returns the state a drawing state block holds: the antialias modes, the two tags used to find failing calls, and the transform. The defaults are a render target's initial state.

Returns the D2D1_DRAWING_STATE_DESCRIPTION.

Example

dim ds as D2D1_DRAWING_STATE_DESCRIPTION = D2D1_DrawingStateDescription( D2D1_ANTIALIAS_MODE_ALIASED )

Microsoft Learn: DrawingStateDescription

D2D1_DrawingStateDescription1

function D2D1_DrawingStateDescription1 overload( byval antialiasMode as D2D1_ANTIALIAS_MODE = D2D1_ANTIALIAS_MODE_PER_PRIMITIVE, byval textAntialiasMode as D2D1_TEXT_ANTIALIAS_MODE = D2D1_TEXT_ANTIALIAS_MODE_DEFAULT, byval tag1 as D2D1_TAG = 0, byval tag2 as D2D1_TAG = 0, byref transform as D2D1_MATRIX_3X2_F = D2D1_IdentityMatrix(), byval primitiveBlend as D2D1_PRIMITIVE_BLEND = D2D1_PRIMITIVE_BLEND_SOURCE_OVER, byval unitMode as D2D1_UNIT_MODE = D2D1_UNIT_MODE_DIPS ) as D2D1_DRAWING_STATE_DESCRIPTION1
function D2D1_DrawingStateDescription1 overload( byref desc as const D2D1_DRAWING_STATE_DESCRIPTION, byval primitiveBlend as D2D1_PRIMITIVE_BLEND = D2D1_PRIMITIVE_BLEND_SOURCE_OVER, byval unitMode as D2D1_UNIT_MODE = D2D1_UNIT_MODE_DIPS ) as D2D1_DRAWING_STATE_DESCRIPTION1

The device-context version of D2D1_DrawingStateDescription, with the primitive blend and whether units are DIPs or pixels. The second form copies an existing D2D1_DRAWING_STATE_DESCRIPTION and adds the two.

Returns the D2D1_DRAWING_STATE_DESCRIPTION1.

Example

dim ds as D2D1_DRAWING_STATE_DESCRIPTION = D2D1_DrawingStateDescription()
dim ds1 as D2D1_DRAWING_STATE_DESCRIPTION1 = D2D1_DrawingStateDescription1( ds, D2D1_PRIMITIVE_BLEND_COPY, D2D1_UNIT_MODE_PIXELS )

Microsoft Learn: DrawingStateDescription1

D2D1_ImageBrushProperties

function D2D1_ImageBrushProperties( byval sourceRectangle as D2D1_RECT_F, byval extendModeX as D2D1_EXTEND_MODE = D2D1_EXTEND_MODE_CLAMP, byval extendModeY as D2D1_EXTEND_MODE = D2D1_EXTEND_MODE_CLAMP, byval interpolationMode as D2D1_INTERPOLATION_MODE = D2D1_INTERPOLATION_MODE_LINEAR ) as D2D1_IMAGE_BRUSH_PROPERTIES

Returns the part of an image an image brush paints with, sourceRectangle, how it extends past that part and how it is sampled.

Returns the D2D1_IMAGE_BRUSH_PROPERTIES.

Example

dim ib as D2D1_IMAGE_BRUSH_PROPERTIES = D2D1_ImageBrushProperties( D2D1_RectF( 0, 0, 32, 32 ), D2D1_EXTEND_MODE_WRAP, D2D1_EXTEND_MODE_WRAP )

Microsoft Learn: ImageBrushProperties

D2D1_ImageBrushProperties1

function D2D1_ImageBrushProperties1( byval extendModeX as D2D1_EXTEND_MODE = D2D1_EXTEND_MODE_CLAMP, byval extendModeY as D2D1_EXTEND_MODE = D2D1_EXTEND_MODE_CLAMP, byval interpolationMode as D2D1_INTERPOLATION_MODE = D2D1_INTERPOLATION_MODE_LINEAR ) as D2D1_BITMAP_BRUSH_PROPERTIES1

Despite its name, returns a D2D1_BITMAP_BRUSH_PROPERTIES1: the extend modes and interpolation of an ID2D1BitmapBrush1, which takes the Direct2D 1.1 interpolation modes. It is the counterpart of the Windows helper BitmapBrushProperties1.

Returns the D2D1_BITMAP_BRUSH_PROPERTIES1.

Example

dim bbp as D2D1_BITMAP_BRUSH_PROPERTIES1 = D2D1_ImageBrushProperties1( D2D1_EXTEND_MODE_WRAP, D2D1_EXTEND_MODE_WRAP, D2D1_INTERPOLATION_MODE_HIGH_QUALITY_CUBIC )

Microsoft Learn: BitmapBrushProperties1

D2D1_PrintControlProperties

function D2D1_PrintControlProperties( byval fontSubsetMode as D2D1_PRINT_FONT_SUBSET_MODE = D2D1_PRINT_FONT_SUBSET_MODE_DEFAULT, byval rasterDpi as FLOAT = 150.0, byval colorSpace as D2D1_COLOR_SPACE = D2D1_COLOR_SPACE_SRGB ) as D2D1_PRINT_CONTROL_PROPERTIES

Returns the settings of a print control: how fonts are subset, the resolution at which rasterised content is printed (150 DPI by default) and the colour space.

Returns the D2D1_PRINT_CONTROL_PROPERTIES.

Example

dim pc as D2D1_PRINT_CONTROL_PROPERTIES = D2D1_PrintControlProperties( , 300 )

Microsoft Learn: PrintControlProperties

D2D1_RenderingControls

function D2D1_RenderingControls( byval bufferPrecision as D2D1_BUFFER_PRECISION, byval tileSize as D2D1_SIZE_U ) as D2D1_RENDERING_CONTROLS

Returns the precision of a device context's intermediate buffers and the tile size it renders effects in.

Returns the D2D1_RENDERING_CONTROLS.

Example

dim rc as D2D1_RENDERING_CONTROLS = D2D1_RenderingControls( D2D1_BUFFER_PRECISION_8BPC_UNORM, D2D1_SizeU( 256, 256 ) )

Microsoft Learn: RenderingControls

D2D1_EffectInputDescription

function D2D1_EffectInputDescription( byval effect as ID2D1Effect ptr, byval inputIndex as UINT32, byval inputRectangle as D2D1_RECT_F ) as D2D1_EFFECT_INPUT_DESCRIPTION

Names one input of an effect and a rectangle on it, for the device context's GetEffectRequiredInputRectangles. The effect pointer is stored as given, without an extra reference.

Returns the D2D1_EFFECT_INPUT_DESCRIPTION.

Example

dim pEffect as ID2D1Effect ptr
dim eid as D2D1_EFFECT_INPUT_DESCRIPTION = D2D1_EffectInputDescription( pEffect, 0, D2D1_RectF( 0, 0, 100, 100 ) )

Microsoft Learn: EffectInputDescription

D2D1_CreationProperties

function D2D1_CreationProperties( byval threadingMode as D2D1_THREADING_MODE, byval debugLevel as D2D1_DEBUG_LEVEL, byval options as D2D1_DEVICE_CONTEXT_OPTIONS ) as D2D1_CREATION_PROPERTIES

Returns the threading mode, debug level and device-context options for D2D1CreateDevice and D2D1CreateDeviceContext. All three must be given.

Returns the D2D1_CREATION_PROPERTIES.

Example

dim cp as D2D1_CREATION_PROPERTIES = D2D1_CreationProperties( D2D1_THREADING_MODE_SINGLE_THREADED, D2D1_DEBUG_LEVEL_NONE, D2D1_DEVICE_CONTEXT_OPTIONS_NONE )

Microsoft Learn: CreationProperties

D2D1_IdentityMatrix

function D2D1_IdentityMatrix() as D2D1_MATRIX_3X2_F

Returns the 3 × 2 matrix that changes nothing: 1, 0, 0, 1, 0, 0. Set it as a render target's transform to undo an earlier SetTransform.

Returns the D2D1_MATRIX_3X2_F.

Example

dim pTarget as ID2D1RenderTarget ptr
if pTarget then pTarget->SetTransform( D2D1_IdentityMatrix() )

Microsoft Learn: IdentityMatrix

D2D1_Matrix3x2F

function D2D1_Matrix3x2F( byval m11 as FLOAT, byval m12 as FLOAT, byval m21 as FLOAT, byval m22 as FLOAT, byval m31 as FLOAT, byval m32 as FLOAT ) as D2D1_MATRIX_3X2_F

Returns a 3 × 2 matrix from its six cells, row by row. A point (x, y) becomes (x·m11 + y·m21 + m31, x·m12 + y·m22 + m32).

Returns the D2D1_MATRIX_3X2_F.

Example

dim m as D2D1_MATRIX_3X2_F = D2D1_Matrix3x2F( 1, 0, 0, -1, 0, 100 )   ' flip vertically in a 100-high area

Microsoft Learn: Matrix3x2F

D2D1_MatrixTranslation

function D2D1_MatrixTranslation overload( byref tsize as D2D1_SIZE_F ) as D2D1_MATRIX_3X2_F
function D2D1_MatrixTranslation overload( byval x as FLOAT, byval y as FLOAT ) as D2D1_MATRIX_3X2_F

Returns a transform that moves everything by x and y, given as two values or as a D2D1_SIZE_F.

Returns the D2D1_MATRIX_3X2_F: 1, 0, 0, 1, x, y.

Example

dim pTarget as ID2D1RenderTarget ptr
if pTarget then pTarget->SetTransform( D2D1_MatrixTranslation( 10, 20 ) )

Microsoft Learn: Matrix3x2F::Translation

D2D1_MatrixScale

function D2D1_MatrixScale overload( byref tsize as D2D1_SIZE_F, byval center as D2D1_POINT_2F = D2D1_Point2F() ) as D2D1_MATRIX_3X2_F
function D2D1_MatrixScale overload( byval x as FLOAT, byval y as FLOAT, byval center as D2D1_POINT_2F = D2D1_Point2F() ) as D2D1_MATRIX_3X2_F
function D2D1_MatrixScale overload( byval x as FLOAT, byval y as FLOAT, byval centerX as FLOAT, byval centerY as FLOAT ) as D2D1_MATRIX_3X2_F

Returns a transform that scales by x horizontally and y vertically (or by the two parts of tsize) about a centre point, which stays where it is. The centre defaults to the origin.

Returns the D2D1_MATRIX_3X2_F.

Example

dim m as D2D1_MATRIX_3X2_F = D2D1_MatrixScale( 2, 3, 10, 10 )   ' 2 0 0 3 -10 -20

Microsoft Learn: Matrix3x2F::Scale

D2D1_MatrixRotation

function D2D1_MatrixRotation overload( byval angle as FLOAT, byval center as D2D1_POINT_2F = D2D1_Point2F() ) as D2D1_MATRIX_3X2_F
function D2D1_MatrixRotation overload( byval angle as FLOAT, byval centerX as FLOAT = 0.0!, byval centerY as FLOAT = 0.0! ) as D2D1_MATRIX_3X2_F

Returns a transform that rotates by angle degrees, clockwise on screen, about a centre point, computed by Direct2D's D2D1MakeRotateMatrix.

Both forms default every argument after angle, so D2D1_MatrixRotation( 45 ) alone matches both and does not compile: always pass the centre, as a point or as two values.

Returns the D2D1_MATRIX_3X2_F.

Example

dim m as D2D1_MATRIX_3X2_F = D2D1_MatrixRotation( 90, 50, 50 )   ' 0 1 -1 0 100 0

Microsoft Learn: Matrix3x2F::Rotation

D2D1_MatrixSkew

function D2D1_MatrixSkew overload( byval angleX as FLOAT, byval angleY as FLOAT, byval center as D2D1_POINT_2F = D2D1_Point2F() ) as D2D1_MATRIX_3X2_F
function D2D1_MatrixSkew overload( byval angleX as FLOAT, byval angleY as FLOAT, byval centerX as FLOAT = 0.0!, byval centerY as FLOAT = 0.0! ) as D2D1_MATRIX_3X2_F

Returns a transform that slants the x axis by angleX degrees and the y axis by angleY degrees about a centre point, computed by Direct2D's D2D1MakeSkewMatrix.

As with D2D1_MatrixRotation, a call that gives only the two angles matches both forms and does not compile: pass the centre.

Returns the D2D1_MATRIX_3X2_F.

Example

dim m as D2D1_MATRIX_3X2_F = D2D1_MatrixSkew( 45, 0, D2D1_Point2F( 0, 0 ) )   ' 1 0 1 1 0 0

Microsoft Learn: Matrix3x2F::Skew

D2D1_MatrixDeterminant

function D2D1_MatrixDeterminant( byref m as D2D1_MATRIX_3X2_F ) as FLOAT

Returns m11·m22 − m12·m21: the factor by which the transform scales areas. 0 means it cannot be inverted.

Returns the determinant.

Example

dim m as D2D1_MATRIX_3X2_F = D2D1_MatrixScale( 2, 4, 0, 0 )
print D2D1_MatrixDeterminant( m )   ' 8

Microsoft Learn: Matrix3x2F::Determinant

D2D1_IsInvertibleMatrix

function D2D1_IsInvertibleMatrix( byref m as D2D1_MATRIX_3X2_F ) as boolean

Tells whether a 3 × 2 matrix can be inverted, by asking Direct2D's D2D1IsMatrixInvertible.

Returns true when it can be inverted, false when it cannot (a scale by 0, say).

Example

dim m as D2D1_MATRIX_3X2_F = D2D1_MatrixScale( 0, 1, 0, 0 )
print D2D1_IsInvertibleMatrix( m )   ' false

Microsoft Learn: Matrix3x2F::IsInvertible

D2D1_InvertMatrix

sub D2D1_InvertMatrix( byref m as D2D1_MATRIX_3X2_F )

Replaces m with its inverse, the transform that undoes it, using Direct2D's D2D1InvertMatrix. A matrix that cannot be inverted is left unchanged, and nothing reports it: check with D2D1_IsInvertibleMatrix first when it matters.

Example

dim m as D2D1_MATRIX_3X2_F = D2D1_MatrixScale( 2, 4, 0, 0 )
D2D1_InvertMatrix( m )   ' 0.5 0 0 0.25 0 0

Microsoft Learn: Matrix3x2F::Invert

D2D1_IsIdentityMatrix

function D2D1_IsIdentityMatrix( byref m as D2D1_MATRIX_3X2_F ) as long

Tells whether every cell of m is exactly that of the identity matrix. The comparison has no tolerance, so a matrix that is the identity only after rounding reports not.

Returns −1 when it is the identity, 0 when it is not (a long, not a boolean).

Example

print D2D1_IsIdentityMatrix( D2D1_IdentityMatrix() )   ' -1

Microsoft Learn: Matrix3x2F::IsIdentity

D2D1_MultiplyMatrices

function D2D1_MultiplyMatrices( byref a as D2D1_MATRIX_3X2_F, byref b as D2D1_MATRIX_3X2_F ) as D2D1_MATRIX_3X2_F

Returns a × b: the transform that applies a first and then b. The same as Operator *.

Returns the product.

Example

dim m as D2D1_MATRIX_3X2_F = D2D1_MultiplyMatrices( D2D1_MatrixScale( 2, 2, 0, 0 ), D2D1_MatrixTranslation( 10, 0 ) )
' 2 0 0 2 10 0: scale first, then move

Microsoft Learn: Matrix3x2F::SetProduct

D2D1_MatrixTransformPoint

function D2D1_MatrixTransformPoint( byref pt as D2D1_POINT_2F, byref m as D2D1_MATRIX_3X2_F ) as D2D1_POINT_2F

Returns where the transform m puts the point pt. The same as pt * m.

Returns the transformed point.

Example

dim pt as D2D1_POINT_2F = D2D1_MatrixTransformPoint( D2D1_Point2F( 1, 1 ), D2D1_MatrixTranslation( 10, 20 ) )
print pt.x; pt.y   ' 11 21

Microsoft Learn: Matrix3x2F::TransformPoint

Operator *

operator *( byref a as D2D1_MATRIX_3X2_F, byref b as D2D1_MATRIX_3X2_F ) as D2D1_MATRIX_3X2_F
operator *( byref pt as D2D1_POINT_2F, byref m as D2D1_MATRIX_3X2_F ) as D2D1_POINT_2F
operator *( byref a as D2D1_MATRIX_4X4_F, byref b as D2D1_MATRIX_4X4_F ) as D2D1_MATRIX_4X4_F

* between two 3 × 2 matrices is D2D1_MultiplyMatrices, between a point and a 3 × 2 matrix D2D1_MatrixTransformPoint, and between two 4 × 4 matrices D2D1_Matrix4x4FSetProduct. Order matters: a * b applies a first.

Returns the product.

Example

dim m as D2D1_MATRIX_3X2_F = D2D1_MatrixRotation( 30, 0, 0 ) * D2D1_MatrixTranslation( 100, 50 )
dim pt as D2D1_POINT_2F = D2D1_Point2F( 3, 4 ) * D2D1_MatrixScale( 2, 2, 0, 0 )   ' 6 8

Microsoft Learn: Matrix3x2F::operator*

D2D1_ComputeFlatteningTolerance

function D2D1_ComputeFlatteningTolerance( byref matrix as D2D1_MATRIX_3X2_F, byval dpiX as FLOAT = 96.0, byval dpiY as FLOAT = 96.0, byval maxZoomFactor as FLOAT = 1.0 ) as FLOAT

Returns the flattening tolerance to pass to calls that turn curves into line segments, such as a device context's CreateFilledGeometryRealization: the default tolerance, 0.25, divided by the largest scale the transform, the DPI and the zoom can apply. The more a geometry will be enlarged, the finer it must be flattened.

Parameter Meaning
matrix The world transform the geometry will be drawn with.
dpiX, dpiY The target's DPI.
maxZoomFactor The most the geometry will be enlarged beyond that; its sign is ignored.

Returns the tolerance: 0.25 for the identity at 96 DPI, 0.125 at 192 DPI, 0.0625 with a zoom of 4.

Example

dim tol as single = D2D1_ComputeFlatteningTolerance( D2D1_IdentityMatrix(), 192, 192 )   ' 0.125

Microsoft Learn: Direct2D helper functions, ComputeFlatteningTolerance

D2D1_Matrix4x3F

function D2D1_Matrix4x3F overload( byval m11 as FLOAT, byval m12 as FLOAT, byval m13 as FLOAT, byval m21 as FLOAT, byval m22 as FLOAT, byval m23 as FLOAT, byval m31 as FLOAT, byval m32 as FLOAT, byval m33 as FLOAT, byval m41 as FLOAT, byval m42 as FLOAT, byval m43 as FLOAT ) as D2D1_MATRIX_4X3_F
function D2D1_Matrix4x3F overload() as D2D1_MATRIX_4X3_F

Returns a 4 × 3 matrix from its twelve cells, row by row; with no arguments, ones on the diagonal (m11, m22, m33) and zeros elsewhere.

Returns the D2D1_MATRIX_4X3_F.

Example

dim m as D2D1_MATRIX_4X3_F = D2D1_Matrix4x3F()

Microsoft Learn: Matrix4x3F

D2D1_Matrix4x4F

function D2D1_Matrix4x4F overload( byval m11 as FLOAT, byval m12 as FLOAT, byval m13 as FLOAT, byval m14 as FLOAT, byval m21 as FLOAT, byval m22 as FLOAT, byval m23 as FLOAT, byval m24 as FLOAT, byval m31 as FLOAT, byval m32 as FLOAT, byval m33 as FLOAT, byval m34 as FLOAT, byval m41 as FLOAT, byval m42 as FLOAT, byval m43 as FLOAT, byval m44 as FLOAT ) as D2D1_MATRIX_4X4_F
function D2D1_Matrix4x4F overload() as D2D1_MATRIX_4X4_F

Returns a 4 × 4 matrix from its sixteen cells, row by row; with no arguments, the identity. The 4 × 4 matrices feed the 3D transform effects and use the same row-vector convention as the 3 × 2 ones: the translation is in row 4.

Returns the D2D1_MATRIX_4X4_F.

Example

dim m as D2D1_MATRIX_4X4_F = D2D1_Matrix4x4F()   ' identity

Microsoft Learn: Matrix4x4F

D2D1_Matrix4x4FTranslation

function D2D1_Matrix4x4FTranslation( byval x as FLOAT, byval y as FLOAT, byval z as FLOAT ) as D2D1_MATRIX_4X4_F

Returns a 3D translation by x, y and z: the identity with m41, m42, m43 set.

Returns the D2D1_MATRIX_4X4_F.

Example

dim m as D2D1_MATRIX_4X4_F = D2D1_Matrix4x4FTranslation( 10, 20, 30 )

Microsoft Learn: Matrix4x4F

D2D1_Matrix4x4FScale

function D2D1_Matrix4x4FScale( byval x as FLOAT, byval y as FLOAT, byval z as FLOAT ) as D2D1_MATRIX_4X4_F

Returns a 3D scale by x, y and z about the origin.

Returns the D2D1_MATRIX_4X4_F.

Example

dim m as D2D1_MATRIX_4X4_F = D2D1_Matrix4x4FScale( 2, 3, 4 )
print D2D1_Matrix4x4FDeterminant( m )   ' 24

Microsoft Learn: Matrix4x4F::Scale

D2D1_Matrix4x4FRotationX

function D2D1_Matrix4x4FRotationX( byval degreeX as FLOAT ) as D2D1_MATRIX_4X4_F

Returns a rotation of degreeX degrees about the x axis.

Returns the D2D1_MATRIX_4X4_F.

Example

dim m as D2D1_MATRIX_4X4_F = D2D1_Matrix4x4FRotationX( 30 )

Microsoft Learn: Matrix4x4F::RotationX

D2D1_Matrix4x4FRotationY

function D2D1_Matrix4x4FRotationY( byval degreeY as FLOAT ) as D2D1_MATRIX_4X4_F

Returns a rotation of degreeY degrees about the y axis.

Returns the D2D1_MATRIX_4X4_F.

Example

dim m as D2D1_MATRIX_4X4_F = D2D1_Matrix4x4FRotationY( 45 )

Microsoft Learn: Matrix4x4F::RotationY

D2D1_Matrix4x4FRotationZ

function D2D1_Matrix4x4FRotationZ( byval degreeZ as FLOAT ) as D2D1_MATRIX_4X4_F

Returns a rotation of degreeZ degrees about the z axis: in the plane of the screen, like D2D1_MatrixRotation about the origin.

Returns the D2D1_MATRIX_4X4_F.

Example

dim m as D2D1_MATRIX_4X4_F = D2D1_Matrix4x4FRotationZ( 90 )

Microsoft Learn: Matrix4x4F::RotationZ

D2D1_Matrix4x4FRotationArbitraryAxis

function D2D1_Matrix4x4FRotationArbitraryAxis( byval x as FLOAT, byval y as FLOAT, byval z as FLOAT, byval degree as FLOAT ) as D2D1_MATRIX_4X4_F

Returns a rotation of degree degrees about the axis through the origin in the direction (x, y, z). The direction need not be of unit length: it is normalised first, so it must not be (0, 0, 0).

Returns the D2D1_MATRIX_4X4_F.

Example

dim m as D2D1_MATRIX_4X4_F = D2D1_Matrix4x4FRotationArbitraryAxis( 1, 1, 0, 60 )

Microsoft Learn: Matrix4x4F::RotationArbitraryAxis

D2D1_Matrix4x4FSkewX

function D2D1_Matrix4x4FSkewX( byval degreeX as FLOAT ) as D2D1_MATRIX_4X4_F

Returns a skew that slants by degreeX degrees along x: the tangent of the angle in m21.

Returns the D2D1_MATRIX_4X4_F.

Example

dim m as D2D1_MATRIX_4X4_F = D2D1_Matrix4x4FSkewX( 45 )   ' m21 = 1

Microsoft Learn: Matrix4x4F::SkewX

D2D1_Matrix4x4FSkewY

function D2D1_Matrix4x4FSkewY( byval degreeY as FLOAT ) as D2D1_MATRIX_4X4_F

Returns a skew that slants by degreeY degrees along y: the tangent of the angle in m12.

Returns the D2D1_MATRIX_4X4_F.

Example

dim m as D2D1_MATRIX_4X4_F = D2D1_Matrix4x4FSkewY( 45 )   ' m12 = 1

Microsoft Learn: Matrix4x4F::SkewY

D2D1_Matrix4x4FPerspectiveProjection

function D2D1_Matrix4x4FPerspectiveProjection( byval depth as FLOAT ) as D2D1_MATRIX_4X4_F

Returns a perspective projection for a viewer depth units in front of the plane: the identity with −1/depth in m34. A depth of 0 or less gives the identity.

Returns the D2D1_MATRIX_4X4_F.

Example

dim m as D2D1_MATRIX_4X4_F = D2D1_Matrix4x4FRotationY( 30 ) * D2D1_Matrix4x4FPerspectiveProjection( 1000 )

Microsoft Learn: Matrix4x4F::PerspectiveProjection

D2D1_Matrix4x4FDeterminant

function D2D1_Matrix4x4FDeterminant( byref m as D2D1_MATRIX_4X4_F ) as FLOAT

Returns the determinant of a 4 × 4 matrix, expanded along the first row.

Returns the determinant: 24 for a scale by 2, 3 and 4; 1 for any rotation or translation.

Example

print D2D1_Matrix4x4FDeterminant( D2D1_Matrix4x4FScale( 2, 3, 4 ) )   ' 24

Microsoft Learn: Matrix4x4F::Determinant

D2D1_Matrix4x4FIsIdentity

function D2D1_Matrix4x4FIsIdentity( byref m as D2D1_MATRIX_4X4_F ) as boolean

Tells whether a 4 × 4 matrix is the identity, allowing each cell to be off by less than 0.00001, so a product that should cancel out, such as a rotation and its reverse, still counts.

Returns true or false.

Example

dim m as D2D1_MATRIX_4X4_F = D2D1_Matrix4x4FRotationZ( 90 ) * D2D1_Matrix4x4FRotationZ( -90 )
print D2D1_Matrix4x4FIsIdentity( m )   ' true

Microsoft Learn: Matrix4x4F::IsIdentity

D2D1_Matrix4x4FSetProduct

function D2D1_Matrix4x4FSetProduct( byref a as D2D1_MATRIX_4X4_F, byref b as D2D1_MATRIX_4X4_F ) as D2D1_MATRIX_4X4_F

Returns a × b, the transform that applies a and then b. Unlike its namesake in the Windows headers it does not change either argument. a * b does the same.

Returns the product.

Example

dim m as D2D1_MATRIX_4X4_F = D2D1_Matrix4x4FSetProduct( D2D1_Matrix4x4FScale( 2, 2, 2 ), D2D1_Matrix4x4FTranslation( 10, 0, 0 ) )

Microsoft Learn: Matrix4x4F::SetProduct

D2D1_Matrix5x4F

function D2D1_Matrix5x4F overload( byval m11 as FLOAT, byval m12 as FLOAT, byval m13 as FLOAT, byval m14 as FLOAT, byval m21 as FLOAT, byval m22 as FLOAT, byval m23 as FLOAT, byval m24 as FLOAT, byval m31 as FLOAT, byval m32 as FLOAT, byval m33 as FLOAT, byval m34 as FLOAT, byval m41 as FLOAT, byval m42 as FLOAT, byval m43 as FLOAT, byval m44 as FLOAT, byval m51 as FLOAT, byval m52 as FLOAT, byval m53 as FLOAT, byval m54 as FLOAT ) as D2D1_MATRIX_5X4_F
function D2D1_Matrix5x4F overload() as D2D1_MATRIX_5X4_F

Returns a 5 × 4 matrix, the kind the colour matrix effect takes: rows 1 to 4 weigh the red, green, blue and alpha inputs and row 5 adds an offset. With no arguments it is the identity, which leaves colours unchanged.

The twenty-value form does not store every argument where its name says: m33 and m34 end up in m31 and m32 (replacing the values given for those), m54 ends up in m53, and m33, m34 and m54 stay 0. Calling it with 1 to 20 gives row 3 = 11, 12, 0, 0 and row 5 = 17, 18, 20, 0. Start from the identity and set the cells yourself instead.

Returns the D2D1_MATRIX_5X4_F.

Example

dim cm as D2D1_MATRIX_5X4_F = D2D1_Matrix5x4F()   ' identity
cm.m11 = 0.3 : cm.m12 = 0.3 : cm.m13 = 0.3        ' red feeds all three channels

Microsoft Learn: Matrix5x4F

D2D1_GradientMeshPatch

function D2D1_GradientMeshPatch( byval point00 as D2D1_POINT_2F, byval point01 as D2D1_POINT_2F, byval point02 as D2D1_POINT_2F, byval point03 as D2D1_POINT_2F, byval point10 as D2D1_POINT_2F, byval point11 as D2D1_POINT_2F, byval point12 as D2D1_POINT_2F, byval point13 as D2D1_POINT_2F, byval point20 as D2D1_POINT_2F, byval point21 as D2D1_POINT_2F, byval point22 as D2D1_POINT_2F, byval point23 as D2D1_POINT_2F, byval point30 as D2D1_POINT_2F, byval point31 as D2D1_POINT_2F, byval point32 as D2D1_POINT_2F, byval point33 as D2D1_POINT_2F, byval color00 as D2D1_COLOR_F, byval color03 as D2D1_COLOR_F, byval color30 as D2D1_COLOR_F, byval color33 as D2D1_COLOR_F, byval topEdgeMode as D2D1_PATCH_EDGE_MODE, byval leftEdgeMode as D2D1_PATCH_EDGE_MODE, byval bottomEdgeMode as D2D1_PATCH_EDGE_MODE, byval rightEdgeMode as D2D1_PATCH_EDGE_MODE ) as D2D1_GRADIENT_MESH_PATCH

Returns one tensor patch of a gradient mesh: the 4 × 4 grid of control points pointRC (row R, column C), the colours of the four corners, and whether each edge is aliased or antialiased. An array of patches goes to a device context's CreateGradientMesh.

Returns the D2D1_GRADIENT_MESH_PATCH.

Example

dim as D2D1_COLOR_F red = D2D1_ColorF( D2D1_Red ), blue = D2D1_ColorF( D2D1_Blue )
dim e as D2D1_PATCH_EDGE_MODE = D2D1_PATCH_EDGE_MODE_ANTIALIASED
dim patch as D2D1_GRADIENT_MESH_PATCH = D2D1_GradientMeshPatch( _
    D2D1_Point2F( 0, 0 ), D2D1_Point2F( 33, 0 ), D2D1_Point2F( 66, 0 ), D2D1_Point2F( 100, 0 ), D2D1_Point2F( 0, 33 ), D2D1_Point2F( 33, 33 ), D2D1_Point2F( 66, 33 ), D2D1_Point2F( 100, 33 ), _
    D2D1_Point2F( 0, 66 ), D2D1_Point2F( 33, 66 ), D2D1_Point2F( 66, 66 ), D2D1_Point2F( 100, 66 ), D2D1_Point2F( 0, 100 ), D2D1_Point2F( 33, 100 ), D2D1_Point2F( 66, 100 ), D2D1_Point2F( 100, 100 ), _
    red, blue, blue, red, e, e, e, e )

Microsoft Learn: GradientMeshPatch

D2D1_GradientMeshPatchFromCoonsPatch

function D2D1_GradientMeshPatchFromCoonsPatch( byval point0 as D2D1_POINT_2F, byval point1 as D2D1_POINT_2F, byval point2 as D2D1_POINT_2F, byval point3 as D2D1_POINT_2F, byval point4 as D2D1_POINT_2F, byval point5 as D2D1_POINT_2F, byval point6 as D2D1_POINT_2F, byval point7 as D2D1_POINT_2F, byval point8 as D2D1_POINT_2F, byval point9 as D2D1_POINT_2F, byval point10 as D2D1_POINT_2F, byval point11 as D2D1_POINT_2F, byval color0 as D2D1_COLOR_F, byval color1 as D2D1_COLOR_F, byval color2 as D2D1_COLOR_F, byval color3 as D2D1_COLOR_F, byval topEdgeMode as D2D1_PATCH_EDGE_MODE, byval leftEdgeMode as D2D1_PATCH_EDGE_MODE, byval bottomEdgeMode as D2D1_PATCH_EDGE_MODE, byval rightEdgeMode as D2D1_PATCH_EDGE_MODE ) as D2D1_GRADIENT_MESH_PATCH

Returns a gradient mesh patch from a Coons patch: the twelve points around its border, clockwise from the top-left corner (point0, point3, point6 and point9 are the corners), and the colours of the corners in the same clockwise order. Direct2D's D2D1GetGradientMeshInteriorPointsFromCoonsPatch works out the four interior points.

Returns the D2D1_GRADIENT_MESH_PATCH.

Example

dim as D2D1_COLOR_F red = D2D1_ColorF( D2D1_Red ), blue = D2D1_ColorF( D2D1_Blue )
dim e as D2D1_PATCH_EDGE_MODE = D2D1_PATCH_EDGE_MODE_ANTIALIASED
dim patch as D2D1_GRADIENT_MESH_PATCH = D2D1_GradientMeshPatchFromCoonsPatch( _
    D2D1_Point2F( 0, 0 ), D2D1_Point2F( 33, 0 ), D2D1_Point2F( 66, 0 ), D2D1_Point2F( 100, 0 ), D2D1_Point2F( 100, 33 ), D2D1_Point2F( 100, 66 ), _
    D2D1_Point2F( 100, 100 ), D2D1_Point2F( 66, 100 ), D2D1_Point2F( 33, 100 ), D2D1_Point2F( 0, 100 ), D2D1_Point2F( 0, 66 ), D2D1_Point2F( 0, 33 ), _
    red, blue, red, blue, e, e, e, e )

Microsoft Learn: GradientMeshPatchFromCoonsPatch

D2D1_InkPoint

function D2D1_InkPoint( byref pt as const D2D1_POINT_2F, byval radius as FLOAT ) as D2D1_INK_POINT

Returns a point of an ink stroke and the stroke's radius there; the radius may change from point to point.

Returns the D2D1_INK_POINT.

Example

dim ip as D2D1_INK_POINT = D2D1_InkPoint( D2D1_Point2F( 5, 6 ), 2 )

Microsoft Learn: InkPoint

D2D1_InkBezierSegment

function D2D1_InkBezierSegment( byref point1 as const D2D1_INK_POINT, byref point2 as const D2D1_INK_POINT, byref point3 as const D2D1_INK_POINT ) as D2D1_INK_BEZIER_SEGMENT

Returns a cubic Bézier segment of an ink stroke: two control points and an end point, each with a radius.

Returns the D2D1_INK_BEZIER_SEGMENT.

Example

dim seg as D2D1_INK_BEZIER_SEGMENT = D2D1_InkBezierSegment( D2D1_InkPoint( D2D1_Point2F( 10, 0 ), 1 ), D2D1_InkPoint( D2D1_Point2F( 20, 10 ), 2 ), D2D1_InkPoint( D2D1_Point2F( 30, 0 ), 1 ) )

Microsoft Learn: InkBezierSegment

D2D1_InkStyleProperties

function D2D1_InkStyleProperties( byval nibShape as D2D1_INK_NIB_SHAPE, byref nibTransform as const D2D1_MATRIX_3X2_F ) as D2D1_INK_STYLE_PROPERTIES

Returns the nib an ink style draws with: round or square, and a transform that stretches or turns it, for a calligraphic pen say.

Returns the D2D1_INK_STYLE_PROPERTIES.

Example

dim isp as D2D1_INK_STYLE_PROPERTIES = D2D1_InkStyleProperties( D2D1_INK_NIB_SHAPE_SQUARE, D2D1_MatrixRotation( 45, 0, 0 ) )

Microsoft Learn: InkStyleProperties

D2D1_SimpleColorProfile

function D2D1_SimpleColorProfile( byref redPrimary as const D2D1_POINT_2F, byref greenPrimary as const D2D1_POINT_2F, byref bluePrimary as const D2D1_POINT_2F, byref gamma as const D2D1_GAMMA1, byref whitePointXZ as const D2D1_POINT_2F ) as D2D1_SIMPLE_COLOR_PROFILE

Returns a colour profile described by the chromaticities of its red, green and blue primaries, its gamma (D2D1_GAMMA1_G22, _G10 or _G2084) and its white point, for CreateColorContextFromSimpleColorProfile.

Returns the D2D1_SIMPLE_COLOR_PROFILE.

Example

dim scp as D2D1_SIMPLE_COLOR_PROFILE = D2D1_SimpleColorProfile( D2D1_Point2F( 0.64, 0.33 ), D2D1_Point2F( 0.3, 0.6 ), D2D1_Point2F( 0.15, 0.06 ), D2D1_GAMMA1_G22, D2D1_Point2F( 0.3127, 0.329 ) )

Microsoft Learn: D2D1_SIMPLE_COLOR_PROFILE

See also

Clone this wiki locally