@bun-win32/d2d1 1.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/AI.md ADDED
@@ -0,0 +1,71 @@
1
+ # AI Guide for @bun-win32/d2d1
2
+
3
+ How to use this package, not what the Win32 API does.
4
+
5
+ ## Usage
6
+
7
+ ```ts
8
+ import D2D1, { SomeFlag } from '@bun-win32/d2d1';
9
+
10
+ // Methods bind lazily on first call
11
+ const result = D2D1.SomeFunctionW(arg1, arg2);
12
+
13
+ // Preload: array, single string, or no args (all symbols)
14
+ D2D1.Preload(['SomeFunctionW', 'AnotherFunction']);
15
+ D2D1.Preload('SomeFunctionW');
16
+ D2D1.Preload();
17
+ ```
18
+
19
+ ## Where To Look
20
+
21
+ | Need | Read |
22
+ | --------------------------------- | -------------------- |
23
+ | Find a method or its MS Docs link | `structs/D2D1.ts` |
24
+ | Find types, enums, constants | `types/D2D1.ts` |
25
+ | Quick examples | `README.md` |
26
+
27
+ `index.ts` re-exports the class and all types — import from `@bun-win32/d2d1` directly.
28
+
29
+ ## Calling Convention
30
+
31
+ All documented `d2d1.dll` exports are bound. Each method maps 1:1 to its DLL export. Names, parameter names, and order match Microsoft Docs.
32
+
33
+ ### Strings
34
+
35
+ `W` methods take UTF-16LE NUL-terminated buffers. `A` methods take ANSI strings.
36
+
37
+ ```ts
38
+ const wide = Buffer.from('Hello\0', 'utf16le'); // LPCWSTR
39
+ D2D1.SomeFunctionW(wide.ptr);
40
+
41
+ // Reading a wide string back from a buffer:
42
+ const text = new TextDecoder('utf-16').decode(buf).replace(/\0.*$/, '');
43
+ ```
44
+
45
+ ### Return types
46
+
47
+ - `HANDLE`, `HWND`, etc. → `bigint`
48
+ - `DWORD`, `UINT`, `BOOL`, `INT`, `LONG` → `number`
49
+ - `LPVOID`, `LPWSTR`, etc. → `Pointer`
50
+ - Win32 `BOOL` is `number` (0 or non-zero), **not** JS `boolean`. Do not compare with `=== true`.
51
+
52
+ ### Pointers, handles, out-parameters
53
+
54
+ - **Pointer** params (`LP*`, `P*`, `Pointer`): pass `buffer.ptr` from a caller-allocated `Buffer`.
55
+ - **Handle** params (`HANDLE`, `HWND`, etc.): pass a `bigint` value.
56
+ - **Out-parameters**: allocate a `Buffer`, pass `.ptr`, read the result after the call.
57
+
58
+ ```ts
59
+ const out = Buffer.alloc(4);
60
+ D2D1.SomeFunction(out.ptr);
61
+ const value = out.readUInt32LE(0);
62
+ ```
63
+
64
+ ### Nullability
65
+
66
+ - `| NULL` in a signature → pass `null` (optional pointer).
67
+ - `| 0n` in a signature → pass `0n` (optional handle).
68
+
69
+ ## Errors and Cleanup
70
+
71
+ Return values are raw. If the Win32 function uses last-error semantics, read via `GetLastError()`. Resource cleanup is your responsibility — same as raw Win32.
package/README.md ADDED
@@ -0,0 +1,75 @@
1
+ # @bun-win32/d2d1
2
+
3
+ Zero-dependency, zero-overhead Win32 D2D1 bindings for [Bun](https://bun.sh) on Windows.
4
+
5
+ ## Overview
6
+
7
+ `@bun-win32/d2d1` exposes the `d2d1.dll` exports using [Bun](https://bun.sh)'s FFI. It provides a single class, `D2D1`, which lazily binds native symbols on first use. You can optionally preload a subset or all symbols up-front via `Preload()`.
8
+
9
+ `d2d1.dll` exports only thirteen flat C functions: the factory/device entry points (`D2D1CreateFactory`, `D2D1CreateDevice`, `D2D1CreateDeviceContext`) and Direct2D's native transform/color math (`D2D1MakeRotateMatrix`, `D2D1MakeSkewMatrix`, `D2D1InvertMatrix`, `D2D1IsMatrixInvertible`, `D2D1ComputeMaximumScaleFactor`, `D2D1ConvertColorSpace`, `D2D1SinCos`, `D2D1Tan`, `D2D1Vec3Length`, `D2D1GetGradientMeshInteriorPointsFromCoonsPatch`). The rest of Direct2D — render targets, brushes, geometry, drawing — is reached through the COM vtable of the `ID2D1Factory` returned by `D2D1CreateFactory`.
10
+
11
+ The bindings are strongly typed for a smooth DX in TypeScript.
12
+
13
+ ## Features
14
+
15
+ - [Bun](https://bun.sh)-first ergonomics on Windows 10/11.
16
+ - Direct FFI to `d2d1.dll` (Direct2D — GPU-accelerated 2D: factory/device creation plus the native matrix, color-space, and gradient-mesh math).
17
+ - In-source docs in `structs/D2D1.ts` with links to Microsoft Docs.
18
+ - Lazy binding on first call; optional eager preload (`D2D1.Preload()`).
19
+ - No wrapper overhead; calls map 1:1 to native APIs.
20
+ - Strongly-typed Win32 aliases (see `types/D2D1.ts`).
21
+
22
+ ## Requirements
23
+
24
+ - [Bun](https://bun.sh) runtime
25
+ - Windows 10 or later
26
+
27
+ ## Installation
28
+
29
+ ```sh
30
+ bun add @bun-win32/d2d1
31
+ ```
32
+
33
+ ## Quick Start
34
+
35
+ ```ts
36
+ import D2D1, { D2D1_FACTORY_TYPE } from '@bun-win32/d2d1';
37
+
38
+ // IID_ID2D1Factory = 06152247-6f50-465a-9245-118bfd3b6007
39
+ const iid = Buffer.from([
40
+ 0x47, 0x22, 0x15, 0x06, 0x50, 0x6f, 0x5a, 0x46,
41
+ 0x92, 0x45, 0x11, 0x8b, 0xfd, 0x3b, 0x60, 0x07,
42
+ ]);
43
+ const ppFactory = Buffer.alloc(8);
44
+
45
+ const hr = D2D1.D2D1CreateFactory(D2D1_FACTORY_TYPE.D2D1_FACTORY_TYPE_SINGLE_THREADED, iid.ptr, null, ppFactory.ptr);
46
+ if (hr !== 0) throw new Error(`D2D1CreateFactory failed: 0x${(hr >>> 0).toString(16)}`);
47
+
48
+ const factory = ppFactory.readBigUInt64LE(0);
49
+ console.log(`ID2D1Factory @ 0x${factory.toString(16)}`);
50
+ // ... walk ID2D1Factory::CreateWicBitmapRenderTarget / GetDesktopDpi / Release via the COM vtable.
51
+
52
+ // Direct2D's native transform engine — no COM required:
53
+ const matrix = Buffer.alloc(24); // D2D1_MATRIX_3X2_F = 6 floats
54
+ D2D1.D2D1MakeRotateMatrix(45, 0n, matrix.ptr); // rotate 45° about the origin
55
+ ```
56
+
57
+ > [!NOTE]
58
+ > AI agents: see `AI.md` for the package binding contract and source-navigation guidance. It explains how to use the package without scanning the entire implementation.
59
+
60
+ ## Examples
61
+
62
+ Run the included examples:
63
+
64
+ ```sh
65
+ # Real-time animated 3D wireframe driven entirely by Direct2D's native matrix/color math
66
+ bun run example:d2d1-matrix-engine
67
+
68
+ # Factory creation + DPI probe + exhaustive transform / color-space / Coons-patch report
69
+ bun run example:d2d1-factory-probe
70
+ ```
71
+
72
+ ## Notes
73
+
74
+ - Either rely on lazy binding or call `D2D1.Preload()`.
75
+ - Windows only. Bun runtime required.
package/index.ts ADDED
@@ -0,0 +1,4 @@
1
+ import D2D1 from './structs/D2D1';
2
+
3
+ export * from './types/D2D1';
4
+ export default D2D1;
package/package.json ADDED
@@ -0,0 +1,58 @@
1
+ {
2
+ "author": "Stev Peifer <stev@bell.net>",
3
+ "bugs": {
4
+ "url": "https://github.com/ObscuritySRL/bun-win32/issues"
5
+ },
6
+ "dependencies": {
7
+ "@bun-win32/core": "1.1.2"
8
+ },
9
+ "description": "Zero-dependency, zero-overhead Win32 D2D1 bindings for Bun (FFI) on Windows.",
10
+ "devDependencies": {
11
+ "@types/bun": "latest"
12
+ },
13
+ "exports": {
14
+ ".": "./index.ts"
15
+ },
16
+ "license": "MIT",
17
+ "module": "index.ts",
18
+ "name": "@bun-win32/d2d1",
19
+ "peerDependencies": {
20
+ "typescript": "^5"
21
+ },
22
+ "private": false,
23
+ "homepage": "https://github.com/ObscuritySRL/bun-win32#readme",
24
+ "repository": {
25
+ "type": "git",
26
+ "url": "git://github.com/ObscuritySRL/bun-win32.git",
27
+ "directory": "packages/d2d1"
28
+ },
29
+ "type": "module",
30
+ "version": "1.0.0",
31
+ "main": "./index.ts",
32
+ "keywords": [
33
+ "bun",
34
+ "ffi",
35
+ "win32",
36
+ "windows",
37
+ "d2d1",
38
+ "direct2d",
39
+ "bindings",
40
+ "typescript",
41
+ "dll"
42
+ ],
43
+ "files": [
44
+ "AI.md",
45
+ "README.md",
46
+ "index.ts",
47
+ "structs/*.ts",
48
+ "types/*.ts"
49
+ ],
50
+ "sideEffects": false,
51
+ "engines": {
52
+ "bun": ">=1.1.0"
53
+ },
54
+ "scripts": {
55
+ "example:d2d1-matrix-engine": "bun ./example/d2d1-matrix-engine.ts",
56
+ "example:d2d1-factory-probe": "bun ./example/d2d1-factory-probe.ts"
57
+ }
58
+ }
@@ -0,0 +1,178 @@
1
+ import { type FFIFunction, FFIType } from 'bun:ffi';
2
+
3
+ import { Win32 } from '@bun-win32/core';
4
+
5
+ import type {
6
+ BOOL,
7
+ FLOAT,
8
+ HRESULT,
9
+ IDXGIDevice,
10
+ IDXGISurface,
11
+ LPLPVOID,
12
+ NULL,
13
+ PACKED_D2D1_POINT_2F,
14
+ PD2D1_COLOR_F,
15
+ PD2D1_CREATION_PROPERTIES,
16
+ PD2D1_FACTORY_OPTIONS,
17
+ PD2D1_MATRIX_3X2_F,
18
+ PD2D1_POINT_2F,
19
+ PFLOAT,
20
+ PID2D1Device,
21
+ PID2D1DeviceContext,
22
+ REFIID,
23
+ } from '../types/D2D1';
24
+ import type { D2D1_COLOR_SPACE, D2D1_FACTORY_TYPE } from '../types/D2D1';
25
+
26
+ /**
27
+ * Thin, lazy-loaded FFI bindings for `d2d1.dll`.
28
+ *
29
+ * Each static method corresponds one-to-one with a Win32 export declared in `Symbols`.
30
+ * The first call to a method binds the underlying native symbol via `bun:ffi` and
31
+ * memoizes it on the class for subsequent calls. For bulk, up-front binding, use `Preload`.
32
+ *
33
+ * Symbols are defined with explicit `FFIType` signatures and kept alphabetized.
34
+ * You normally do not access `Symbols` directly; call the static methods or preload
35
+ * a subset for hot paths.
36
+ *
37
+ * `d2d1.dll` exposes only thirteen flat C exports; the rest of Direct2D is reached
38
+ * through the COM vtable of the `ID2D1Factory` obtained from `D2D1CreateFactory`.
39
+ *
40
+ * @example
41
+ * ```ts
42
+ * import D2D1, { D2D1_FACTORY_TYPE } from './structs/D2D1';
43
+ *
44
+ * // Lazy: bind on first call
45
+ * const iid = Buffer.alloc(16);
46
+ * const ppFactory = Buffer.alloc(8);
47
+ * const hr = D2D1.D2D1CreateFactory(D2D1_FACTORY_TYPE.D2D1_FACTORY_TYPE_SINGLE_THREADED, iid.ptr, null, ppFactory.ptr);
48
+ *
49
+ * // Or preload a subset to avoid per-symbol lazy binding cost
50
+ * D2D1.Preload(['D2D1CreateFactory', 'D2D1MakeRotateMatrix']);
51
+ * ```
52
+ */
53
+ class D2D1 extends Win32 {
54
+ protected static override name = 'd2d1.dll';
55
+
56
+ /** @inheritdoc */
57
+ protected static override readonly Symbols = {
58
+ D2D1ComputeMaximumScaleFactor: { args: [FFIType.ptr], returns: FFIType.f32 },
59
+ D2D1ConvertColorSpace: { args: [FFIType.ptr, FFIType.u32, FFIType.u32, FFIType.ptr], returns: FFIType.ptr },
60
+ D2D1CreateDevice: { args: [FFIType.ptr, FFIType.ptr, FFIType.ptr], returns: FFIType.i32 },
61
+ D2D1CreateDeviceContext: { args: [FFIType.ptr, FFIType.ptr, FFIType.ptr], returns: FFIType.i32 },
62
+ D2D1CreateFactory: { args: [FFIType.u32, FFIType.ptr, FFIType.ptr, FFIType.ptr], returns: FFIType.i32 },
63
+ D2D1GetGradientMeshInteriorPointsFromCoonsPatch: {
64
+ args: [FFIType.ptr, FFIType.ptr, FFIType.ptr, FFIType.ptr, FFIType.ptr, FFIType.ptr, FFIType.ptr, FFIType.ptr, FFIType.ptr, FFIType.ptr, FFIType.ptr, FFIType.ptr, FFIType.ptr, FFIType.ptr, FFIType.ptr, FFIType.ptr],
65
+ returns: FFIType.void,
66
+ },
67
+ D2D1InvertMatrix: { args: [FFIType.ptr], returns: FFIType.i32 },
68
+ D2D1IsMatrixInvertible: { args: [FFIType.ptr], returns: FFIType.i32 },
69
+ D2D1MakeRotateMatrix: { args: [FFIType.f32, FFIType.u64, FFIType.ptr], returns: FFIType.void },
70
+ D2D1MakeSkewMatrix: { args: [FFIType.f32, FFIType.f32, FFIType.u64, FFIType.ptr], returns: FFIType.void },
71
+ D2D1SinCos: { args: [FFIType.f32, FFIType.ptr, FFIType.ptr], returns: FFIType.void },
72
+ D2D1Tan: { args: [FFIType.f32], returns: FFIType.f32 },
73
+ D2D1Vec3Length: { args: [FFIType.f32, FFIType.f32, FFIType.f32], returns: FFIType.f32 },
74
+ } as const satisfies Record<string, FFIFunction>;
75
+
76
+ // https://learn.microsoft.com/en-us/windows/win32/api/d2d1_2/nf-d2d1_2-d2d1computemaximumscalefactor
77
+ public static D2D1ComputeMaximumScaleFactor(matrix: PD2D1_MATRIX_3X2_F): FLOAT {
78
+ return D2D1.Load('D2D1ComputeMaximumScaleFactor')(matrix);
79
+ }
80
+
81
+ // The x64 ABI returns the 16-byte D2D1_COLOR_F by hidden pointer: the caller allocates the
82
+ // result buffer and passes it as an implicit leading argument; the same pointer is returned.
83
+ // https://learn.microsoft.com/en-us/windows/win32/api/d2d1_1/nf-d2d1_1-d2d1convertcolorspace
84
+ public static D2D1ConvertColorSpace(convertedColor: PD2D1_COLOR_F, sourceColorSpace: D2D1_COLOR_SPACE, destinationColorSpace: D2D1_COLOR_SPACE, color: PD2D1_COLOR_F): PD2D1_COLOR_F {
85
+ return D2D1.Load('D2D1ConvertColorSpace')(convertedColor, sourceColorSpace, destinationColorSpace, color);
86
+ }
87
+
88
+ // https://learn.microsoft.com/en-us/windows/win32/api/d2d1_1/nf-d2d1_1-d2d1createdevice
89
+ public static D2D1CreateDevice(dxgiDevice: IDXGIDevice, creationProperties: PD2D1_CREATION_PROPERTIES | NULL, d2dDevice: PID2D1Device): HRESULT {
90
+ return D2D1.Load('D2D1CreateDevice')(dxgiDevice, creationProperties, d2dDevice);
91
+ }
92
+
93
+ // https://learn.microsoft.com/en-us/windows/win32/api/d2d1_1/nf-d2d1_1-d2d1createdevicecontext
94
+ public static D2D1CreateDeviceContext(dxgiSurface: IDXGISurface, creationProperties: PD2D1_CREATION_PROPERTIES | NULL, d2dDeviceContext: PID2D1DeviceContext): HRESULT {
95
+ return D2D1.Load('D2D1CreateDeviceContext')(dxgiSurface, creationProperties, d2dDeviceContext);
96
+ }
97
+
98
+ // https://learn.microsoft.com/en-us/windows/win32/api/d2d1/nf-d2d1-d2d1createfactory
99
+ public static D2D1CreateFactory(factoryType: D2D1_FACTORY_TYPE, riid: REFIID, pFactoryOptions: PD2D1_FACTORY_OPTIONS | NULL, ppIFactory: LPLPVOID): HRESULT {
100
+ return D2D1.Load('D2D1CreateFactory')(factoryType, riid, pFactoryOptions, ppIFactory);
101
+ }
102
+
103
+ // https://learn.microsoft.com/en-us/windows/win32/api/d2d1_3/nf-d2d1_3-d2d1getgradientmeshinteriorpointsfromcoonspatch
104
+ public static D2D1GetGradientMeshInteriorPointsFromCoonsPatch(
105
+ pPoint0: PD2D1_POINT_2F,
106
+ pPoint1: PD2D1_POINT_2F,
107
+ pPoint2: PD2D1_POINT_2F,
108
+ pPoint3: PD2D1_POINT_2F,
109
+ pPoint4: PD2D1_POINT_2F,
110
+ pPoint5: PD2D1_POINT_2F,
111
+ pPoint6: PD2D1_POINT_2F,
112
+ pPoint7: PD2D1_POINT_2F,
113
+ pPoint8: PD2D1_POINT_2F,
114
+ pPoint9: PD2D1_POINT_2F,
115
+ pPoint10: PD2D1_POINT_2F,
116
+ pPoint11: PD2D1_POINT_2F,
117
+ pTensorPoint11: PD2D1_POINT_2F,
118
+ pTensorPoint12: PD2D1_POINT_2F,
119
+ pTensorPoint21: PD2D1_POINT_2F,
120
+ pTensorPoint22: PD2D1_POINT_2F,
121
+ ): void {
122
+ return D2D1.Load('D2D1GetGradientMeshInteriorPointsFromCoonsPatch')(
123
+ pPoint0,
124
+ pPoint1,
125
+ pPoint2,
126
+ pPoint3,
127
+ pPoint4,
128
+ pPoint5,
129
+ pPoint6,
130
+ pPoint7,
131
+ pPoint8,
132
+ pPoint9,
133
+ pPoint10,
134
+ pPoint11,
135
+ pTensorPoint11,
136
+ pTensorPoint12,
137
+ pTensorPoint21,
138
+ pTensorPoint22,
139
+ );
140
+ }
141
+
142
+ // https://learn.microsoft.com/en-us/windows/win32/api/d2d1/nf-d2d1-d2d1invertmatrix
143
+ public static D2D1InvertMatrix(matrix: PD2D1_MATRIX_3X2_F): BOOL {
144
+ return D2D1.Load('D2D1InvertMatrix')(matrix);
145
+ }
146
+
147
+ // https://learn.microsoft.com/en-us/windows/win32/api/d2d1/nf-d2d1-d2d1ismatrixinvertible
148
+ public static D2D1IsMatrixInvertible(matrix: PD2D1_MATRIX_3X2_F): BOOL {
149
+ return D2D1.Load('D2D1IsMatrixInvertible')(matrix);
150
+ }
151
+
152
+ // https://learn.microsoft.com/en-us/windows/win32/api/d2d1/nf-d2d1-d2d1makerotatematrix
153
+ public static D2D1MakeRotateMatrix(angle: FLOAT, center: PACKED_D2D1_POINT_2F, matrix: PD2D1_MATRIX_3X2_F): void {
154
+ return D2D1.Load('D2D1MakeRotateMatrix')(angle, center, matrix);
155
+ }
156
+
157
+ // https://learn.microsoft.com/en-us/windows/win32/api/d2d1/nf-d2d1-d2d1makeskewmatrix
158
+ public static D2D1MakeSkewMatrix(angleX: FLOAT, angleY: FLOAT, center: PACKED_D2D1_POINT_2F, matrix: PD2D1_MATRIX_3X2_F): void {
159
+ return D2D1.Load('D2D1MakeSkewMatrix')(angleX, angleY, center, matrix);
160
+ }
161
+
162
+ // https://learn.microsoft.com/en-us/windows/win32/api/d2d1_1/nf-d2d1_1-d2d1sincos
163
+ public static D2D1SinCos(angle: FLOAT, s: PFLOAT, c: PFLOAT): void {
164
+ return D2D1.Load('D2D1SinCos')(angle, s, c);
165
+ }
166
+
167
+ // https://learn.microsoft.com/en-us/windows/win32/api/d2d1_1/nf-d2d1_1-d2d1tan
168
+ public static D2D1Tan(angle: FLOAT): FLOAT {
169
+ return D2D1.Load('D2D1Tan')(angle);
170
+ }
171
+
172
+ // https://learn.microsoft.com/en-us/windows/win32/api/d2d1_1/nf-d2d1_1-d2d1vec3length
173
+ public static D2D1Vec3Length(x: FLOAT, y: FLOAT, z: FLOAT): FLOAT {
174
+ return D2D1.Load('D2D1Vec3Length')(x, y, z);
175
+ }
176
+ }
177
+
178
+ export default D2D1;
package/types/D2D1.ts ADDED
@@ -0,0 +1,59 @@
1
+ import type { Pointer } from 'bun:ffi';
2
+
3
+ export type { BOOL, HRESULT, NULL } from '@bun-win32/core';
4
+
5
+ export enum D2D1_COLOR_SPACE {
6
+ D2D1_COLOR_SPACE_CUSTOM = 0,
7
+ D2D1_COLOR_SPACE_FORCE_DWORD = 0xffff_ffff,
8
+ D2D1_COLOR_SPACE_SCRGB = 2,
9
+ D2D1_COLOR_SPACE_SRGB = 1,
10
+ }
11
+
12
+ export enum D2D1_DEBUG_LEVEL {
13
+ D2D1_DEBUG_LEVEL_ERROR = 1,
14
+ D2D1_DEBUG_LEVEL_FORCE_DWORD = 0xffff_ffff,
15
+ D2D1_DEBUG_LEVEL_INFORMATION = 3,
16
+ D2D1_DEBUG_LEVEL_NONE = 0,
17
+ D2D1_DEBUG_LEVEL_WARNING = 2,
18
+ }
19
+
20
+ export enum D2D1_DEVICE_CONTEXT_OPTIONS {
21
+ D2D1_DEVICE_CONTEXT_OPTIONS_ENABLE_MULTITHREADED_OPTIMIZATIONS = 1,
22
+ D2D1_DEVICE_CONTEXT_OPTIONS_FORCE_DWORD = 0xffff_ffff,
23
+ D2D1_DEVICE_CONTEXT_OPTIONS_NONE = 0,
24
+ }
25
+
26
+ export enum D2D1_FACTORY_TYPE {
27
+ D2D1_FACTORY_TYPE_FORCE_DWORD = 0xffff_ffff,
28
+ D2D1_FACTORY_TYPE_MULTI_THREADED = 1,
29
+ D2D1_FACTORY_TYPE_SINGLE_THREADED = 0,
30
+ }
31
+
32
+ export enum D2D1_THREADING_MODE {
33
+ D2D1_THREADING_MODE_MULTI_THREADED = 1,
34
+ D2D1_THREADING_MODE_SINGLE_THREADED = 0,
35
+ }
36
+
37
+ export type FLOAT = number;
38
+ export type IDXGIDevice = Pointer;
39
+ export type IDXGISurface = Pointer;
40
+ export type LPLPVOID = Pointer;
41
+ export type PACKED_D2D1_POINT_2F = bigint;
42
+ export type PD2D1_COLOR_F = Pointer;
43
+ export type PD2D1_CREATION_PROPERTIES = Pointer;
44
+ export type PD2D1_FACTORY_OPTIONS = Pointer;
45
+ export type PD2D1_MATRIX_3X2_F = Pointer;
46
+ export type PD2D1_POINT_2F = Pointer;
47
+ export type PFLOAT = Pointer;
48
+ export type PID2D1Device = Pointer;
49
+ export type PID2D1DeviceContext = Pointer;
50
+ export type REFIID = Pointer;
51
+
52
+ const _packPointBuffer = Buffer.alloc(8);
53
+
54
+ /** Pack two `FLOAT` values into a `PACKED_D2D1_POINT_2F` for Win32 functions that take `D2D1_POINT_2F` by value (8 bytes, passed in a single x64 register). */
55
+ export function packD2D1_POINT_2F(x: number, y: number): PACKED_D2D1_POINT_2F {
56
+ _packPointBuffer.writeFloatLE(x, 0);
57
+ _packPointBuffer.writeFloatLE(y, 4);
58
+ return _packPointBuffer.readBigUInt64LE(0);
59
+ }