@gtkx/codegen 1.2.1 → 1.3.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/README.md +2 -1
- package/dist/analysis/descriptor-render.d.ts +7 -1
- package/dist/analysis/descriptor-render.d.ts.map +1 -1
- package/dist/analysis/descriptor-render.js +36 -15
- package/dist/analysis/descriptor-render.js.map +1 -1
- package/dist/analysis/descriptor.d.ts +4 -1
- package/dist/analysis/descriptor.d.ts.map +1 -1
- package/dist/analysis/descriptor.js +11 -2
- package/dist/analysis/descriptor.js.map +1 -1
- package/dist/analysis/param-capability.d.ts +5 -2
- package/dist/analysis/param-capability.d.ts.map +1 -1
- package/dist/analysis/param-capability.js +36 -4
- package/dist/analysis/param-capability.js.map +1 -1
- package/dist/analysis/param-structure.d.ts +1 -1
- package/dist/analysis/param-structure.d.ts.map +1 -1
- package/dist/analysis/param-structure.js.map +1 -1
- package/dist/analysis/ts-type.d.ts +1 -1
- package/dist/analysis/ts-type.d.ts.map +1 -1
- package/dist/analysis/ts-type.js +28 -10
- package/dist/analysis/ts-type.js.map +1 -1
- package/dist/compile.js +1 -1
- package/dist/compile.js.map +1 -1
- package/dist/docs/api-reference.d.ts +6 -0
- package/dist/docs/api-reference.d.ts.map +1 -1
- package/dist/docs/api-reference.js +11 -2
- package/dist/docs/api-reference.js.map +1 -1
- package/dist/docs/pipeline.d.ts +3 -0
- package/dist/docs/pipeline.d.ts.map +1 -1
- package/dist/docs/pipeline.js +10 -1
- package/dist/docs/pipeline.js.map +1 -1
- package/dist/fingerprint.d.ts +5 -0
- package/dist/fingerprint.d.ts.map +1 -1
- package/dist/fingerprint.js +107 -15
- package/dist/fingerprint.js.map +1 -1
- package/dist/gi.d.ts +3 -0
- package/dist/gi.d.ts.map +1 -1
- package/dist/gi.js +29 -7
- package/dist/gi.js.map +1 -1
- package/dist/gir/external-namespaces.d.ts +8 -0
- package/dist/gir/external-namespaces.d.ts.map +1 -0
- package/dist/gir/external-namespaces.js +4 -0
- package/dist/gir/external-namespaces.js.map +1 -0
- package/dist/gir/finish-overrides.d.ts +3 -0
- package/dist/gir/finish-overrides.d.ts.map +1 -0
- package/dist/gir/finish-overrides.js +5 -0
- package/dist/gir/finish-overrides.js.map +1 -0
- package/dist/gir/function.d.ts +5 -2
- package/dist/gir/function.d.ts.map +1 -1
- package/dist/gir/function.js +34 -5
- package/dist/gir/function.js.map +1 -1
- package/dist/gir/hidden-symbols.d.ts +3 -0
- package/dist/gir/hidden-symbols.d.ts.map +1 -0
- package/dist/gir/hidden-symbols.js +39 -0
- package/dist/gir/hidden-symbols.js.map +1 -0
- package/dist/gir/library.d.ts +22 -2
- package/dist/gir/library.d.ts.map +1 -1
- package/dist/gir/library.js +21 -3
- package/dist/gir/library.js.map +1 -1
- package/dist/gir/ucs4-overrides.d.ts +3 -0
- package/dist/gir/ucs4-overrides.d.ts.map +1 -0
- package/dist/gir/ucs4-overrides.js +7 -0
- package/dist/gir/ucs4-overrides.js.map +1 -0
- package/dist/jsx.d.ts.map +1 -1
- package/dist/jsx.js +27 -8
- package/dist/jsx.js.map +1 -1
- package/dist/runner.d.ts +8 -0
- package/dist/runner.d.ts.map +1 -1
- package/dist/runner.js +9 -3
- package/dist/runner.js.map +1 -1
- package/dist/store/external-package-links.d.ts +6 -0
- package/dist/store/external-package-links.d.ts.map +1 -0
- package/dist/store/external-package-links.js +158 -0
- package/dist/store/external-package-links.js.map +1 -0
- package/dist/store/gi/callable-doc.d.ts.map +1 -1
- package/dist/store/gi/callable-doc.js +4 -4
- package/dist/store/gi/callable-doc.js.map +1 -1
- package/dist/store/gi/callables.d.ts +1 -1
- package/dist/store/gi/callables.d.ts.map +1 -1
- package/dist/store/gi/callables.js +4 -4
- package/dist/store/gi/callables.js.map +1 -1
- package/dist/store/gi/class.d.ts.map +1 -1
- package/dist/store/gi/class.js +25 -15
- package/dist/store/gi/class.js.map +1 -1
- package/dist/store/gi/constructor-props.js +1 -1
- package/dist/store/gi/constructor-props.js.map +1 -1
- package/dist/store/gi/function.d.ts.map +1 -1
- package/dist/store/gi/function.js +2 -1
- package/dist/store/gi/function.js.map +1 -1
- package/dist/store/gi/gtype-binding.d.ts +2 -2
- package/dist/store/gi/gtype-binding.d.ts.map +1 -1
- package/dist/store/gi/gtype-binding.js +6 -13
- package/dist/store/gi/gtype-binding.js.map +1 -1
- package/dist/store/gi/interface.js +2 -2
- package/dist/store/gi/interface.js.map +1 -1
- package/dist/store/gi/method.d.ts +7 -2
- package/dist/store/gi/method.d.ts.map +1 -1
- package/dist/store/gi/method.js +126 -30
- package/dist/store/gi/method.js.map +1 -1
- package/dist/store/gi/param-marshal.d.ts +8 -1
- package/dist/store/gi/param-marshal.d.ts.map +1 -1
- package/dist/store/gi/param-marshal.js +52 -4
- package/dist/store/gi/param-marshal.js.map +1 -1
- package/dist/store/gi/record-constructor.d.ts.map +1 -1
- package/dist/store/gi/record-constructor.js +2 -3
- package/dist/store/gi/record-constructor.js.map +1 -1
- package/dist/store/gi/record-field-accessor.d.ts +2 -1
- package/dist/store/gi/record-field-accessor.d.ts.map +1 -1
- package/dist/store/gi/record-field-accessor.js +142 -16
- package/dist/store/gi/record-field-accessor.js.map +1 -1
- package/dist/store/gi/record-layout.d.ts +5 -2
- package/dist/store/gi/record-layout.d.ts.map +1 -1
- package/dist/store/gi/record-layout.js +2 -1
- package/dist/store/gi/record-layout.js.map +1 -1
- package/dist/store/gi/record.d.ts.map +1 -1
- package/dist/store/gi/record.js +9 -5
- package/dist/store/gi/record.js.map +1 -1
- package/dist/store/gi/runtime-override.js +1 -1
- package/dist/store/gi/runtime-override.js.map +1 -1
- package/dist/store/gi/signal.js +2 -2
- package/dist/store/gi/signal.js.map +1 -1
- package/dist/store/gi/vtable.d.ts.map +1 -1
- package/dist/store/gi/vtable.js +82 -12
- package/dist/store/gi/vtable.js.map +1 -1
- package/dist/store/gi-store.d.ts +7 -2
- package/dist/store/gi-store.d.ts.map +1 -1
- package/dist/store/gi-store.js +19 -4
- package/dist/store/gi-store.js.map +1 -1
- package/dist/store/jsx/jsx.d.ts.map +1 -1
- package/dist/store/jsx/jsx.js +3 -1
- package/dist/store/jsx/jsx.js.map +1 -1
- package/dist/store/jsx-store.d.ts +8 -1
- package/dist/store/jsx-store.d.ts.map +1 -1
- package/dist/store/jsx-store.js +9 -2
- package/dist/store/jsx-store.js.map +1 -1
- package/dist/store/resolve-store.d.ts +2 -1
- package/dist/store/resolve-store.d.ts.map +1 -1
- package/dist/store/resolve-store.js +2 -1
- package/dist/store/resolve-store.js.map +1 -1
- package/dist/store/store-fs.d.ts +2 -1
- package/dist/store/store-fs.d.ts.map +1 -1
- package/dist/store/store-fs.js +8 -3
- package/dist/store/store-fs.js.map +1 -1
- package/dist/writer/context.d.ts.map +1 -1
- package/dist/writer/context.js +8 -0
- package/dist/writer/context.js.map +1 -1
- package/dist/writer/gtk-doc.d.ts.map +1 -1
- package/dist/writer/gtk-doc.js +27 -1
- package/dist/writer/gtk-doc.js.map +1 -1
- package/overrides/gdk/rgba.ts.ejs +15 -1
- package/overrides/glib/index.ts.ejs +3 -0
- package/overrides/glib/regex.ts.ejs +66 -0
- package/overrides/gobject/index.ts.ejs +3 -0
- package/overrides/gobject/object-class.ts.ejs +27 -0
- package/overrides/gobject/param-spec-getters.ts.ejs +57 -0
- package/overrides/gobject/param-spec.ts.ejs +21 -0
- package/overrides/gobject/value.ts.ejs +6 -1
- package/overrides/graphene/structs.ts.ejs +38 -3
- package/overrides/gtk/index.ts.ejs +2 -0
- package/overrides/gtk/widget-class.ts.ejs +28 -0
- package/package.json +6 -5
- package/src/analysis/descriptor-render.ts +59 -16
- package/src/analysis/descriptor.ts +15 -3
- package/src/analysis/param-capability.ts +68 -5
- package/src/analysis/param-structure.ts +1 -1
- package/src/analysis/ts-type.ts +45 -11
- package/src/compile.ts +1 -1
- package/src/docs/api-reference.ts +20 -2
- package/src/docs/pipeline.ts +15 -1
- package/src/fingerprint.ts +144 -16
- package/src/gi.ts +44 -9
- package/src/gir/external-namespaces.ts +8 -0
- package/src/gir/finish-overrides.ts +5 -0
- package/src/gir/function.ts +52 -14
- package/src/gir/hidden-symbols.ts +39 -0
- package/src/gir/library.ts +36 -3
- package/src/gir/ucs4-overrides.ts +7 -0
- package/src/jsx.ts +33 -8
- package/src/runner.ts +17 -3
- package/src/store/external-package-links.ts +226 -0
- package/src/store/gi/callable-doc.ts +8 -4
- package/src/store/gi/callables.ts +5 -5
- package/src/store/gi/class.ts +42 -32
- package/src/store/gi/constructor-props.ts +1 -1
- package/src/store/gi/function.ts +2 -1
- package/src/store/gi/gtype-binding.ts +7 -15
- package/src/store/gi/interface.ts +2 -2
- package/src/store/gi/method.ts +189 -36
- package/src/store/gi/param-marshal.ts +67 -4
- package/src/store/gi/record-constructor.ts +8 -3
- package/src/store/gi/record-field-accessor.ts +209 -16
- package/src/store/gi/record-layout.ts +11 -1
- package/src/store/gi/record.ts +17 -13
- package/src/store/gi/runtime-override.ts +1 -1
- package/src/store/gi/signal.ts +2 -2
- package/src/store/gi/vtable.ts +118 -11
- package/src/store/gi-store.ts +33 -3
- package/src/store/jsx/jsx.ts +3 -1
- package/src/store/jsx-store.ts +23 -7
- package/src/store/resolve-store.ts +2 -1
- package/src/store/store-fs.ts +10 -2
- package/src/writer/context.ts +11 -0
- package/src/writer/gtk-doc.ts +38 -1
- package/overrides/cairo/context.ts.ejs +0 -1269
- package/overrides/cairo/font-face.ts.ejs +0 -151
- package/overrides/cairo/font-options.ts.ejs +0 -199
- package/overrides/cairo/image-surface.ts.ejs +0 -132
- package/overrides/cairo/index.ts.ejs +0 -22
- package/overrides/cairo/matrix.ts.ejs +0 -171
- package/overrides/cairo/pattern.ts.ejs +0 -476
- package/overrides/cairo/recording-surface.ts.ejs +0 -102
- package/overrides/cairo/region.ts.ejs +0 -237
- package/overrides/cairo/scaled-font.ts.ejs +0 -330
- package/overrides/cairo/surface.ts.ejs +0 -296
|
@@ -1,1269 +0,0 @@
|
|
|
1
|
-
import { alloc, type ExternalObject, getHandle, type Handle, read, t, wrapHandle, write } from "@gtkx/runtime";
|
|
2
|
-
import type {
|
|
3
|
-
Antialias,
|
|
4
|
-
Content,
|
|
5
|
-
FillRule,
|
|
6
|
-
FontOptions,
|
|
7
|
-
FontSlant,
|
|
8
|
-
FontWeight,
|
|
9
|
-
LineCap,
|
|
10
|
-
LineJoin,
|
|
11
|
-
Operator,
|
|
12
|
-
Status,
|
|
13
|
-
TextClusterFlags,
|
|
14
|
-
} from "../cairo.js";
|
|
15
|
-
import { Context, FontFace, Pattern, ScaledFont, Surface } from "../cairo.js";
|
|
16
|
-
import { FontOptions as FontOptionsConstructor } from "./font-options.js";
|
|
17
|
-
import { allocMatrix, type Matrix as CairoMatrix } from "./matrix.js";
|
|
18
|
-
|
|
19
|
-
const { bind } = t;
|
|
20
|
-
const CONTEXT_T = t.boxed("CairoContext", {
|
|
21
|
-
ownership: "borrowed",
|
|
22
|
-
sharedLibrary: "libcairo-gobject.so.2",
|
|
23
|
-
getTypeFnName: "cairo_gobject_context_get_type",
|
|
24
|
-
});
|
|
25
|
-
|
|
26
|
-
export type CairoGlyph = { index: number; x: number; y: number };
|
|
27
|
-
export type CairoTextCluster = { numBytes: number; numGlyphs: number };
|
|
28
|
-
|
|
29
|
-
export const allocGlyphBuffer = (glyphs: CairoGlyph[]): ExternalObject<Handle> => {
|
|
30
|
-
const buf = alloc(glyphs.length * 24);
|
|
31
|
-
let offset = 0;
|
|
32
|
-
for (const glyph of glyphs) {
|
|
33
|
-
write(buf, t.uint64, offset, glyph.index);
|
|
34
|
-
write(buf, t.float64, offset + 8, glyph.x);
|
|
35
|
-
write(buf, t.float64, offset + 16, glyph.y);
|
|
36
|
-
offset += 24;
|
|
37
|
-
}
|
|
38
|
-
return buf;
|
|
39
|
-
};
|
|
40
|
-
|
|
41
|
-
export const allocClusterBuffer = (clusters: CairoTextCluster[]): ExternalObject<Handle> => {
|
|
42
|
-
const buf = alloc(clusters.length * 8);
|
|
43
|
-
let offset = 0;
|
|
44
|
-
for (const cluster of clusters) {
|
|
45
|
-
write(buf, t.int32, offset, cluster.numBytes);
|
|
46
|
-
write(buf, t.int32, offset + 4, cluster.numGlyphs);
|
|
47
|
-
offset += 8;
|
|
48
|
-
}
|
|
49
|
-
return buf;
|
|
50
|
-
};
|
|
51
|
-
|
|
52
|
-
export type TextExtents = {
|
|
53
|
-
xBearing: number;
|
|
54
|
-
yBearing: number;
|
|
55
|
-
width: number;
|
|
56
|
-
height: number;
|
|
57
|
-
xAdvance: number;
|
|
58
|
-
yAdvance: number;
|
|
59
|
-
};
|
|
60
|
-
|
|
61
|
-
export type FontExtents = {
|
|
62
|
-
ascent: number;
|
|
63
|
-
descent: number;
|
|
64
|
-
height: number;
|
|
65
|
-
maxXAdvance: number;
|
|
66
|
-
maxYAdvance: number;
|
|
67
|
-
};
|
|
68
|
-
|
|
69
|
-
export const readTextExtents = (handle: ExternalObject<Handle>): TextExtents => ({
|
|
70
|
-
xBearing: read(handle, t.float64, 0) as number,
|
|
71
|
-
yBearing: read(handle, t.float64, 8) as number,
|
|
72
|
-
width: read(handle, t.float64, 16) as number,
|
|
73
|
-
height: read(handle, t.float64, 24) as number,
|
|
74
|
-
xAdvance: read(handle, t.float64, 32) as number,
|
|
75
|
-
yAdvance: read(handle, t.float64, 40) as number,
|
|
76
|
-
});
|
|
77
|
-
|
|
78
|
-
export const readFontExtents = (handle: ExternalObject<Handle>): FontExtents => ({
|
|
79
|
-
ascent: read(handle, t.float64, 0) as number,
|
|
80
|
-
descent: read(handle, t.float64, 8) as number,
|
|
81
|
-
height: read(handle, t.float64, 16) as number,
|
|
82
|
-
maxXAdvance: read(handle, t.float64, 24) as number,
|
|
83
|
-
maxYAdvance: read(handle, t.float64, 32) as number,
|
|
84
|
-
});
|
|
85
|
-
|
|
86
|
-
export type PathData =
|
|
87
|
-
| { type: "moveTo"; x: number; y: number }
|
|
88
|
-
| { type: "lineTo"; x: number; y: number }
|
|
89
|
-
| { type: "curveTo"; x1: number; y1: number; x2: number; y2: number; x3: number; y3: number }
|
|
90
|
-
| { type: "closePath" };
|
|
91
|
-
|
|
92
|
-
const PATH_MOVE_TO = 0;
|
|
93
|
-
const PATH_LINE_TO = 1;
|
|
94
|
-
const PATH_CURVE_TO = 2;
|
|
95
|
-
const PATH_CLOSE_PATH = 3;
|
|
96
|
-
|
|
97
|
-
export const parsePath = (pathHandle: ExternalObject<Handle>): PathData[] => {
|
|
98
|
-
const numData = read(pathHandle, t.int32, 16) as number;
|
|
99
|
-
if (numData === 0) return [];
|
|
100
|
-
|
|
101
|
-
const dataArray = read(pathHandle, t.struct("borrowed", { size: numData * 16 }), 8) as ExternalObject<Handle>;
|
|
102
|
-
const result: PathData[] = [];
|
|
103
|
-
let i = 0;
|
|
104
|
-
while (i < numData) {
|
|
105
|
-
const base = i * 16;
|
|
106
|
-
const headerType = read(dataArray, t.int32, base) as number;
|
|
107
|
-
const length = read(dataArray, t.int32, base + 4) as number;
|
|
108
|
-
switch (headerType) {
|
|
109
|
-
case PATH_MOVE_TO: {
|
|
110
|
-
const ptBase = (i + 1) * 16;
|
|
111
|
-
result.push({
|
|
112
|
-
type: "moveTo",
|
|
113
|
-
x: read(dataArray, t.float64, ptBase) as number,
|
|
114
|
-
y: read(dataArray, t.float64, ptBase + 8) as number,
|
|
115
|
-
});
|
|
116
|
-
break;
|
|
117
|
-
}
|
|
118
|
-
case PATH_LINE_TO: {
|
|
119
|
-
const ptBase = (i + 1) * 16;
|
|
120
|
-
result.push({
|
|
121
|
-
type: "lineTo",
|
|
122
|
-
x: read(dataArray, t.float64, ptBase) as number,
|
|
123
|
-
y: read(dataArray, t.float64, ptBase + 8) as number,
|
|
124
|
-
});
|
|
125
|
-
break;
|
|
126
|
-
}
|
|
127
|
-
case PATH_CURVE_TO: {
|
|
128
|
-
const pt1 = (i + 1) * 16;
|
|
129
|
-
const pt2 = (i + 2) * 16;
|
|
130
|
-
const pt3 = (i + 3) * 16;
|
|
131
|
-
result.push({
|
|
132
|
-
type: "curveTo",
|
|
133
|
-
x1: read(dataArray, t.float64, pt1) as number,
|
|
134
|
-
y1: read(dataArray, t.float64, pt1 + 8) as number,
|
|
135
|
-
x2: read(dataArray, t.float64, pt2) as number,
|
|
136
|
-
y2: read(dataArray, t.float64, pt2 + 8) as number,
|
|
137
|
-
x3: read(dataArray, t.float64, pt3) as number,
|
|
138
|
-
y3: read(dataArray, t.float64, pt3 + 8) as number,
|
|
139
|
-
});
|
|
140
|
-
break;
|
|
141
|
-
}
|
|
142
|
-
case PATH_CLOSE_PATH: {
|
|
143
|
-
result.push({ type: "closePath" });
|
|
144
|
-
break;
|
|
145
|
-
}
|
|
146
|
-
}
|
|
147
|
-
i += length;
|
|
148
|
-
}
|
|
149
|
-
return result;
|
|
150
|
-
};
|
|
151
|
-
|
|
152
|
-
const cairoVersion = t.bind("libcairo.so.2", "cairo_version", [], t.int32);
|
|
153
|
-
const cairoVersionString = t.bind("libcairo.so.2", "cairo_version_string", [], t.string("borrowed"));
|
|
154
|
-
|
|
155
|
-
export const version = (): number => cairoVersion() as number;
|
|
156
|
-
|
|
157
|
-
export const versionString = (): string => cairoVersionString() as string;
|
|
158
|
-
|
|
159
|
-
declare module "../cairo.js" {
|
|
160
|
-
interface Context {
|
|
161
|
-
moveTo(x: number, y: number): void;
|
|
162
|
-
lineTo(x: number, y: number): void;
|
|
163
|
-
relMoveTo(dx: number, dy: number): void;
|
|
164
|
-
relLineTo(dx: number, dy: number): void;
|
|
165
|
-
relCurveTo(dx1: number, dy1: number, dx2: number, dy2: number, dx3: number, dy3: number): void;
|
|
166
|
-
curveTo(x1: number, y1: number, x2: number, y2: number, x3: number, y3: number): void;
|
|
167
|
-
arc(xc: number, yc: number, radius: number, angle1: number, angle2: number): void;
|
|
168
|
-
arcNegative(xc: number, yc: number, radius: number, angle1: number, angle2: number): void;
|
|
169
|
-
rectangle(x: number, y: number, width: number, height: number): void;
|
|
170
|
-
closePath(): void;
|
|
171
|
-
newPath(): void;
|
|
172
|
-
newSubPath(): void;
|
|
173
|
-
|
|
174
|
-
stroke(): void;
|
|
175
|
-
strokePreserve(): void;
|
|
176
|
-
fill(): void;
|
|
177
|
-
fillPreserve(): void;
|
|
178
|
-
paint(): void;
|
|
179
|
-
paintWithAlpha(alpha: number): void;
|
|
180
|
-
clip(): void;
|
|
181
|
-
clipPreserve(): void;
|
|
182
|
-
resetClip(): void;
|
|
183
|
-
|
|
184
|
-
setSourceRgb(red: number, green: number, blue: number): void;
|
|
185
|
-
setSourceRgba(red: number, green: number, blue: number, alpha: number): void;
|
|
186
|
-
setSource(pattern: Pattern): void;
|
|
187
|
-
|
|
188
|
-
setLineWidth(width: number): void;
|
|
189
|
-
getLineWidth(): number;
|
|
190
|
-
setLineCap(lineCap: LineCap): void;
|
|
191
|
-
getLineCap(): LineCap;
|
|
192
|
-
setLineJoin(lineJoin: LineJoin): void;
|
|
193
|
-
getLineJoin(): LineJoin;
|
|
194
|
-
setDash(dashes: number[], offset: number): void;
|
|
195
|
-
getDashCount(): number;
|
|
196
|
-
getDash(): { dashes: number[]; offset: number };
|
|
197
|
-
setMiterLimit(limit: number): void;
|
|
198
|
-
getMiterLimit(): number;
|
|
199
|
-
setTolerance(tolerance: number): void;
|
|
200
|
-
getTolerance(): number;
|
|
201
|
-
|
|
202
|
-
setFillRule(fillRule: FillRule): void;
|
|
203
|
-
getFillRule(): FillRule;
|
|
204
|
-
|
|
205
|
-
save(): void;
|
|
206
|
-
restore(): void;
|
|
207
|
-
translate(tx: number, ty: number): void;
|
|
208
|
-
scale(sx: number, sy: number): void;
|
|
209
|
-
rotate(angle: number): void;
|
|
210
|
-
|
|
211
|
-
setOperator(op: Operator): void;
|
|
212
|
-
getOperator(): Operator;
|
|
213
|
-
|
|
214
|
-
selectFontFace(family: string, slant: FontSlant, weight: FontWeight): void;
|
|
215
|
-
setFontSize(size: number): void;
|
|
216
|
-
showText(text: string): void;
|
|
217
|
-
textPath(text: string): void;
|
|
218
|
-
textExtents(text: string): TextExtents;
|
|
219
|
-
fontExtents(): FontExtents;
|
|
220
|
-
|
|
221
|
-
setFontOptions(options: FontOptions): void;
|
|
222
|
-
getFontOptions(): FontOptions;
|
|
223
|
-
setAntialias(antialias: Antialias): void;
|
|
224
|
-
getAntialias(): Antialias;
|
|
225
|
-
|
|
226
|
-
showPage(): void;
|
|
227
|
-
copyPage(): void;
|
|
228
|
-
getTarget(): Surface;
|
|
229
|
-
setSourceSurface(surface: Surface, x: number, y: number): void;
|
|
230
|
-
hasCurrentPoint(): boolean;
|
|
231
|
-
getCurrentPoint(): { x: number; y: number } | null;
|
|
232
|
-
getSource(): Pattern;
|
|
233
|
-
|
|
234
|
-
strokeExtents(): { x1: number; y1: number; x2: number; y2: number };
|
|
235
|
-
fillExtents(): { x1: number; y1: number; x2: number; y2: number };
|
|
236
|
-
clipExtents(): { x1: number; y1: number; x2: number; y2: number };
|
|
237
|
-
pathExtents(): { x1: number; y1: number; x2: number; y2: number };
|
|
238
|
-
inStroke(x: number, y: number): boolean;
|
|
239
|
-
inFill(x: number, y: number): boolean;
|
|
240
|
-
inClip(x: number, y: number): boolean;
|
|
241
|
-
copyClipRectangleList(): Array<{ x: number; y: number; width: number; height: number }>;
|
|
242
|
-
|
|
243
|
-
mask(pattern: Pattern): void;
|
|
244
|
-
maskSurface(surface: Surface, x: number, y: number): void;
|
|
245
|
-
|
|
246
|
-
setMatrix(matrix: CairoMatrix): void;
|
|
247
|
-
getMatrix(): CairoMatrix;
|
|
248
|
-
transform(matrix: CairoMatrix): void;
|
|
249
|
-
identityMatrix(): void;
|
|
250
|
-
userToDevice(x: number, y: number): { x: number; y: number };
|
|
251
|
-
userToDeviceDistance(dx: number, dy: number): { dx: number; dy: number };
|
|
252
|
-
deviceToUser(x: number, y: number): { x: number; y: number };
|
|
253
|
-
deviceToUserDistance(dx: number, dy: number): { dx: number; dy: number };
|
|
254
|
-
|
|
255
|
-
status(): Status;
|
|
256
|
-
getReferenceCount(): number;
|
|
257
|
-
}
|
|
258
|
-
}
|
|
259
|
-
|
|
260
|
-
const cairoMoveTo = bind("libcairo.so.2", "cairo_move_to", [CONTEXT_T, t.float64, t.float64], t.void);
|
|
261
|
-
Context.prototype.moveTo = function (x: number, y: number): void {
|
|
262
|
-
cairoMoveTo(getHandle(this), x, y);
|
|
263
|
-
};
|
|
264
|
-
|
|
265
|
-
const cairoLineTo = bind("libcairo.so.2", "cairo_line_to", [CONTEXT_T, t.float64, t.float64], t.void);
|
|
266
|
-
Context.prototype.lineTo = function (x: number, y: number): void {
|
|
267
|
-
cairoLineTo(getHandle(this), x, y);
|
|
268
|
-
};
|
|
269
|
-
|
|
270
|
-
const cairoRelMoveTo = bind("libcairo.so.2", "cairo_rel_move_to", [CONTEXT_T, t.float64, t.float64], t.void);
|
|
271
|
-
Context.prototype.relMoveTo = function (dx: number, dy: number): void {
|
|
272
|
-
cairoRelMoveTo(getHandle(this), dx, dy);
|
|
273
|
-
};
|
|
274
|
-
|
|
275
|
-
const cairoRelLineTo = bind("libcairo.so.2", "cairo_rel_line_to", [CONTEXT_T, t.float64, t.float64], t.void);
|
|
276
|
-
Context.prototype.relLineTo = function (dx: number, dy: number): void {
|
|
277
|
-
cairoRelLineTo(getHandle(this), dx, dy);
|
|
278
|
-
};
|
|
279
|
-
|
|
280
|
-
const cairoRelCurveTo = bind(
|
|
281
|
-
"libcairo.so.2",
|
|
282
|
-
"cairo_rel_curve_to",
|
|
283
|
-
[CONTEXT_T, t.float64, t.float64, t.float64, t.float64, t.float64, t.float64],
|
|
284
|
-
t.void,
|
|
285
|
-
);
|
|
286
|
-
Context.prototype.relCurveTo = function (
|
|
287
|
-
dx1: number,
|
|
288
|
-
dy1: number,
|
|
289
|
-
dx2: number,
|
|
290
|
-
dy2: number,
|
|
291
|
-
dx3: number,
|
|
292
|
-
dy3: number,
|
|
293
|
-
): void {
|
|
294
|
-
cairoRelCurveTo(getHandle(this), dx1, dy1, dx2, dy2, dx3, dy3);
|
|
295
|
-
};
|
|
296
|
-
|
|
297
|
-
const cairoCurveTo = bind(
|
|
298
|
-
"libcairo.so.2",
|
|
299
|
-
"cairo_curve_to",
|
|
300
|
-
[CONTEXT_T, t.float64, t.float64, t.float64, t.float64, t.float64, t.float64],
|
|
301
|
-
t.void,
|
|
302
|
-
);
|
|
303
|
-
Context.prototype.curveTo = function (x1: number, y1: number, x2: number, y2: number, x3: number, y3: number): void {
|
|
304
|
-
cairoCurveTo(getHandle(this), x1, y1, x2, y2, x3, y3);
|
|
305
|
-
};
|
|
306
|
-
|
|
307
|
-
const cairoArc = bind(
|
|
308
|
-
"libcairo.so.2",
|
|
309
|
-
"cairo_arc",
|
|
310
|
-
[CONTEXT_T, t.float64, t.float64, t.float64, t.float64, t.float64],
|
|
311
|
-
t.void,
|
|
312
|
-
);
|
|
313
|
-
Context.prototype.arc = function (xc: number, yc: number, radius: number, angle1: number, angle2: number): void {
|
|
314
|
-
cairoArc(getHandle(this), xc, yc, radius, angle1, angle2);
|
|
315
|
-
};
|
|
316
|
-
|
|
317
|
-
const cairoArcNegative = bind(
|
|
318
|
-
"libcairo.so.2",
|
|
319
|
-
"cairo_arc_negative",
|
|
320
|
-
[CONTEXT_T, t.float64, t.float64, t.float64, t.float64, t.float64],
|
|
321
|
-
t.void,
|
|
322
|
-
);
|
|
323
|
-
Context.prototype.arcNegative = function (
|
|
324
|
-
xc: number,
|
|
325
|
-
yc: number,
|
|
326
|
-
radius: number,
|
|
327
|
-
angle1: number,
|
|
328
|
-
angle2: number,
|
|
329
|
-
): void {
|
|
330
|
-
cairoArcNegative(getHandle(this), xc, yc, radius, angle1, angle2);
|
|
331
|
-
};
|
|
332
|
-
|
|
333
|
-
const cairoRectangle = bind(
|
|
334
|
-
"libcairo.so.2",
|
|
335
|
-
"cairo_rectangle",
|
|
336
|
-
[CONTEXT_T, t.float64, t.float64, t.float64, t.float64],
|
|
337
|
-
t.void,
|
|
338
|
-
);
|
|
339
|
-
Context.prototype.rectangle = function (x: number, y: number, width: number, height: number): void {
|
|
340
|
-
cairoRectangle(getHandle(this), x, y, width, height);
|
|
341
|
-
};
|
|
342
|
-
|
|
343
|
-
const cairoClosePath = bind("libcairo.so.2", "cairo_close_path", [CONTEXT_T], t.void);
|
|
344
|
-
Context.prototype.closePath = function (): void {
|
|
345
|
-
cairoClosePath(getHandle(this));
|
|
346
|
-
};
|
|
347
|
-
|
|
348
|
-
const cairoNewPath = bind("libcairo.so.2", "cairo_new_path", [CONTEXT_T], t.void);
|
|
349
|
-
Context.prototype.newPath = function (): void {
|
|
350
|
-
cairoNewPath(getHandle(this));
|
|
351
|
-
};
|
|
352
|
-
|
|
353
|
-
const cairoNewSubPath = bind("libcairo.so.2", "cairo_new_sub_path", [CONTEXT_T], t.void);
|
|
354
|
-
Context.prototype.newSubPath = function (): void {
|
|
355
|
-
cairoNewSubPath(getHandle(this));
|
|
356
|
-
};
|
|
357
|
-
|
|
358
|
-
const cairoStroke = bind("libcairo.so.2", "cairo_stroke", [CONTEXT_T], t.void);
|
|
359
|
-
Context.prototype.stroke = function (): void {
|
|
360
|
-
cairoStroke(getHandle(this));
|
|
361
|
-
};
|
|
362
|
-
|
|
363
|
-
const cairoStrokePreserve = bind("libcairo.so.2", "cairo_stroke_preserve", [CONTEXT_T], t.void);
|
|
364
|
-
Context.prototype.strokePreserve = function (): void {
|
|
365
|
-
cairoStrokePreserve(getHandle(this));
|
|
366
|
-
};
|
|
367
|
-
|
|
368
|
-
const cairoFill = bind("libcairo.so.2", "cairo_fill", [CONTEXT_T], t.void);
|
|
369
|
-
Context.prototype.fill = function (): void {
|
|
370
|
-
cairoFill(getHandle(this));
|
|
371
|
-
};
|
|
372
|
-
|
|
373
|
-
const cairoFillPreserve = bind("libcairo.so.2", "cairo_fill_preserve", [CONTEXT_T], t.void);
|
|
374
|
-
Context.prototype.fillPreserve = function (): void {
|
|
375
|
-
cairoFillPreserve(getHandle(this));
|
|
376
|
-
};
|
|
377
|
-
|
|
378
|
-
const cairoPaint = bind("libcairo.so.2", "cairo_paint", [CONTEXT_T], t.void);
|
|
379
|
-
Context.prototype.paint = function (): void {
|
|
380
|
-
cairoPaint(getHandle(this));
|
|
381
|
-
};
|
|
382
|
-
|
|
383
|
-
const cairoPaintWithAlpha = bind("libcairo.so.2", "cairo_paint_with_alpha", [CONTEXT_T, t.float64], t.void);
|
|
384
|
-
Context.prototype.paintWithAlpha = function (alpha: number): void {
|
|
385
|
-
cairoPaintWithAlpha(getHandle(this), alpha);
|
|
386
|
-
};
|
|
387
|
-
|
|
388
|
-
const cairoClip = bind("libcairo.so.2", "cairo_clip", [CONTEXT_T], t.void);
|
|
389
|
-
Context.prototype.clip = function (): void {
|
|
390
|
-
cairoClip(getHandle(this));
|
|
391
|
-
};
|
|
392
|
-
|
|
393
|
-
const cairoClipPreserve = bind("libcairo.so.2", "cairo_clip_preserve", [CONTEXT_T], t.void);
|
|
394
|
-
Context.prototype.clipPreserve = function (): void {
|
|
395
|
-
cairoClipPreserve(getHandle(this));
|
|
396
|
-
};
|
|
397
|
-
|
|
398
|
-
const cairoResetClip = bind("libcairo.so.2", "cairo_reset_clip", [CONTEXT_T], t.void);
|
|
399
|
-
Context.prototype.resetClip = function (): void {
|
|
400
|
-
cairoResetClip(getHandle(this));
|
|
401
|
-
};
|
|
402
|
-
|
|
403
|
-
const cairoSetSourceRgb = bind(
|
|
404
|
-
"libcairo.so.2",
|
|
405
|
-
"cairo_set_source_rgb",
|
|
406
|
-
[CONTEXT_T, t.float64, t.float64, t.float64],
|
|
407
|
-
t.void,
|
|
408
|
-
);
|
|
409
|
-
Context.prototype.setSourceRgb = function (red: number, green: number, blue: number): void {
|
|
410
|
-
cairoSetSourceRgb(getHandle(this), red, green, blue);
|
|
411
|
-
};
|
|
412
|
-
|
|
413
|
-
const cairoSetSourceRgba = bind(
|
|
414
|
-
"libcairo.so.2",
|
|
415
|
-
"cairo_set_source_rgba",
|
|
416
|
-
[CONTEXT_T, t.float64, t.float64, t.float64, t.float64],
|
|
417
|
-
t.void,
|
|
418
|
-
);
|
|
419
|
-
Context.prototype.setSourceRgba = function (red: number, green: number, blue: number, alpha: number): void {
|
|
420
|
-
cairoSetSourceRgba(getHandle(this), red, green, blue, alpha);
|
|
421
|
-
};
|
|
422
|
-
|
|
423
|
-
const cairoSetSource = bind(
|
|
424
|
-
"libcairo.so.2",
|
|
425
|
-
"cairo_set_source",
|
|
426
|
-
[
|
|
427
|
-
CONTEXT_T,
|
|
428
|
-
t.boxed("CairoPattern", {
|
|
429
|
-
ownership: "borrowed",
|
|
430
|
-
sharedLibrary: "libcairo-gobject.so.2",
|
|
431
|
-
getTypeFnName: "cairo_gobject_pattern_get_type",
|
|
432
|
-
}),
|
|
433
|
-
],
|
|
434
|
-
t.void,
|
|
435
|
-
);
|
|
436
|
-
Context.prototype.setSource = function (pattern: Pattern): void {
|
|
437
|
-
cairoSetSource(getHandle(this), getHandle(pattern));
|
|
438
|
-
};
|
|
439
|
-
|
|
440
|
-
const cairoSetLineWidth = bind("libcairo.so.2", "cairo_set_line_width", [CONTEXT_T, t.float64], t.void);
|
|
441
|
-
Context.prototype.setLineWidth = function (width: number): void {
|
|
442
|
-
cairoSetLineWidth(getHandle(this), width);
|
|
443
|
-
};
|
|
444
|
-
|
|
445
|
-
const cairoGetLineWidth = bind("libcairo.so.2", "cairo_get_line_width", [CONTEXT_T], t.float64);
|
|
446
|
-
Context.prototype.getLineWidth = function (): number {
|
|
447
|
-
return cairoGetLineWidth(getHandle(this)) as number;
|
|
448
|
-
};
|
|
449
|
-
|
|
450
|
-
const cairoSetLineCap = bind("libcairo.so.2", "cairo_set_line_cap", [CONTEXT_T, t.int32], t.void);
|
|
451
|
-
Context.prototype.setLineCap = function (lineCap: LineCap): void {
|
|
452
|
-
cairoSetLineCap(getHandle(this), lineCap);
|
|
453
|
-
};
|
|
454
|
-
|
|
455
|
-
const cairoGetLineCap = bind("libcairo.so.2", "cairo_get_line_cap", [CONTEXT_T], t.int32);
|
|
456
|
-
Context.prototype.getLineCap = function (): LineCap {
|
|
457
|
-
return cairoGetLineCap(getHandle(this)) as LineCap;
|
|
458
|
-
};
|
|
459
|
-
|
|
460
|
-
const cairoSetLineJoin = bind("libcairo.so.2", "cairo_set_line_join", [CONTEXT_T, t.int32], t.void);
|
|
461
|
-
Context.prototype.setLineJoin = function (lineJoin: LineJoin): void {
|
|
462
|
-
cairoSetLineJoin(getHandle(this), lineJoin);
|
|
463
|
-
};
|
|
464
|
-
|
|
465
|
-
const cairoGetLineJoin = bind("libcairo.so.2", "cairo_get_line_join", [CONTEXT_T], t.int32);
|
|
466
|
-
Context.prototype.getLineJoin = function (): LineJoin {
|
|
467
|
-
return cairoGetLineJoin(getHandle(this)) as LineJoin;
|
|
468
|
-
};
|
|
469
|
-
|
|
470
|
-
const DOUBLE_BUFFER_T = t.boxed("double[]", { ownership: "borrowed", sharedLibrary: "libcairo.so.2" });
|
|
471
|
-
|
|
472
|
-
const cairoSetDash = bind("libcairo.so.2", "cairo_set_dash", [CONTEXT_T, DOUBLE_BUFFER_T, t.int32, t.float64], t.void);
|
|
473
|
-
Context.prototype.setDash = function (dashes: number[], offset: number): void {
|
|
474
|
-
const dashBuf = alloc(dashes.length * 8);
|
|
475
|
-
for (let i = 0; i < dashes.length; i++) {
|
|
476
|
-
write(dashBuf, t.float64, i * 8, dashes[i]);
|
|
477
|
-
}
|
|
478
|
-
cairoSetDash(getHandle(this), dashBuf, dashes.length, offset);
|
|
479
|
-
};
|
|
480
|
-
|
|
481
|
-
const cairoGetDashCount = bind("libcairo.so.2", "cairo_get_dash_count", [CONTEXT_T], t.int32);
|
|
482
|
-
Context.prototype.getDashCount = function (): number {
|
|
483
|
-
return cairoGetDashCount(getHandle(this)) as number;
|
|
484
|
-
};
|
|
485
|
-
|
|
486
|
-
const cairoGetDash = bind("libcairo.so.2", "cairo_get_dash", [CONTEXT_T, DOUBLE_BUFFER_T, t.ref(t.float64)], t.void);
|
|
487
|
-
Context.prototype.getDash = function (): { dashes: number[]; offset: number } {
|
|
488
|
-
const count = this.getDashCount();
|
|
489
|
-
if (count === 0) {
|
|
490
|
-
return { dashes: [], offset: 0 };
|
|
491
|
-
}
|
|
492
|
-
const dashBuf = alloc(count * 8);
|
|
493
|
-
const offsetRef = { value: 0 };
|
|
494
|
-
cairoGetDash(getHandle(this), dashBuf, offsetRef);
|
|
495
|
-
const dashes: number[] = [];
|
|
496
|
-
for (let i = 0; i < count; i++) {
|
|
497
|
-
dashes.push(read(dashBuf, t.float64, i * 8) as number);
|
|
498
|
-
}
|
|
499
|
-
return { dashes, offset: offsetRef.value };
|
|
500
|
-
};
|
|
501
|
-
|
|
502
|
-
const cairoSetMiterLimit = bind("libcairo.so.2", "cairo_set_miter_limit", [CONTEXT_T, t.float64], t.void);
|
|
503
|
-
Context.prototype.setMiterLimit = function (limit: number): void {
|
|
504
|
-
cairoSetMiterLimit(getHandle(this), limit);
|
|
505
|
-
};
|
|
506
|
-
|
|
507
|
-
const cairoGetMiterLimit = bind("libcairo.so.2", "cairo_get_miter_limit", [CONTEXT_T], t.float64);
|
|
508
|
-
Context.prototype.getMiterLimit = function (): number {
|
|
509
|
-
return cairoGetMiterLimit(getHandle(this)) as number;
|
|
510
|
-
};
|
|
511
|
-
|
|
512
|
-
const cairoSetTolerance = bind("libcairo.so.2", "cairo_set_tolerance", [CONTEXT_T, t.float64], t.void);
|
|
513
|
-
Context.prototype.setTolerance = function (tolerance: number): void {
|
|
514
|
-
cairoSetTolerance(getHandle(this), tolerance);
|
|
515
|
-
};
|
|
516
|
-
|
|
517
|
-
const cairoGetTolerance = bind("libcairo.so.2", "cairo_get_tolerance", [CONTEXT_T], t.float64);
|
|
518
|
-
Context.prototype.getTolerance = function (): number {
|
|
519
|
-
return cairoGetTolerance(getHandle(this)) as number;
|
|
520
|
-
};
|
|
521
|
-
|
|
522
|
-
const cairoSetFillRule = bind("libcairo.so.2", "cairo_set_fill_rule", [CONTEXT_T, t.int32], t.void);
|
|
523
|
-
Context.prototype.setFillRule = function (fillRule: FillRule): void {
|
|
524
|
-
cairoSetFillRule(getHandle(this), fillRule);
|
|
525
|
-
};
|
|
526
|
-
|
|
527
|
-
const cairoGetFillRule = bind("libcairo.so.2", "cairo_get_fill_rule", [CONTEXT_T], t.int32);
|
|
528
|
-
Context.prototype.getFillRule = function (): FillRule {
|
|
529
|
-
return cairoGetFillRule(getHandle(this)) as FillRule;
|
|
530
|
-
};
|
|
531
|
-
|
|
532
|
-
const cairoSave = bind("libcairo.so.2", "cairo_save", [CONTEXT_T], t.void);
|
|
533
|
-
Context.prototype.save = function (): void {
|
|
534
|
-
cairoSave(getHandle(this));
|
|
535
|
-
};
|
|
536
|
-
|
|
537
|
-
const cairoRestore = bind("libcairo.so.2", "cairo_restore", [CONTEXT_T], t.void);
|
|
538
|
-
Context.prototype.restore = function (): void {
|
|
539
|
-
cairoRestore(getHandle(this));
|
|
540
|
-
};
|
|
541
|
-
|
|
542
|
-
const cairoTranslate = bind("libcairo.so.2", "cairo_translate", [CONTEXT_T, t.float64, t.float64], t.void);
|
|
543
|
-
Context.prototype.translate = function (tx: number, ty: number): void {
|
|
544
|
-
cairoTranslate(getHandle(this), tx, ty);
|
|
545
|
-
};
|
|
546
|
-
|
|
547
|
-
const cairoScale = bind("libcairo.so.2", "cairo_scale", [CONTEXT_T, t.float64, t.float64], t.void);
|
|
548
|
-
Context.prototype.scale = function (sx: number, sy: number): void {
|
|
549
|
-
cairoScale(getHandle(this), sx, sy);
|
|
550
|
-
};
|
|
551
|
-
|
|
552
|
-
const cairoRotate = bind("libcairo.so.2", "cairo_rotate", [CONTEXT_T, t.float64], t.void);
|
|
553
|
-
Context.prototype.rotate = function (angle: number): void {
|
|
554
|
-
cairoRotate(getHandle(this), angle);
|
|
555
|
-
};
|
|
556
|
-
|
|
557
|
-
const cairoSetOperator = bind("libcairo.so.2", "cairo_set_operator", [CONTEXT_T, t.int32], t.void);
|
|
558
|
-
Context.prototype.setOperator = function (op: Operator): void {
|
|
559
|
-
cairoSetOperator(getHandle(this), op);
|
|
560
|
-
};
|
|
561
|
-
|
|
562
|
-
const cairoGetOperator = bind("libcairo.so.2", "cairo_get_operator", [CONTEXT_T], t.int32);
|
|
563
|
-
Context.prototype.getOperator = function (): Operator {
|
|
564
|
-
return cairoGetOperator(getHandle(this)) as Operator;
|
|
565
|
-
};
|
|
566
|
-
|
|
567
|
-
const cairoSelectFontFace = bind(
|
|
568
|
-
"libcairo.so.2",
|
|
569
|
-
"cairo_select_font_face",
|
|
570
|
-
[CONTEXT_T, t.string("full"), t.int32, t.int32],
|
|
571
|
-
t.void,
|
|
572
|
-
);
|
|
573
|
-
Context.prototype.selectFontFace = function (family: string, slant: FontSlant, weight: FontWeight): void {
|
|
574
|
-
cairoSelectFontFace(getHandle(this), family, slant, weight);
|
|
575
|
-
};
|
|
576
|
-
|
|
577
|
-
const cairoSetFontSize = bind("libcairo.so.2", "cairo_set_font_size", [CONTEXT_T, t.float64], t.void);
|
|
578
|
-
Context.prototype.setFontSize = function (size: number): void {
|
|
579
|
-
cairoSetFontSize(getHandle(this), size);
|
|
580
|
-
};
|
|
581
|
-
|
|
582
|
-
const cairoShowText = bind("libcairo.so.2", "cairo_show_text", [CONTEXT_T, t.string("full")], t.void);
|
|
583
|
-
Context.prototype.showText = function (text: string): void {
|
|
584
|
-
cairoShowText(getHandle(this), text);
|
|
585
|
-
};
|
|
586
|
-
|
|
587
|
-
const cairoTextPath = bind("libcairo.so.2", "cairo_text_path", [CONTEXT_T, t.string("full")], t.void);
|
|
588
|
-
Context.prototype.textPath = function (text: string): void {
|
|
589
|
-
cairoTextPath(getHandle(this), text);
|
|
590
|
-
};
|
|
591
|
-
|
|
592
|
-
const cairoTextExtents = bind(
|
|
593
|
-
"libcairo.so.2",
|
|
594
|
-
"cairo_text_extents",
|
|
595
|
-
[
|
|
596
|
-
CONTEXT_T,
|
|
597
|
-
t.string("full"),
|
|
598
|
-
t.boxed("cairo_text_extents_t", { ownership: "borrowed", sharedLibrary: "libcairo.so.2" }),
|
|
599
|
-
],
|
|
600
|
-
t.void,
|
|
601
|
-
);
|
|
602
|
-
Context.prototype.textExtents = function (text: string): TextExtents {
|
|
603
|
-
const extents = alloc(48);
|
|
604
|
-
cairoTextExtents(getHandle(this), text, extents);
|
|
605
|
-
return readTextExtents(extents);
|
|
606
|
-
};
|
|
607
|
-
|
|
608
|
-
const cairoFontExtents = bind(
|
|
609
|
-
"libcairo.so.2",
|
|
610
|
-
"cairo_font_extents",
|
|
611
|
-
[CONTEXT_T, t.boxed("cairo_font_extents_t", { ownership: "borrowed", sharedLibrary: "libcairo.so.2" })],
|
|
612
|
-
t.void,
|
|
613
|
-
);
|
|
614
|
-
Context.prototype.fontExtents = function (): FontExtents {
|
|
615
|
-
const extents = alloc(40);
|
|
616
|
-
cairoFontExtents(getHandle(this), extents);
|
|
617
|
-
return readFontExtents(extents);
|
|
618
|
-
};
|
|
619
|
-
|
|
620
|
-
const cairoSetFontOptions = bind(
|
|
621
|
-
"libcairo.so.2",
|
|
622
|
-
"cairo_set_font_options",
|
|
623
|
-
[
|
|
624
|
-
CONTEXT_T,
|
|
625
|
-
t.boxed("CairoFontOptions", {
|
|
626
|
-
ownership: "borrowed",
|
|
627
|
-
sharedLibrary: "libcairo-gobject.so.2",
|
|
628
|
-
getTypeFnName: "cairo_gobject_font_options_get_type",
|
|
629
|
-
}),
|
|
630
|
-
],
|
|
631
|
-
t.void,
|
|
632
|
-
);
|
|
633
|
-
Context.prototype.setFontOptions = function (options: FontOptions): void {
|
|
634
|
-
cairoSetFontOptions(getHandle(this), getHandle(options));
|
|
635
|
-
};
|
|
636
|
-
|
|
637
|
-
const cairoGetFontOptions = bind(
|
|
638
|
-
"libcairo.so.2",
|
|
639
|
-
"cairo_get_font_options",
|
|
640
|
-
[
|
|
641
|
-
CONTEXT_T,
|
|
642
|
-
t.boxed("CairoFontOptions", {
|
|
643
|
-
ownership: "borrowed",
|
|
644
|
-
sharedLibrary: "libcairo-gobject.so.2",
|
|
645
|
-
getTypeFnName: "cairo_gobject_font_options_get_type",
|
|
646
|
-
}),
|
|
647
|
-
],
|
|
648
|
-
t.void,
|
|
649
|
-
);
|
|
650
|
-
Context.prototype.getFontOptions = function (): FontOptions {
|
|
651
|
-
const options = FontOptionsConstructor.create();
|
|
652
|
-
cairoGetFontOptions(getHandle(this), getHandle(options));
|
|
653
|
-
return options;
|
|
654
|
-
};
|
|
655
|
-
|
|
656
|
-
const cairoSetAntialias = bind("libcairo.so.2", "cairo_set_antialias", [CONTEXT_T, t.int32], t.void);
|
|
657
|
-
Context.prototype.setAntialias = function (antialias: Antialias): void {
|
|
658
|
-
cairoSetAntialias(getHandle(this), antialias);
|
|
659
|
-
};
|
|
660
|
-
|
|
661
|
-
const cairoGetAntialias = bind("libcairo.so.2", "cairo_get_antialias", [CONTEXT_T], t.int32);
|
|
662
|
-
Context.prototype.getAntialias = function (): Antialias {
|
|
663
|
-
return cairoGetAntialias(getHandle(this)) as Antialias;
|
|
664
|
-
};
|
|
665
|
-
|
|
666
|
-
const cairoShowPage = bind("libcairo.so.2", "cairo_show_page", [CONTEXT_T], t.void);
|
|
667
|
-
Context.prototype.showPage = function (): void {
|
|
668
|
-
cairoShowPage(getHandle(this));
|
|
669
|
-
};
|
|
670
|
-
|
|
671
|
-
const cairoCopyPage = bind("libcairo.so.2", "cairo_copy_page", [CONTEXT_T], t.void);
|
|
672
|
-
Context.prototype.copyPage = function (): void {
|
|
673
|
-
cairoCopyPage(getHandle(this));
|
|
674
|
-
};
|
|
675
|
-
|
|
676
|
-
const cairoGetTarget = bind(
|
|
677
|
-
"libcairo.so.2",
|
|
678
|
-
"cairo_get_target",
|
|
679
|
-
[CONTEXT_T],
|
|
680
|
-
t.boxed("CairoSurface", {
|
|
681
|
-
ownership: "borrowed",
|
|
682
|
-
sharedLibrary: "libcairo-gobject.so.2",
|
|
683
|
-
getTypeFnName: "cairo_gobject_surface_get_type",
|
|
684
|
-
}),
|
|
685
|
-
);
|
|
686
|
-
Context.prototype.getTarget = function (): Surface {
|
|
687
|
-
return wrapHandle(cairoGetTarget(getHandle(this)) as ExternalObject<Handle>, Surface) as Surface;
|
|
688
|
-
};
|
|
689
|
-
|
|
690
|
-
const cairoSetSourceSurface = bind(
|
|
691
|
-
"libcairo.so.2",
|
|
692
|
-
"cairo_set_source_surface",
|
|
693
|
-
[
|
|
694
|
-
CONTEXT_T,
|
|
695
|
-
t.boxed("CairoSurface", {
|
|
696
|
-
ownership: "borrowed",
|
|
697
|
-
sharedLibrary: "libcairo-gobject.so.2",
|
|
698
|
-
getTypeFnName: "cairo_gobject_surface_get_type",
|
|
699
|
-
}),
|
|
700
|
-
t.float64,
|
|
701
|
-
t.float64,
|
|
702
|
-
],
|
|
703
|
-
t.void,
|
|
704
|
-
);
|
|
705
|
-
Context.prototype.setSourceSurface = function (surface: Surface, x: number, y: number): void {
|
|
706
|
-
cairoSetSourceSurface(getHandle(this), getHandle(surface), x, y);
|
|
707
|
-
};
|
|
708
|
-
|
|
709
|
-
const cairoHasCurrentPoint = bind("libcairo.so.2", "cairo_has_current_point", [CONTEXT_T], t.boolean);
|
|
710
|
-
Context.prototype.hasCurrentPoint = function (): boolean {
|
|
711
|
-
return cairoHasCurrentPoint(getHandle(this)) as boolean;
|
|
712
|
-
};
|
|
713
|
-
|
|
714
|
-
const cairoGetCurrentPoint = bind(
|
|
715
|
-
"libcairo.so.2",
|
|
716
|
-
"cairo_get_current_point",
|
|
717
|
-
[CONTEXT_T, t.ref(t.float64), t.ref(t.float64)],
|
|
718
|
-
t.void,
|
|
719
|
-
);
|
|
720
|
-
Context.prototype.getCurrentPoint = function (): { x: number; y: number } | null {
|
|
721
|
-
if (!this.hasCurrentPoint()) {
|
|
722
|
-
return null;
|
|
723
|
-
}
|
|
724
|
-
const xRef = { value: 0 };
|
|
725
|
-
const yRef = { value: 0 };
|
|
726
|
-
cairoGetCurrentPoint(getHandle(this), xRef, yRef);
|
|
727
|
-
return { x: xRef.value, y: yRef.value };
|
|
728
|
-
};
|
|
729
|
-
|
|
730
|
-
const cairoGetSource = bind(
|
|
731
|
-
"libcairo.so.2",
|
|
732
|
-
"cairo_get_source",
|
|
733
|
-
[CONTEXT_T],
|
|
734
|
-
t.boxed("CairoPattern", {
|
|
735
|
-
ownership: "borrowed",
|
|
736
|
-
sharedLibrary: "libcairo-gobject.so.2",
|
|
737
|
-
getTypeFnName: "cairo_gobject_pattern_get_type",
|
|
738
|
-
}),
|
|
739
|
-
);
|
|
740
|
-
Context.prototype.getSource = function (): Pattern {
|
|
741
|
-
return wrapHandle(cairoGetSource(getHandle(this)) as ExternalObject<Handle>, Pattern) as Pattern;
|
|
742
|
-
};
|
|
743
|
-
|
|
744
|
-
const EXTENTS_ARGS = [CONTEXT_T, t.ref(t.float64), t.ref(t.float64), t.ref(t.float64), t.ref(t.float64)];
|
|
745
|
-
const cairoStrokeExtents = bind("libcairo.so.2", "cairo_stroke_extents", EXTENTS_ARGS, t.void);
|
|
746
|
-
const cairoFillExtents = bind("libcairo.so.2", "cairo_fill_extents", EXTENTS_ARGS, t.void);
|
|
747
|
-
const cairoClipExtents = bind("libcairo.so.2", "cairo_clip_extents", EXTENTS_ARGS, t.void);
|
|
748
|
-
const cairoPathExtents = bind("libcairo.so.2", "cairo_path_extents", EXTENTS_ARGS, t.void);
|
|
749
|
-
|
|
750
|
-
const getExtents = (
|
|
751
|
-
ctx: Context,
|
|
752
|
-
boundFn: (...args: unknown[]) => unknown,
|
|
753
|
-
): { x1: number; y1: number; x2: number; y2: number } => {
|
|
754
|
-
const x1Ref = { value: 0 };
|
|
755
|
-
const y1Ref = { value: 0 };
|
|
756
|
-
const x2Ref = { value: 0 };
|
|
757
|
-
const y2Ref = { value: 0 };
|
|
758
|
-
boundFn(getHandle(ctx), x1Ref, y1Ref, x2Ref, y2Ref);
|
|
759
|
-
return { x1: x1Ref.value, y1: y1Ref.value, x2: x2Ref.value, y2: y2Ref.value };
|
|
760
|
-
};
|
|
761
|
-
|
|
762
|
-
Context.prototype.strokeExtents = function (): { x1: number; y1: number; x2: number; y2: number } {
|
|
763
|
-
return getExtents(this, cairoStrokeExtents);
|
|
764
|
-
};
|
|
765
|
-
|
|
766
|
-
Context.prototype.fillExtents = function (): { x1: number; y1: number; x2: number; y2: number } {
|
|
767
|
-
return getExtents(this, cairoFillExtents);
|
|
768
|
-
};
|
|
769
|
-
|
|
770
|
-
Context.prototype.clipExtents = function (): { x1: number; y1: number; x2: number; y2: number } {
|
|
771
|
-
return getExtents(this, cairoClipExtents);
|
|
772
|
-
};
|
|
773
|
-
|
|
774
|
-
Context.prototype.pathExtents = function (): { x1: number; y1: number; x2: number; y2: number } {
|
|
775
|
-
return getExtents(this, cairoPathExtents);
|
|
776
|
-
};
|
|
777
|
-
|
|
778
|
-
const cairoInStroke = bind("libcairo.so.2", "cairo_in_stroke", [CONTEXT_T, t.float64, t.float64], t.boolean);
|
|
779
|
-
Context.prototype.inStroke = function (x: number, y: number): boolean {
|
|
780
|
-
return cairoInStroke(getHandle(this), x, y) as boolean;
|
|
781
|
-
};
|
|
782
|
-
|
|
783
|
-
const cairoInFill = bind("libcairo.so.2", "cairo_in_fill", [CONTEXT_T, t.float64, t.float64], t.boolean);
|
|
784
|
-
Context.prototype.inFill = function (x: number, y: number): boolean {
|
|
785
|
-
return cairoInFill(getHandle(this), x, y) as boolean;
|
|
786
|
-
};
|
|
787
|
-
|
|
788
|
-
const cairoInClip = bind("libcairo.so.2", "cairo_in_clip", [CONTEXT_T, t.float64, t.float64], t.boolean);
|
|
789
|
-
Context.prototype.inClip = function (x: number, y: number): boolean {
|
|
790
|
-
return cairoInClip(getHandle(this), x, y) as boolean;
|
|
791
|
-
};
|
|
792
|
-
|
|
793
|
-
const cairoCopyClipRectangleList = bind(
|
|
794
|
-
"libcairo.so.2",
|
|
795
|
-
"cairo_copy_clip_rectangle_list",
|
|
796
|
-
[CONTEXT_T],
|
|
797
|
-
t.boxed("cairo_rectangle_list_t", { ownership: "borrowed", sharedLibrary: "libcairo.so.2" }),
|
|
798
|
-
);
|
|
799
|
-
const cairoRectangleListDestroy = bind(
|
|
800
|
-
"libcairo.so.2",
|
|
801
|
-
"cairo_rectangle_list_destroy",
|
|
802
|
-
[t.boxed("cairo_rectangle_list_t", { ownership: "borrowed", sharedLibrary: "libcairo.so.2" })],
|
|
803
|
-
t.void,
|
|
804
|
-
);
|
|
805
|
-
|
|
806
|
-
Context.prototype.copyClipRectangleList = function (): Array<{
|
|
807
|
-
x: number;
|
|
808
|
-
y: number;
|
|
809
|
-
width: number;
|
|
810
|
-
height: number;
|
|
811
|
-
}> {
|
|
812
|
-
const listHandle = cairoCopyClipRectangleList(getHandle(this)) as ExternalObject<Handle>;
|
|
813
|
-
|
|
814
|
-
const numRectangles = read(listHandle, t.int32, 16) as number;
|
|
815
|
-
if (numRectangles === 0) {
|
|
816
|
-
cairoRectangleListDestroy(listHandle);
|
|
817
|
-
return [];
|
|
818
|
-
}
|
|
819
|
-
const rectsArray = read(listHandle, t.struct("full", { size: numRectangles * 32 }), 8) as ExternalObject<Handle>;
|
|
820
|
-
const result: Array<{ x: number; y: number; width: number; height: number }> = [];
|
|
821
|
-
|
|
822
|
-
for (let i = 0; i < numRectangles; i++) {
|
|
823
|
-
const base = i * 32;
|
|
824
|
-
result.push({
|
|
825
|
-
x: read(rectsArray, t.float64, base) as number,
|
|
826
|
-
y: read(rectsArray, t.float64, base + 8) as number,
|
|
827
|
-
width: read(rectsArray, t.float64, base + 16) as number,
|
|
828
|
-
height: read(rectsArray, t.float64, base + 24) as number,
|
|
829
|
-
});
|
|
830
|
-
}
|
|
831
|
-
|
|
832
|
-
cairoRectangleListDestroy(listHandle);
|
|
833
|
-
|
|
834
|
-
return result;
|
|
835
|
-
};
|
|
836
|
-
|
|
837
|
-
const cairoMask = bind(
|
|
838
|
-
"libcairo.so.2",
|
|
839
|
-
"cairo_mask",
|
|
840
|
-
[
|
|
841
|
-
CONTEXT_T,
|
|
842
|
-
t.boxed("CairoPattern", {
|
|
843
|
-
ownership: "borrowed",
|
|
844
|
-
sharedLibrary: "libcairo-gobject.so.2",
|
|
845
|
-
getTypeFnName: "cairo_gobject_pattern_get_type",
|
|
846
|
-
}),
|
|
847
|
-
],
|
|
848
|
-
t.void,
|
|
849
|
-
);
|
|
850
|
-
Context.prototype.mask = function (pattern: Pattern): void {
|
|
851
|
-
cairoMask(getHandle(this), getHandle(pattern));
|
|
852
|
-
};
|
|
853
|
-
|
|
854
|
-
const cairoMaskSurface = bind(
|
|
855
|
-
"libcairo.so.2",
|
|
856
|
-
"cairo_mask_surface",
|
|
857
|
-
[
|
|
858
|
-
CONTEXT_T,
|
|
859
|
-
t.boxed("CairoSurface", {
|
|
860
|
-
ownership: "borrowed",
|
|
861
|
-
sharedLibrary: "libcairo-gobject.so.2",
|
|
862
|
-
getTypeFnName: "cairo_gobject_surface_get_type",
|
|
863
|
-
}),
|
|
864
|
-
t.float64,
|
|
865
|
-
t.float64,
|
|
866
|
-
],
|
|
867
|
-
t.void,
|
|
868
|
-
);
|
|
869
|
-
Context.prototype.maskSurface = function (surface: Surface, x: number, y: number): void {
|
|
870
|
-
cairoMaskSurface(getHandle(this), getHandle(surface), x, y);
|
|
871
|
-
};
|
|
872
|
-
|
|
873
|
-
const cairoSetMatrix = bind(
|
|
874
|
-
"libcairo.so.2",
|
|
875
|
-
"cairo_set_matrix",
|
|
876
|
-
[CONTEXT_T, t.boxed("cairo_matrix_t", { ownership: "borrowed", sharedLibrary: "libcairo.so.2" })],
|
|
877
|
-
t.void,
|
|
878
|
-
);
|
|
879
|
-
Context.prototype.setMatrix = function (matrix: CairoMatrix): void {
|
|
880
|
-
cairoSetMatrix(getHandle(this), getHandle(matrix));
|
|
881
|
-
};
|
|
882
|
-
|
|
883
|
-
const cairoGetMatrix = bind(
|
|
884
|
-
"libcairo.so.2",
|
|
885
|
-
"cairo_get_matrix",
|
|
886
|
-
[CONTEXT_T, t.boxed("cairo_matrix_t", { ownership: "borrowed", sharedLibrary: "libcairo.so.2" })],
|
|
887
|
-
t.void,
|
|
888
|
-
);
|
|
889
|
-
Context.prototype.getMatrix = function (): CairoMatrix {
|
|
890
|
-
const { handle, obj } = allocMatrix();
|
|
891
|
-
cairoGetMatrix(getHandle(this), handle);
|
|
892
|
-
return obj;
|
|
893
|
-
};
|
|
894
|
-
|
|
895
|
-
const cairoTransform = bind(
|
|
896
|
-
"libcairo.so.2",
|
|
897
|
-
"cairo_transform",
|
|
898
|
-
[CONTEXT_T, t.boxed("cairo_matrix_t", { ownership: "borrowed", sharedLibrary: "libcairo.so.2" })],
|
|
899
|
-
t.void,
|
|
900
|
-
);
|
|
901
|
-
Context.prototype.transform = function (matrix: CairoMatrix): void {
|
|
902
|
-
cairoTransform(getHandle(this), getHandle(matrix));
|
|
903
|
-
};
|
|
904
|
-
|
|
905
|
-
const cairoIdentityMatrix = bind("libcairo.so.2", "cairo_identity_matrix", [CONTEXT_T], t.void);
|
|
906
|
-
Context.prototype.identityMatrix = function (): void {
|
|
907
|
-
cairoIdentityMatrix(getHandle(this));
|
|
908
|
-
};
|
|
909
|
-
|
|
910
|
-
const COORD_ARGS = [CONTEXT_T, t.ref(t.float64), t.ref(t.float64)];
|
|
911
|
-
const cairoUserToDevice = bind("libcairo.so.2", "cairo_user_to_device", COORD_ARGS, t.void);
|
|
912
|
-
const cairoUserToDeviceDistance = bind("libcairo.so.2", "cairo_user_to_device_distance", COORD_ARGS, t.void);
|
|
913
|
-
const cairoDeviceToUser = bind("libcairo.so.2", "cairo_device_to_user", COORD_ARGS, t.void);
|
|
914
|
-
const cairoDeviceToUserDistance = bind("libcairo.so.2", "cairo_device_to_user_distance", COORD_ARGS, t.void);
|
|
915
|
-
|
|
916
|
-
const coordTransform = (
|
|
917
|
-
ctx: Context,
|
|
918
|
-
boundFn: (...args: unknown[]) => unknown,
|
|
919
|
-
a: number,
|
|
920
|
-
b: number,
|
|
921
|
-
): [number, number] => {
|
|
922
|
-
const aRef = { value: a };
|
|
923
|
-
const bRef = { value: b };
|
|
924
|
-
boundFn(getHandle(ctx), aRef, bRef);
|
|
925
|
-
return [aRef.value, bRef.value];
|
|
926
|
-
};
|
|
927
|
-
|
|
928
|
-
Context.prototype.userToDevice = function (x: number, y: number): { x: number; y: number } {
|
|
929
|
-
const [px, py] = coordTransform(this, cairoUserToDevice, x, y);
|
|
930
|
-
return { x: px, y: py };
|
|
931
|
-
};
|
|
932
|
-
|
|
933
|
-
Context.prototype.userToDeviceDistance = function (dx: number, dy: number): { dx: number; dy: number } {
|
|
934
|
-
const [ddx, ddy] = coordTransform(this, cairoUserToDeviceDistance, dx, dy);
|
|
935
|
-
return { dx: ddx, dy: ddy };
|
|
936
|
-
};
|
|
937
|
-
|
|
938
|
-
Context.prototype.deviceToUser = function (x: number, y: number): { x: number; y: number } {
|
|
939
|
-
const [px, py] = coordTransform(this, cairoDeviceToUser, x, y);
|
|
940
|
-
return { x: px, y: py };
|
|
941
|
-
};
|
|
942
|
-
|
|
943
|
-
Context.prototype.deviceToUserDistance = function (dx: number, dy: number): { dx: number; dy: number } {
|
|
944
|
-
const [ddx, ddy] = coordTransform(this, cairoDeviceToUserDistance, dx, dy);
|
|
945
|
-
return { dx: ddx, dy: ddy };
|
|
946
|
-
};
|
|
947
|
-
|
|
948
|
-
const cairoStatus = bind("libcairo.so.2", "cairo_status", [CONTEXT_T], t.int32);
|
|
949
|
-
Context.prototype.status = function (): Status {
|
|
950
|
-
return cairoStatus(getHandle(this)) as Status;
|
|
951
|
-
};
|
|
952
|
-
|
|
953
|
-
const cairoGetReferenceCount = bind("libcairo.so.2", "cairo_get_reference_count", [CONTEXT_T], t.int32);
|
|
954
|
-
Context.prototype.getReferenceCount = function (): number {
|
|
955
|
-
return cairoGetReferenceCount(getHandle(this)) as number;
|
|
956
|
-
};
|
|
957
|
-
|
|
958
|
-
declare module "../cairo.js" {
|
|
959
|
-
interface Context {
|
|
960
|
-
pushGroup(): void;
|
|
961
|
-
pushGroupWithContent(content: Content): void;
|
|
962
|
-
popGroup(): Pattern;
|
|
963
|
-
popGroupToSource(): void;
|
|
964
|
-
getGroupTarget(): Surface;
|
|
965
|
-
|
|
966
|
-
setFontFace(fontFace: FontFace): void;
|
|
967
|
-
getFontFace(): FontFace;
|
|
968
|
-
setFontMatrix(matrix: CairoMatrix): void;
|
|
969
|
-
getFontMatrix(): CairoMatrix;
|
|
970
|
-
setScaledFont(scaledFont: ScaledFont): void;
|
|
971
|
-
getScaledFont(): ScaledFont;
|
|
972
|
-
|
|
973
|
-
showGlyphs(glyphs: Array<{ index: number; x: number; y: number }>): void;
|
|
974
|
-
glyphPath(glyphs: Array<{ index: number; x: number; y: number }>): void;
|
|
975
|
-
glyphExtents(glyphs: Array<{ index: number; x: number; y: number }>): TextExtents;
|
|
976
|
-
|
|
977
|
-
copyPath(): PathData[];
|
|
978
|
-
copyPathFlat(): PathData[];
|
|
979
|
-
appendPath(data: PathData[]): void;
|
|
980
|
-
}
|
|
981
|
-
}
|
|
982
|
-
|
|
983
|
-
const cairoPushGroup = bind("libcairo.so.2", "cairo_push_group", [CONTEXT_T], t.void);
|
|
984
|
-
Context.prototype.pushGroup = function (): void {
|
|
985
|
-
cairoPushGroup(getHandle(this));
|
|
986
|
-
};
|
|
987
|
-
|
|
988
|
-
const cairoPushGroupWithContent = bind("libcairo.so.2", "cairo_push_group_with_content", [CONTEXT_T, t.int32], t.void);
|
|
989
|
-
Context.prototype.pushGroupWithContent = function (content: Content): void {
|
|
990
|
-
cairoPushGroupWithContent(getHandle(this), content);
|
|
991
|
-
};
|
|
992
|
-
|
|
993
|
-
const cairoPopGroup = bind(
|
|
994
|
-
"libcairo.so.2",
|
|
995
|
-
"cairo_pop_group",
|
|
996
|
-
[CONTEXT_T],
|
|
997
|
-
t.boxed("CairoPattern", {
|
|
998
|
-
ownership: "full",
|
|
999
|
-
sharedLibrary: "libcairo-gobject.so.2",
|
|
1000
|
-
getTypeFnName: "cairo_gobject_pattern_get_type",
|
|
1001
|
-
}),
|
|
1002
|
-
);
|
|
1003
|
-
Context.prototype.popGroup = function (): Pattern {
|
|
1004
|
-
return wrapHandle(cairoPopGroup(getHandle(this)) as ExternalObject<Handle>, Pattern) as Pattern;
|
|
1005
|
-
};
|
|
1006
|
-
|
|
1007
|
-
const cairoPopGroupToSource = bind("libcairo.so.2", "cairo_pop_group_to_source", [CONTEXT_T], t.void);
|
|
1008
|
-
Context.prototype.popGroupToSource = function (): void {
|
|
1009
|
-
cairoPopGroupToSource(getHandle(this));
|
|
1010
|
-
};
|
|
1011
|
-
|
|
1012
|
-
const cairoGetGroupTarget = bind(
|
|
1013
|
-
"libcairo.so.2",
|
|
1014
|
-
"cairo_get_group_target",
|
|
1015
|
-
[CONTEXT_T],
|
|
1016
|
-
t.boxed("CairoSurface", {
|
|
1017
|
-
ownership: "borrowed",
|
|
1018
|
-
sharedLibrary: "libcairo-gobject.so.2",
|
|
1019
|
-
getTypeFnName: "cairo_gobject_surface_get_type",
|
|
1020
|
-
}),
|
|
1021
|
-
);
|
|
1022
|
-
Context.prototype.getGroupTarget = function (): Surface {
|
|
1023
|
-
return wrapHandle(cairoGetGroupTarget(getHandle(this)) as ExternalObject<Handle>, Surface) as Surface;
|
|
1024
|
-
};
|
|
1025
|
-
|
|
1026
|
-
const cairoSetFontFace = bind(
|
|
1027
|
-
"libcairo.so.2",
|
|
1028
|
-
"cairo_set_font_face",
|
|
1029
|
-
[
|
|
1030
|
-
CONTEXT_T,
|
|
1031
|
-
t.boxed("CairoFontFace", {
|
|
1032
|
-
ownership: "borrowed",
|
|
1033
|
-
sharedLibrary: "libcairo-gobject.so.2",
|
|
1034
|
-
getTypeFnName: "cairo_gobject_font_face_get_type",
|
|
1035
|
-
}),
|
|
1036
|
-
],
|
|
1037
|
-
t.void,
|
|
1038
|
-
);
|
|
1039
|
-
Context.prototype.setFontFace = function (fontFace: FontFace): void {
|
|
1040
|
-
cairoSetFontFace(getHandle(this), getHandle(fontFace));
|
|
1041
|
-
};
|
|
1042
|
-
|
|
1043
|
-
const cairoGetFontFace = bind(
|
|
1044
|
-
"libcairo.so.2",
|
|
1045
|
-
"cairo_get_font_face",
|
|
1046
|
-
[CONTEXT_T],
|
|
1047
|
-
t.boxed("CairoFontFace", {
|
|
1048
|
-
ownership: "borrowed",
|
|
1049
|
-
sharedLibrary: "libcairo-gobject.so.2",
|
|
1050
|
-
getTypeFnName: "cairo_gobject_font_face_get_type",
|
|
1051
|
-
}),
|
|
1052
|
-
);
|
|
1053
|
-
Context.prototype.getFontFace = function (): FontFace {
|
|
1054
|
-
return wrapHandle(cairoGetFontFace(getHandle(this)) as ExternalObject<Handle>, FontFace) as FontFace;
|
|
1055
|
-
};
|
|
1056
|
-
|
|
1057
|
-
const cairoSetFontMatrix = bind(
|
|
1058
|
-
"libcairo.so.2",
|
|
1059
|
-
"cairo_set_font_matrix",
|
|
1060
|
-
[CONTEXT_T, t.boxed("cairo_matrix_t", { ownership: "borrowed", sharedLibrary: "libcairo.so.2" })],
|
|
1061
|
-
t.void,
|
|
1062
|
-
);
|
|
1063
|
-
Context.prototype.setFontMatrix = function (matrix: CairoMatrix): void {
|
|
1064
|
-
cairoSetFontMatrix(getHandle(this), getHandle(matrix));
|
|
1065
|
-
};
|
|
1066
|
-
|
|
1067
|
-
const cairoGetFontMatrix = bind(
|
|
1068
|
-
"libcairo.so.2",
|
|
1069
|
-
"cairo_get_font_matrix",
|
|
1070
|
-
[CONTEXT_T, t.boxed("cairo_matrix_t", { ownership: "borrowed", sharedLibrary: "libcairo.so.2" })],
|
|
1071
|
-
t.void,
|
|
1072
|
-
);
|
|
1073
|
-
Context.prototype.getFontMatrix = function (): CairoMatrix {
|
|
1074
|
-
const { handle, obj } = allocMatrix();
|
|
1075
|
-
cairoGetFontMatrix(getHandle(this), handle);
|
|
1076
|
-
return obj;
|
|
1077
|
-
};
|
|
1078
|
-
|
|
1079
|
-
const cairoSetScaledFont = bind(
|
|
1080
|
-
"libcairo.so.2",
|
|
1081
|
-
"cairo_set_scaled_font",
|
|
1082
|
-
[
|
|
1083
|
-
CONTEXT_T,
|
|
1084
|
-
t.boxed("CairoScaledFont", {
|
|
1085
|
-
ownership: "borrowed",
|
|
1086
|
-
sharedLibrary: "libcairo-gobject.so.2",
|
|
1087
|
-
getTypeFnName: "cairo_gobject_scaled_font_get_type",
|
|
1088
|
-
}),
|
|
1089
|
-
],
|
|
1090
|
-
t.void,
|
|
1091
|
-
);
|
|
1092
|
-
Context.prototype.setScaledFont = function (scaledFont: ScaledFont): void {
|
|
1093
|
-
cairoSetScaledFont(getHandle(this), getHandle(scaledFont));
|
|
1094
|
-
};
|
|
1095
|
-
|
|
1096
|
-
const cairoGetScaledFont = bind(
|
|
1097
|
-
"libcairo.so.2",
|
|
1098
|
-
"cairo_get_scaled_font",
|
|
1099
|
-
[CONTEXT_T],
|
|
1100
|
-
t.boxed("CairoScaledFont", {
|
|
1101
|
-
ownership: "borrowed",
|
|
1102
|
-
sharedLibrary: "libcairo-gobject.so.2",
|
|
1103
|
-
getTypeFnName: "cairo_gobject_scaled_font_get_type",
|
|
1104
|
-
}),
|
|
1105
|
-
);
|
|
1106
|
-
Context.prototype.getScaledFont = function (): ScaledFont {
|
|
1107
|
-
return wrapHandle(cairoGetScaledFont(getHandle(this)) as ExternalObject<Handle>, ScaledFont) as ScaledFont;
|
|
1108
|
-
};
|
|
1109
|
-
|
|
1110
|
-
const cairoShowGlyphs = bind(
|
|
1111
|
-
"libcairo.so.2",
|
|
1112
|
-
"cairo_show_glyphs",
|
|
1113
|
-
[CONTEXT_T, t.boxed("cairo_glyph_t", { ownership: "borrowed", sharedLibrary: "libcairo.so.2" }), t.int32],
|
|
1114
|
-
t.void,
|
|
1115
|
-
);
|
|
1116
|
-
Context.prototype.showGlyphs = function (glyphs: Array<{ index: number; x: number; y: number }>): void {
|
|
1117
|
-
cairoShowGlyphs(getHandle(this), allocGlyphBuffer(glyphs), glyphs.length);
|
|
1118
|
-
};
|
|
1119
|
-
|
|
1120
|
-
const cairoGlyphPath = bind(
|
|
1121
|
-
"libcairo.so.2",
|
|
1122
|
-
"cairo_glyph_path",
|
|
1123
|
-
[CONTEXT_T, t.boxed("cairo_glyph_t", { ownership: "borrowed", sharedLibrary: "libcairo.so.2" }), t.int32],
|
|
1124
|
-
t.void,
|
|
1125
|
-
);
|
|
1126
|
-
Context.prototype.glyphPath = function (glyphs: Array<{ index: number; x: number; y: number }>): void {
|
|
1127
|
-
cairoGlyphPath(getHandle(this), allocGlyphBuffer(glyphs), glyphs.length);
|
|
1128
|
-
};
|
|
1129
|
-
|
|
1130
|
-
const cairoGlyphExtents = bind(
|
|
1131
|
-
"libcairo.so.2",
|
|
1132
|
-
"cairo_glyph_extents",
|
|
1133
|
-
[
|
|
1134
|
-
CONTEXT_T,
|
|
1135
|
-
t.boxed("cairo_glyph_t", { ownership: "borrowed", sharedLibrary: "libcairo.so.2" }),
|
|
1136
|
-
t.int32,
|
|
1137
|
-
t.boxed("cairo_text_extents_t", { ownership: "borrowed", sharedLibrary: "libcairo.so.2" }),
|
|
1138
|
-
],
|
|
1139
|
-
t.void,
|
|
1140
|
-
);
|
|
1141
|
-
Context.prototype.glyphExtents = function (glyphs: Array<{ index: number; x: number; y: number }>): TextExtents {
|
|
1142
|
-
const buf = allocGlyphBuffer(glyphs);
|
|
1143
|
-
const extents = alloc(48);
|
|
1144
|
-
cairoGlyphExtents(getHandle(this), buf, glyphs.length, extents);
|
|
1145
|
-
return readTextExtents(extents);
|
|
1146
|
-
};
|
|
1147
|
-
|
|
1148
|
-
const cairoCopyPath = bind(
|
|
1149
|
-
"libcairo.so.2",
|
|
1150
|
-
"cairo_copy_path",
|
|
1151
|
-
[CONTEXT_T],
|
|
1152
|
-
t.boxed("cairo_path_t", { ownership: "full", sharedLibrary: "libcairo.so.2", freeFnName: "cairo_path_destroy" }),
|
|
1153
|
-
);
|
|
1154
|
-
Context.prototype.copyPath = function (): PathData[] {
|
|
1155
|
-
return parsePath(cairoCopyPath(getHandle(this)) as ExternalObject<Handle>);
|
|
1156
|
-
};
|
|
1157
|
-
|
|
1158
|
-
const cairoCopyPathFlat = bind(
|
|
1159
|
-
"libcairo.so.2",
|
|
1160
|
-
"cairo_copy_path_flat",
|
|
1161
|
-
[CONTEXT_T],
|
|
1162
|
-
t.boxed("cairo_path_t", { ownership: "full", sharedLibrary: "libcairo.so.2", freeFnName: "cairo_path_destroy" }),
|
|
1163
|
-
);
|
|
1164
|
-
Context.prototype.copyPathFlat = function (): PathData[] {
|
|
1165
|
-
return parsePath(cairoCopyPathFlat(getHandle(this)) as ExternalObject<Handle>);
|
|
1166
|
-
};
|
|
1167
|
-
|
|
1168
|
-
Context.prototype.appendPath = function (data: PathData[]): void {
|
|
1169
|
-
for (const item of data) {
|
|
1170
|
-
switch (item.type) {
|
|
1171
|
-
case "moveTo":
|
|
1172
|
-
this.moveTo(item.x, item.y);
|
|
1173
|
-
break;
|
|
1174
|
-
case "lineTo":
|
|
1175
|
-
this.lineTo(item.x, item.y);
|
|
1176
|
-
break;
|
|
1177
|
-
case "curveTo":
|
|
1178
|
-
this.curveTo(item.x1, item.y1, item.x2, item.y2, item.x3, item.y3);
|
|
1179
|
-
break;
|
|
1180
|
-
case "closePath":
|
|
1181
|
-
this.closePath();
|
|
1182
|
-
break;
|
|
1183
|
-
}
|
|
1184
|
-
}
|
|
1185
|
-
};
|
|
1186
|
-
|
|
1187
|
-
const cairoStatusToString = bind("libcairo.so.2", "cairo_status_to_string", [t.int32], t.string("borrowed"));
|
|
1188
|
-
export const statusToString = (status: Status): string => {
|
|
1189
|
-
return cairoStatusToString(status) as string;
|
|
1190
|
-
};
|
|
1191
|
-
|
|
1192
|
-
const cairoCreate = bind(
|
|
1193
|
-
"libcairo.so.2",
|
|
1194
|
-
"cairo_create",
|
|
1195
|
-
[
|
|
1196
|
-
t.boxed("CairoSurface", {
|
|
1197
|
-
ownership: "borrowed",
|
|
1198
|
-
sharedLibrary: "libcairo-gobject.so.2",
|
|
1199
|
-
getTypeFnName: "cairo_gobject_surface_get_type",
|
|
1200
|
-
}),
|
|
1201
|
-
],
|
|
1202
|
-
CONTEXT_T,
|
|
1203
|
-
);
|
|
1204
|
-
|
|
1205
|
-
class ContextImpl extends Context {
|
|
1206
|
-
static create(surface: Surface): ContextImpl {
|
|
1207
|
-
return wrapHandle(cairoCreate(getHandle(surface)) as ExternalObject<Handle>, ContextImpl);
|
|
1208
|
-
}
|
|
1209
|
-
}
|
|
1210
|
-
|
|
1211
|
-
export { ContextImpl as Context };
|
|
1212
|
-
|
|
1213
|
-
declare module "../cairo.js" {
|
|
1214
|
-
interface Context {
|
|
1215
|
-
tagBegin(tagName: string, attributes: string): void;
|
|
1216
|
-
tagEnd(tagName: string): void;
|
|
1217
|
-
showTextGlyphs(
|
|
1218
|
-
text: string,
|
|
1219
|
-
glyphs: CairoGlyph[],
|
|
1220
|
-
clusters: CairoTextCluster[],
|
|
1221
|
-
clusterFlags: TextClusterFlags,
|
|
1222
|
-
): void;
|
|
1223
|
-
}
|
|
1224
|
-
}
|
|
1225
|
-
|
|
1226
|
-
const cairoTagBegin = bind("libcairo.so.2", "cairo_tag_begin", [CONTEXT_T, t.string("full"), t.string("full")], t.void);
|
|
1227
|
-
Context.prototype.tagBegin = function (tagName: string, attributes: string): void {
|
|
1228
|
-
cairoTagBegin(getHandle(this), tagName, attributes);
|
|
1229
|
-
};
|
|
1230
|
-
|
|
1231
|
-
const cairoTagEnd = bind("libcairo.so.2", "cairo_tag_end", [CONTEXT_T, t.string("full")], t.void);
|
|
1232
|
-
Context.prototype.tagEnd = function (tagName: string): void {
|
|
1233
|
-
cairoTagEnd(getHandle(this), tagName);
|
|
1234
|
-
};
|
|
1235
|
-
|
|
1236
|
-
const cairoShowTextGlyphs = bind(
|
|
1237
|
-
"libcairo.so.2",
|
|
1238
|
-
"cairo_show_text_glyphs",
|
|
1239
|
-
[
|
|
1240
|
-
CONTEXT_T,
|
|
1241
|
-
t.string("full"),
|
|
1242
|
-
t.int32,
|
|
1243
|
-
t.boxed("cairo_glyph_t", { ownership: "borrowed", sharedLibrary: "libcairo.so.2" }),
|
|
1244
|
-
t.int32,
|
|
1245
|
-
t.boxed("cairo_text_cluster_t", { ownership: "borrowed", sharedLibrary: "libcairo.so.2" }),
|
|
1246
|
-
t.int32,
|
|
1247
|
-
t.int32,
|
|
1248
|
-
],
|
|
1249
|
-
t.void,
|
|
1250
|
-
);
|
|
1251
|
-
Context.prototype.showTextGlyphs = function (
|
|
1252
|
-
text: string,
|
|
1253
|
-
glyphs: CairoGlyph[],
|
|
1254
|
-
clusters: CairoTextCluster[],
|
|
1255
|
-
clusterFlags: TextClusterFlags,
|
|
1256
|
-
): void {
|
|
1257
|
-
const glyphBuf = allocGlyphBuffer(glyphs);
|
|
1258
|
-
const clusterBuf = allocClusterBuffer(clusters);
|
|
1259
|
-
cairoShowTextGlyphs(
|
|
1260
|
-
getHandle(this),
|
|
1261
|
-
text,
|
|
1262
|
-
-1,
|
|
1263
|
-
glyphBuf,
|
|
1264
|
-
glyphs.length,
|
|
1265
|
-
clusterBuf,
|
|
1266
|
-
clusters.length,
|
|
1267
|
-
clusterFlags,
|
|
1268
|
-
);
|
|
1269
|
-
};
|