@gjsify/node-gi 0.26.1 → 0.27.1
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/README.md +96 -12
- package/cairo.d.ts +121 -121
- package/cairo.js +425 -426
- package/gettext.d.ts +24 -24
- package/gettext.js +42 -42
- package/gi.d.ts +170 -122
- package/gi.js +1514 -1464
- package/globals.d.ts +28 -28
- package/globals.js +103 -97
- package/gtk-runtime.js +64 -20
- package/index.d.ts +133 -152
- package/index.js +82 -100
- package/native-paths.js +104 -0
- package/overrides/_signals.js +108 -111
- package/overrides/byte-array.js +135 -135
- package/overrides/gio-dbus.js +681 -658
- package/overrides/mainloop.js +27 -27
- package/overrides/package.js +128 -128
- package/package.json +7 -2
- package/prebuilds/darwin-arm64/node_gi.node +0 -0
- package/prebuilds/darwin-x64/node_gi.node +0 -0
- package/prebuilds/linux-arm64/node_gi.node +0 -0
- package/prebuilds/linux-x64/node_gi.node +0 -0
- package/prebuilds/win32-x64/node_gi.node +0 -0
- package/scripts/install.mjs +238 -0
- package/scripts/win-gi-gyp-flags.mjs +2 -11
- package/src/template.cc +24 -6
- package/system-gi.d.ts +20 -0
- package/system-gi.js +209 -0
- package/system.d.ts +13 -13
- package/system.js +35 -35
package/cairo.js
CHANGED
|
@@ -27,10 +27,10 @@ import native from './index.js';
|
|
|
27
27
|
|
|
28
28
|
const c = native.__cairo;
|
|
29
29
|
if (c === undefined) {
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
30
|
+
throw new Error(
|
|
31
|
+
'@gjsify/node-gi/cairo: the native cairo binding is missing from the addon. ' +
|
|
32
|
+
'Rebuild @gjsify/node-gi (node-gyp rebuild) — the addon must link libcairo.',
|
|
33
|
+
);
|
|
34
34
|
}
|
|
35
35
|
|
|
36
36
|
// ---- enums (ported verbatim from refs/gjs/modules/core/_cairo.js) -----------
|
|
@@ -52,64 +52,64 @@ export const FontWeight = { NORMAL: 0, BOLD: 1 };
|
|
|
52
52
|
export const Format = { ARGB32: 0, RGB24: 1, A8: 2, A1: 3, RGB16_565: 4 };
|
|
53
53
|
|
|
54
54
|
export const LineCap = {
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
55
|
+
BUTT: 0,
|
|
56
|
+
ROUND: 1,
|
|
57
|
+
SQUARE: 2,
|
|
58
|
+
/** @deprecated Historical typo of {@link LineCap.SQUARE}, kept for compatibility. */
|
|
59
|
+
SQUASH: 2,
|
|
60
60
|
};
|
|
61
61
|
|
|
62
62
|
export const LineJoin = { MITER: 0, ROUND: 1, BEVEL: 2 };
|
|
63
63
|
|
|
64
64
|
export const Operator = {
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
65
|
+
CLEAR: 0,
|
|
66
|
+
SOURCE: 1,
|
|
67
|
+
OVER: 2,
|
|
68
|
+
IN: 3,
|
|
69
|
+
OUT: 4,
|
|
70
|
+
ATOP: 5,
|
|
71
|
+
DEST: 6,
|
|
72
|
+
DEST_OVER: 7,
|
|
73
|
+
DEST_IN: 8,
|
|
74
|
+
DEST_OUT: 9,
|
|
75
|
+
DEST_ATOP: 10,
|
|
76
|
+
XOR: 11,
|
|
77
|
+
ADD: 12,
|
|
78
|
+
SATURATE: 13,
|
|
79
|
+
MULTIPLY: 14,
|
|
80
|
+
SCREEN: 15,
|
|
81
|
+
OVERLAY: 16,
|
|
82
|
+
DARKEN: 17,
|
|
83
|
+
LIGHTEN: 18,
|
|
84
|
+
COLOR_DODGE: 19,
|
|
85
|
+
COLOR_BURN: 20,
|
|
86
|
+
HARD_LIGHT: 21,
|
|
87
|
+
SOFT_LIGHT: 22,
|
|
88
|
+
DIFFERENCE: 23,
|
|
89
|
+
EXCLUSION: 24,
|
|
90
|
+
HSL_HUE: 25,
|
|
91
|
+
HSL_SATURATION: 26,
|
|
92
|
+
HSL_COLOR: 27,
|
|
93
|
+
HSL_LUMINOSITY: 28,
|
|
94
94
|
};
|
|
95
95
|
|
|
96
96
|
export const PatternType = { SOLID: 0, SURFACE: 1, LINEAR: 2, RADIAL: 3 };
|
|
97
97
|
|
|
98
98
|
export const SurfaceType = {
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
99
|
+
IMAGE: 0,
|
|
100
|
+
PDF: 1,
|
|
101
|
+
PS: 2,
|
|
102
|
+
XLIB: 3,
|
|
103
|
+
XCB: 4,
|
|
104
|
+
GLITZ: 5,
|
|
105
|
+
QUARTZ: 6,
|
|
106
|
+
WIN32: 7,
|
|
107
|
+
BEOS: 8,
|
|
108
|
+
DIRECTFB: 9,
|
|
109
|
+
SVG: 10,
|
|
110
|
+
OS2: 11,
|
|
111
|
+
WIN32_PRINTING: 12,
|
|
112
|
+
QUARTZ_IMAGE: 13,
|
|
113
113
|
};
|
|
114
114
|
|
|
115
115
|
// ---- wrappers ---------------------------------------------------------------
|
|
@@ -121,385 +121,385 @@ export const SurfaceType = {
|
|
|
121
121
|
const H = '_ptr';
|
|
122
122
|
|
|
123
123
|
function setHandle(obj, handle) {
|
|
124
|
-
|
|
125
|
-
|
|
124
|
+
Object.defineProperty(obj, H, { value: handle, writable: true, configurable: true });
|
|
125
|
+
return obj;
|
|
126
126
|
}
|
|
127
127
|
|
|
128
128
|
// Build a wrapper for an existing native handle WITHOUT running the class
|
|
129
129
|
// constructor (which would allocate a fresh cairo object) — used by the static
|
|
130
130
|
// `create*` factories + the foreign from_func factories.
|
|
131
131
|
function wrapRaw(Klass, handle) {
|
|
132
|
-
|
|
132
|
+
return setHandle(Object.create(Klass.prototype), handle);
|
|
133
133
|
}
|
|
134
134
|
|
|
135
135
|
function handleOf(x, what) {
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
136
|
+
const h = x != null ? x[H] : undefined;
|
|
137
|
+
if (h === undefined) throw new TypeError(`expected a ${what}`);
|
|
138
|
+
return h;
|
|
139
139
|
}
|
|
140
140
|
|
|
141
141
|
/** cairo drawing context. `new cairo.Context(surface)` wraps `cairo_create`. */
|
|
142
142
|
export class Context {
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
|
|
341
|
-
|
|
342
|
-
|
|
343
|
-
|
|
344
|
-
|
|
345
|
-
|
|
346
|
-
|
|
347
|
-
|
|
348
|
-
|
|
349
|
-
|
|
350
|
-
|
|
351
|
-
|
|
352
|
-
|
|
353
|
-
|
|
354
|
-
|
|
355
|
-
|
|
356
|
-
|
|
357
|
-
|
|
358
|
-
|
|
359
|
-
|
|
360
|
-
|
|
361
|
-
|
|
362
|
-
|
|
363
|
-
|
|
364
|
-
|
|
365
|
-
|
|
366
|
-
|
|
367
|
-
|
|
368
|
-
|
|
369
|
-
|
|
370
|
-
|
|
371
|
-
|
|
372
|
-
|
|
143
|
+
constructor(surface) {
|
|
144
|
+
setHandle(this, c.contextCreate(handleOf(surface, 'cairo.Surface')));
|
|
145
|
+
}
|
|
146
|
+
|
|
147
|
+
save() {
|
|
148
|
+
c.save(this[H]);
|
|
149
|
+
}
|
|
150
|
+
restore() {
|
|
151
|
+
c.restore(this[H]);
|
|
152
|
+
}
|
|
153
|
+
newPath() {
|
|
154
|
+
c.newPath(this[H]);
|
|
155
|
+
}
|
|
156
|
+
closePath() {
|
|
157
|
+
c.closePath(this[H]);
|
|
158
|
+
}
|
|
159
|
+
|
|
160
|
+
moveTo(x, y) {
|
|
161
|
+
c.moveTo(this[H], x, y);
|
|
162
|
+
}
|
|
163
|
+
lineTo(x, y) {
|
|
164
|
+
c.lineTo(this[H], x, y);
|
|
165
|
+
}
|
|
166
|
+
relMoveTo(dx, dy) {
|
|
167
|
+
c.relMoveTo(this[H], dx, dy);
|
|
168
|
+
}
|
|
169
|
+
relLineTo(dx, dy) {
|
|
170
|
+
c.relLineTo(this[H], dx, dy);
|
|
171
|
+
}
|
|
172
|
+
rectangle(x, y, width, height) {
|
|
173
|
+
c.rectangle(this[H], x, y, width, height);
|
|
174
|
+
}
|
|
175
|
+
arc(xc, yc, radius, angle1, angle2) {
|
|
176
|
+
c.arc(this[H], xc, yc, radius, angle1, angle2);
|
|
177
|
+
}
|
|
178
|
+
arcNegative(xc, yc, radius, angle1, angle2) {
|
|
179
|
+
c.arcNegative(this[H], xc, yc, radius, angle1, angle2);
|
|
180
|
+
}
|
|
181
|
+
curveTo(x1, y1, x2, y2, x3, y3) {
|
|
182
|
+
c.curveTo(this[H], x1, y1, x2, y2, x3, y3);
|
|
183
|
+
}
|
|
184
|
+
|
|
185
|
+
fill() {
|
|
186
|
+
c.fill(this[H]);
|
|
187
|
+
}
|
|
188
|
+
fillPreserve() {
|
|
189
|
+
c.fillPreserve(this[H]);
|
|
190
|
+
}
|
|
191
|
+
stroke() {
|
|
192
|
+
c.stroke(this[H]);
|
|
193
|
+
}
|
|
194
|
+
strokePreserve() {
|
|
195
|
+
c.strokePreserve(this[H]);
|
|
196
|
+
}
|
|
197
|
+
paint() {
|
|
198
|
+
c.paint(this[H]);
|
|
199
|
+
}
|
|
200
|
+
paintWithAlpha(alpha) {
|
|
201
|
+
c.paintWithAlpha(this[H], alpha);
|
|
202
|
+
}
|
|
203
|
+
clip() {
|
|
204
|
+
c.clip(this[H]);
|
|
205
|
+
}
|
|
206
|
+
clipPreserve() {
|
|
207
|
+
c.clipPreserve(this[H]);
|
|
208
|
+
}
|
|
209
|
+
|
|
210
|
+
translate(tx, ty) {
|
|
211
|
+
c.translate(this[H], tx, ty);
|
|
212
|
+
}
|
|
213
|
+
scale(sx, sy) {
|
|
214
|
+
c.scale(this[H], sx, sy);
|
|
215
|
+
}
|
|
216
|
+
rotate(angle) {
|
|
217
|
+
c.rotate(this[H], angle);
|
|
218
|
+
}
|
|
219
|
+
identityMatrix() {
|
|
220
|
+
c.identityMatrix(this[H]);
|
|
221
|
+
}
|
|
222
|
+
newSubPath() {
|
|
223
|
+
c.newSubPath(this[H]);
|
|
224
|
+
}
|
|
225
|
+
/** User → device coordinates as `[x, y]` (GJS return shape). */
|
|
226
|
+
userToDevice(x, y) {
|
|
227
|
+
return c.userToDevice(this[H], x, y);
|
|
228
|
+
}
|
|
229
|
+
/** User → device distance (ignores translation) as `[dx, dy]`. */
|
|
230
|
+
userToDeviceDistance(dx, dy) {
|
|
231
|
+
return c.userToDeviceDistance(this[H], dx, dy);
|
|
232
|
+
}
|
|
233
|
+
/** Device → user coordinates as `[x, y]`. */
|
|
234
|
+
deviceToUser(x, y) {
|
|
235
|
+
return c.deviceToUser(this[H], x, y);
|
|
236
|
+
}
|
|
237
|
+
/** Device → user distance (ignores translation) as `[dx, dy]`. */
|
|
238
|
+
deviceToUserDistance(dx, dy) {
|
|
239
|
+
return c.deviceToUserDistance(this[H], dx, dy);
|
|
240
|
+
}
|
|
241
|
+
/** Copy the current path into an owned {@link Path} handle. */
|
|
242
|
+
copyPath() {
|
|
243
|
+
return wrapRaw(Path, c.copyPath(this[H]));
|
|
244
|
+
}
|
|
245
|
+
/** Like {@link copyPath} but with curves flattened to line segments. */
|
|
246
|
+
copyPathFlat() {
|
|
247
|
+
return wrapRaw(Path, c.copyPathFlat(this[H]));
|
|
248
|
+
}
|
|
249
|
+
appendPath(path) {
|
|
250
|
+
c.appendPath(this[H], handleOf(path, 'cairo.Path'));
|
|
251
|
+
}
|
|
252
|
+
/**
|
|
253
|
+
* Set the stroke dash pattern. GJS semantics: holes/undefined entries are
|
|
254
|
+
* skipped, a non-positive value throws, an empty array disables dashing.
|
|
255
|
+
*/
|
|
256
|
+
setDash(dashes, offset) {
|
|
257
|
+
c.setDash(this[H], dashes, offset);
|
|
258
|
+
}
|
|
259
|
+
getDashCount() {
|
|
260
|
+
return c.getDashCount(this[H]);
|
|
261
|
+
}
|
|
262
|
+
/**
|
|
263
|
+
* The current dash pattern as `[dashes, offset]`.
|
|
264
|
+
* Note: GJS ships only `getDashCount`; this is a node-gi convenience.
|
|
265
|
+
*/
|
|
266
|
+
getDash() {
|
|
267
|
+
return c.getDash(this[H]);
|
|
268
|
+
}
|
|
269
|
+
inFill(x, y) {
|
|
270
|
+
return c.inFill(this[H], x, y);
|
|
271
|
+
}
|
|
272
|
+
inStroke(x, y) {
|
|
273
|
+
return c.inStroke(this[H], x, y);
|
|
274
|
+
}
|
|
275
|
+
|
|
276
|
+
setSourceRGB(red, green, blue) {
|
|
277
|
+
c.setSourceRGB(this[H], red, green, blue);
|
|
278
|
+
}
|
|
279
|
+
setSourceRGBA(red, green, blue, alpha) {
|
|
280
|
+
c.setSourceRGBA(this[H], red, green, blue, alpha);
|
|
281
|
+
}
|
|
282
|
+
setSource(pattern) {
|
|
283
|
+
c.setSource(this[H], handleOf(pattern, 'cairo.Pattern'));
|
|
284
|
+
}
|
|
285
|
+
setSourceSurface(surface, x, y) {
|
|
286
|
+
c.setSourceSurface(this[H], handleOf(surface, 'cairo.Surface'), x, y);
|
|
287
|
+
}
|
|
288
|
+
/** The context's current source pattern (a ref of its own — safe to keep). */
|
|
289
|
+
getSource() {
|
|
290
|
+
return wrapPatternHandle(c.getSource(this[H]));
|
|
291
|
+
}
|
|
292
|
+
|
|
293
|
+
setLineWidth(width) {
|
|
294
|
+
c.setLineWidth(this[H], width);
|
|
295
|
+
}
|
|
296
|
+
getLineWidth() {
|
|
297
|
+
return c.getLineWidth(this[H]);
|
|
298
|
+
}
|
|
299
|
+
getOperator() {
|
|
300
|
+
return c.getOperator(this[H]);
|
|
301
|
+
}
|
|
302
|
+
getLineCap() {
|
|
303
|
+
return c.getLineCap(this[H]);
|
|
304
|
+
}
|
|
305
|
+
getLineJoin() {
|
|
306
|
+
return c.getLineJoin(this[H]);
|
|
307
|
+
}
|
|
308
|
+
getFillRule() {
|
|
309
|
+
return c.getFillRule(this[H]);
|
|
310
|
+
}
|
|
311
|
+
getAntialias() {
|
|
312
|
+
return c.getAntialias(this[H]);
|
|
313
|
+
}
|
|
314
|
+
getMiterLimit() {
|
|
315
|
+
return c.getMiterLimit(this[H]);
|
|
316
|
+
}
|
|
317
|
+
getTolerance() {
|
|
318
|
+
return c.getTolerance(this[H]);
|
|
319
|
+
}
|
|
320
|
+
hasCurrentPoint() {
|
|
321
|
+
return c.hasCurrentPoint(this[H]);
|
|
322
|
+
}
|
|
323
|
+
/** The current path point as `[x, y]`. */
|
|
324
|
+
getCurrentPoint() {
|
|
325
|
+
return c.getCurrentPoint(this[H]);
|
|
326
|
+
}
|
|
327
|
+
/** Current-path bounding box as `[x1, y1, x2, y2]`. */
|
|
328
|
+
pathExtents() {
|
|
329
|
+
return c.pathExtents(this[H]);
|
|
330
|
+
}
|
|
331
|
+
/** Fill bounding box as `[x1, y1, x2, y2]`. */
|
|
332
|
+
fillExtents() {
|
|
333
|
+
return c.fillExtents(this[H]);
|
|
334
|
+
}
|
|
335
|
+
/** Stroke bounding box as `[x1, y1, x2, y2]`. */
|
|
336
|
+
strokeExtents() {
|
|
337
|
+
return c.strokeExtents(this[H]);
|
|
338
|
+
}
|
|
339
|
+
/** Clip bounding box as `[x1, y1, x2, y2]`. */
|
|
340
|
+
clipExtents() {
|
|
341
|
+
return c.clipExtents(this[H]);
|
|
342
|
+
}
|
|
343
|
+
setLineCap(lineCap) {
|
|
344
|
+
c.setLineCap(this[H], lineCap);
|
|
345
|
+
}
|
|
346
|
+
setLineJoin(lineJoin) {
|
|
347
|
+
c.setLineJoin(this[H], lineJoin);
|
|
348
|
+
}
|
|
349
|
+
setFillRule(fillRule) {
|
|
350
|
+
c.setFillRule(this[H], fillRule);
|
|
351
|
+
}
|
|
352
|
+
setAntialias(antialias) {
|
|
353
|
+
c.setAntialias(this[H], antialias);
|
|
354
|
+
}
|
|
355
|
+
setOperator(op) {
|
|
356
|
+
c.setOperator(this[H], op);
|
|
357
|
+
}
|
|
358
|
+
setMiterLimit(limit) {
|
|
359
|
+
c.setMiterLimit(this[H], limit);
|
|
360
|
+
}
|
|
361
|
+
setTolerance(tolerance) {
|
|
362
|
+
c.setTolerance(this[H], tolerance);
|
|
363
|
+
}
|
|
364
|
+
|
|
365
|
+
status() {
|
|
366
|
+
return c.status(this[H]);
|
|
367
|
+
}
|
|
368
|
+
|
|
369
|
+
/** Eagerly destroy the underlying `cairo_t` (GJS `$dispose`). */
|
|
370
|
+
$dispose() {
|
|
371
|
+
c.dispose(this[H]);
|
|
372
|
+
}
|
|
373
373
|
}
|
|
374
374
|
|
|
375
375
|
/** cairo surface base class — the shared Surface API (flush/finish/writeToPNG/…). */
|
|
376
376
|
export class Surface {
|
|
377
|
-
|
|
378
|
-
|
|
379
|
-
|
|
380
|
-
|
|
381
|
-
|
|
382
|
-
|
|
383
|
-
|
|
384
|
-
|
|
385
|
-
|
|
386
|
-
|
|
387
|
-
|
|
388
|
-
|
|
389
|
-
|
|
390
|
-
|
|
391
|
-
|
|
392
|
-
|
|
393
|
-
|
|
394
|
-
|
|
395
|
-
|
|
377
|
+
getType() {
|
|
378
|
+
return c.surfaceGetType(this[H]);
|
|
379
|
+
}
|
|
380
|
+
status() {
|
|
381
|
+
return c.surfaceStatus(this[H]);
|
|
382
|
+
}
|
|
383
|
+
flush() {
|
|
384
|
+
c.surfaceFlush(this[H]);
|
|
385
|
+
}
|
|
386
|
+
finish() {
|
|
387
|
+
c.surfaceFinish(this[H]);
|
|
388
|
+
}
|
|
389
|
+
writeToPNG(filename) {
|
|
390
|
+
c.surfaceWriteToPNG(this[H], filename);
|
|
391
|
+
}
|
|
392
|
+
/** Eagerly destroy the underlying `cairo_surface_t` (GJS `$dispose`). */
|
|
393
|
+
$dispose() {
|
|
394
|
+
c.dispose(this[H]);
|
|
395
|
+
}
|
|
396
396
|
}
|
|
397
397
|
|
|
398
398
|
/** An in-memory image surface (`cairo_image_surface_*`). */
|
|
399
399
|
export class ImageSurface extends Surface {
|
|
400
|
-
|
|
401
|
-
|
|
402
|
-
|
|
403
|
-
|
|
404
|
-
|
|
405
|
-
|
|
406
|
-
|
|
407
|
-
|
|
408
|
-
|
|
409
|
-
|
|
410
|
-
|
|
411
|
-
|
|
412
|
-
|
|
413
|
-
|
|
414
|
-
|
|
415
|
-
|
|
416
|
-
|
|
417
|
-
|
|
418
|
-
|
|
419
|
-
|
|
420
|
-
|
|
421
|
-
|
|
422
|
-
|
|
423
|
-
|
|
424
|
-
|
|
425
|
-
|
|
426
|
-
|
|
427
|
-
|
|
428
|
-
|
|
429
|
-
|
|
430
|
-
|
|
431
|
-
|
|
400
|
+
constructor(format, width, height) {
|
|
401
|
+
super();
|
|
402
|
+
setHandle(this, c.imageSurfaceCreate(format, width, height));
|
|
403
|
+
}
|
|
404
|
+
|
|
405
|
+
static create(format, width, height) {
|
|
406
|
+
return new ImageSurface(format, width, height);
|
|
407
|
+
}
|
|
408
|
+
static createFromPNG(filename) {
|
|
409
|
+
return wrapRaw(ImageSurface, c.imageSurfaceCreateFromPNG(filename));
|
|
410
|
+
}
|
|
411
|
+
|
|
412
|
+
getWidth() {
|
|
413
|
+
return c.imageSurfaceGetWidth(this[H]);
|
|
414
|
+
}
|
|
415
|
+
getHeight() {
|
|
416
|
+
return c.imageSurfaceGetHeight(this[H]);
|
|
417
|
+
}
|
|
418
|
+
getStride() {
|
|
419
|
+
return c.imageSurfaceGetStride(this[H]);
|
|
420
|
+
}
|
|
421
|
+
getFormat() {
|
|
422
|
+
return c.imageSurfaceGetFormat(this[H]);
|
|
423
|
+
}
|
|
424
|
+
/**
|
|
425
|
+
* The raw pixel buffer as a fresh Uint8Array copy (length = stride * height).
|
|
426
|
+
* Note: GJS ships no `getData`; this is a node-gi convenience for headless pixel
|
|
427
|
+
* assertions. The buffer is flushed first + copied (independent of the surface).
|
|
428
|
+
*/
|
|
429
|
+
getData() {
|
|
430
|
+
return c.imageSurfaceGetData(this[H]);
|
|
431
|
+
}
|
|
432
432
|
}
|
|
433
433
|
|
|
434
434
|
/** cairo pattern base class. */
|
|
435
435
|
export class Pattern {
|
|
436
|
-
|
|
437
|
-
|
|
438
|
-
|
|
439
|
-
|
|
440
|
-
|
|
441
|
-
|
|
442
|
-
|
|
443
|
-
|
|
444
|
-
|
|
445
|
-
|
|
436
|
+
getType() {
|
|
437
|
+
return c.patternGetType(this[H]);
|
|
438
|
+
}
|
|
439
|
+
status() {
|
|
440
|
+
return c.patternStatus(this[H]);
|
|
441
|
+
}
|
|
442
|
+
/** Eagerly destroy the underlying `cairo_pattern_t` (GJS `$dispose`). */
|
|
443
|
+
$dispose() {
|
|
444
|
+
c.dispose(this[H]);
|
|
445
|
+
}
|
|
446
446
|
}
|
|
447
447
|
|
|
448
448
|
/** A solid-color pattern (`cairo_pattern_create_rgb[a]`). */
|
|
449
449
|
export class SolidPattern extends Pattern {
|
|
450
|
-
|
|
451
|
-
|
|
452
|
-
|
|
453
|
-
|
|
454
|
-
|
|
455
|
-
|
|
450
|
+
static createRGB(red, green, blue) {
|
|
451
|
+
return wrapRaw(SolidPattern, c.solidPatternCreateRGB(red, green, blue));
|
|
452
|
+
}
|
|
453
|
+
static createRGBA(red, green, blue, alpha) {
|
|
454
|
+
return wrapRaw(SolidPattern, c.solidPatternCreateRGBA(red, green, blue, alpha));
|
|
455
|
+
}
|
|
456
456
|
}
|
|
457
457
|
|
|
458
458
|
/** Gradient base class — the shared color-stop API (GJS `CairoGradient`). */
|
|
459
459
|
export class Gradient extends Pattern {
|
|
460
|
-
|
|
461
|
-
|
|
462
|
-
|
|
463
|
-
|
|
464
|
-
|
|
465
|
-
|
|
460
|
+
addColorStopRGB(offset, red, green, blue) {
|
|
461
|
+
c.patternAddColorStopRGB(this[H], offset, red, green, blue);
|
|
462
|
+
}
|
|
463
|
+
addColorStopRGBA(offset, red, green, blue, alpha) {
|
|
464
|
+
c.patternAddColorStopRGBA(this[H], offset, red, green, blue, alpha);
|
|
465
|
+
}
|
|
466
466
|
}
|
|
467
467
|
|
|
468
468
|
/** A linear gradient (`cairo_pattern_create_linear`). */
|
|
469
469
|
export class LinearGradient extends Gradient {
|
|
470
|
-
|
|
471
|
-
|
|
472
|
-
|
|
473
|
-
|
|
470
|
+
constructor(x0, y0, x1, y1) {
|
|
471
|
+
super();
|
|
472
|
+
setHandle(this, c.linearGradientCreate(x0, y0, x1, y1));
|
|
473
|
+
}
|
|
474
474
|
}
|
|
475
475
|
|
|
476
476
|
/** A radial gradient (`cairo_pattern_create_radial`). */
|
|
477
477
|
export class RadialGradient extends Gradient {
|
|
478
|
-
|
|
479
|
-
|
|
480
|
-
|
|
481
|
-
|
|
478
|
+
constructor(cx0, cy0, radius0, cx1, cy1, radius1) {
|
|
479
|
+
super();
|
|
480
|
+
setHandle(this, c.radialGradientCreate(cx0, cy0, radius0, cx1, cy1, radius1));
|
|
481
|
+
}
|
|
482
482
|
}
|
|
483
483
|
|
|
484
484
|
/** A surface-backed pattern (`cairo_pattern_create_for_surface`). */
|
|
485
485
|
export class SurfacePattern extends Pattern {
|
|
486
|
-
|
|
487
|
-
|
|
488
|
-
|
|
489
|
-
|
|
490
|
-
|
|
491
|
-
|
|
492
|
-
|
|
493
|
-
|
|
494
|
-
|
|
495
|
-
|
|
496
|
-
|
|
497
|
-
|
|
498
|
-
|
|
499
|
-
|
|
500
|
-
|
|
501
|
-
|
|
502
|
-
|
|
486
|
+
constructor(surface) {
|
|
487
|
+
super();
|
|
488
|
+
setHandle(this, c.surfacePatternCreate(handleOf(surface, 'cairo.Surface')));
|
|
489
|
+
}
|
|
490
|
+
|
|
491
|
+
setExtend(extend) {
|
|
492
|
+
c.patternSetExtend(this[H], extend);
|
|
493
|
+
}
|
|
494
|
+
getExtend() {
|
|
495
|
+
return c.patternGetExtend(this[H]);
|
|
496
|
+
}
|
|
497
|
+
setFilter(filter) {
|
|
498
|
+
c.patternSetFilter(this[H], filter);
|
|
499
|
+
}
|
|
500
|
+
getFilter() {
|
|
501
|
+
return c.patternGetFilter(this[H]);
|
|
502
|
+
}
|
|
503
503
|
}
|
|
504
504
|
|
|
505
505
|
/**
|
|
@@ -513,18 +513,18 @@ export class Path {}
|
|
|
513
513
|
// mirrors gjs_cairo_pattern_from_pattern (MESH/RASTER_SOURCE fall back to the
|
|
514
514
|
// base Pattern; gjs throws for those, but they are unreachable from this module).
|
|
515
515
|
function wrapPatternHandle(handle) {
|
|
516
|
-
|
|
517
|
-
|
|
518
|
-
|
|
519
|
-
|
|
520
|
-
|
|
521
|
-
|
|
522
|
-
|
|
523
|
-
|
|
524
|
-
|
|
525
|
-
|
|
526
|
-
|
|
527
|
-
|
|
516
|
+
const t = c.patternGetType(handle);
|
|
517
|
+
const Klass =
|
|
518
|
+
t === PatternType.SOLID
|
|
519
|
+
? SolidPattern
|
|
520
|
+
: t === PatternType.SURFACE
|
|
521
|
+
? SurfacePattern
|
|
522
|
+
: t === PatternType.LINEAR
|
|
523
|
+
? LinearGradient
|
|
524
|
+
: t === PatternType.RADIAL
|
|
525
|
+
? RadialGradient
|
|
526
|
+
: Pattern;
|
|
527
|
+
return wrapRaw(Klass, handle);
|
|
528
528
|
}
|
|
529
529
|
|
|
530
530
|
// Register the wrapper factories so the engine's foreign-struct from_func can turn
|
|
@@ -532,39 +532,38 @@ function wrapPatternHandle(handle) {
|
|
|
532
532
|
// fan out to the concrete subclass by cairo runtime type (mirrors
|
|
533
533
|
// CairoSurface::from_c_ptr / gjs_cairo_pattern_from_pattern).
|
|
534
534
|
c.setup({
|
|
535
|
-
|
|
536
|
-
|
|
537
|
-
|
|
538
|
-
|
|
539
|
-
path: (handle) => wrapRaw(Path, handle),
|
|
535
|
+
context: (handle) => wrapRaw(Context, handle),
|
|
536
|
+
surface: (handle) => wrapRaw(c.surfaceGetType(handle) === SurfaceType.IMAGE ? ImageSurface : Surface, handle),
|
|
537
|
+
pattern: (handle) => wrapPatternHandle(handle),
|
|
538
|
+
path: (handle) => wrapRaw(Path, handle),
|
|
540
539
|
});
|
|
541
540
|
|
|
542
541
|
// The default export mirrors GJS's ESM `cairo` object (enums + constructors), the
|
|
543
542
|
// shape `import cairo from 'cairo'` returns.
|
|
544
543
|
const cairo = {
|
|
545
|
-
|
|
546
|
-
|
|
547
|
-
|
|
548
|
-
|
|
549
|
-
|
|
550
|
-
|
|
551
|
-
|
|
552
|
-
|
|
553
|
-
|
|
554
|
-
|
|
555
|
-
|
|
556
|
-
|
|
557
|
-
|
|
558
|
-
|
|
559
|
-
|
|
560
|
-
|
|
561
|
-
|
|
562
|
-
|
|
563
|
-
|
|
564
|
-
|
|
565
|
-
|
|
566
|
-
|
|
567
|
-
|
|
544
|
+
Antialias,
|
|
545
|
+
Content,
|
|
546
|
+
Extend,
|
|
547
|
+
FillRule,
|
|
548
|
+
Filter,
|
|
549
|
+
FontSlant,
|
|
550
|
+
FontWeight,
|
|
551
|
+
Format,
|
|
552
|
+
LineCap,
|
|
553
|
+
LineJoin,
|
|
554
|
+
Operator,
|
|
555
|
+
PatternType,
|
|
556
|
+
SurfaceType,
|
|
557
|
+
Context,
|
|
558
|
+
Surface,
|
|
559
|
+
ImageSurface,
|
|
560
|
+
Pattern,
|
|
561
|
+
SolidPattern,
|
|
562
|
+
Gradient,
|
|
563
|
+
LinearGradient,
|
|
564
|
+
RadialGradient,
|
|
565
|
+
SurfacePattern,
|
|
566
|
+
Path,
|
|
568
567
|
};
|
|
569
568
|
|
|
570
569
|
export default cairo;
|