@gtkx/cairo 1.2.2

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.
Files changed (86) hide show
  1. package/dist/context.d.ts +229 -0
  2. package/dist/context.d.ts.map +1 -0
  3. package/dist/context.js +646 -0
  4. package/dist/context.js.map +1 -0
  5. package/dist/device.d.ts +21 -0
  6. package/dist/device.d.ts.map +1 -0
  7. package/dist/device.js +39 -0
  8. package/dist/device.js.map +1 -0
  9. package/dist/enums.d.ts +526 -0
  10. package/dist/enums.d.ts.map +1 -0
  11. package/dist/enums.js +482 -0
  12. package/dist/enums.js.map +1 -0
  13. package/dist/font-face.d.ts +55 -0
  14. package/dist/font-face.d.ts.map +1 -0
  15. package/dist/font-face.js +103 -0
  16. package/dist/font-face.js.map +1 -0
  17. package/dist/font-options.d.ts +43 -0
  18. package/dist/font-options.d.ts.map +1 -0
  19. package/dist/font-options.js +95 -0
  20. package/dist/font-options.js.map +1 -0
  21. package/dist/index.d.ts +29 -0
  22. package/dist/index.d.ts.map +1 -0
  23. package/dist/index.js +27 -0
  24. package/dist/index.js.map +1 -0
  25. package/dist/lib.d.ts +36 -0
  26. package/dist/lib.d.ts.map +1 -0
  27. package/dist/lib.js +120 -0
  28. package/dist/lib.js.map +1 -0
  29. package/dist/matrix.d.ts +40 -0
  30. package/dist/matrix.d.ts.map +1 -0
  31. package/dist/matrix.js +93 -0
  32. package/dist/matrix.js.map +1 -0
  33. package/dist/path.d.ts +14 -0
  34. package/dist/path.d.ts.map +1 -0
  35. package/dist/path.js +67 -0
  36. package/dist/path.js.map +1 -0
  37. package/dist/pattern.d.ts +95 -0
  38. package/dist/pattern.d.ts.map +1 -0
  39. package/dist/pattern.js +250 -0
  40. package/dist/pattern.js.map +1 -0
  41. package/dist/region.d.ts +59 -0
  42. package/dist/region.d.ts.map +1 -0
  43. package/dist/region.js +154 -0
  44. package/dist/region.js.map +1 -0
  45. package/dist/scaled-font.d.ts +43 -0
  46. package/dist/scaled-font.d.ts.map +1 -0
  47. package/dist/scaled-font.js +156 -0
  48. package/dist/scaled-font.js.map +1 -0
  49. package/dist/structs.d.ts +120 -0
  50. package/dist/structs.d.ts.map +1 -0
  51. package/dist/structs.js +185 -0
  52. package/dist/structs.js.map +1 -0
  53. package/dist/surface.d.ts +98 -0
  54. package/dist/surface.d.ts.map +1 -0
  55. package/dist/surface.js +274 -0
  56. package/dist/surface.js.map +1 -0
  57. package/dist/text.d.ts +10 -0
  58. package/dist/text.d.ts.map +1 -0
  59. package/dist/text.js +45 -0
  60. package/dist/text.js.map +1 -0
  61. package/dist/types.d.ts +245 -0
  62. package/dist/types.d.ts.map +1 -0
  63. package/dist/types.js +2 -0
  64. package/dist/types.js.map +1 -0
  65. package/dist/version.d.ts +9 -0
  66. package/dist/version.d.ts.map +1 -0
  67. package/dist/version.js +13 -0
  68. package/dist/version.js.map +1 -0
  69. package/package.json +64 -0
  70. package/src/context.ts +899 -0
  71. package/src/device.ts +50 -0
  72. package/src/enums.ts +571 -0
  73. package/src/font-face.ts +157 -0
  74. package/src/font-options.ts +142 -0
  75. package/src/index.ts +28 -0
  76. package/src/lib.ts +186 -0
  77. package/src/matrix.ts +135 -0
  78. package/src/path.ts +87 -0
  79. package/src/pattern.ts +423 -0
  80. package/src/region.ts +216 -0
  81. package/src/scaled-font.ts +268 -0
  82. package/src/structs.ts +306 -0
  83. package/src/surface.ts +411 -0
  84. package/src/text.ts +56 -0
  85. package/src/types.ts +290 -0
  86. package/src/version.ts +16 -0
package/src/types.ts ADDED
@@ -0,0 +1,290 @@
1
+ /** One glyph to draw: its index in the font and its position in user space. */
2
+ type CairoGlyph = {
3
+ /** Index of the glyph in the font. */
4
+ index: number;
5
+ /** Horizontal position of the glyph origin. */
6
+ x: number;
7
+ /** Vertical position of the glyph origin. */
8
+ y: number;
9
+ };
10
+
11
+ /** One text cluster: how many bytes of text map to how many glyphs. */
12
+ type CairoTextCluster = {
13
+ /** Number of UTF-8 bytes the cluster covers. */
14
+ numBytes: number;
15
+ /** Number of glyphs the cluster covers. */
16
+ numGlyphs: number;
17
+ };
18
+
19
+ /** Extents of a run of text or glyphs in user space. */
20
+ type TextExtents = {
21
+ /** Horizontal distance from the origin to the leftmost part of the glyphs. */
22
+ xBearing: number;
23
+ /** Vertical distance from the origin to the topmost part of the glyphs. */
24
+ yBearing: number;
25
+ /** Width of the glyphs as drawn. */
26
+ width: number;
27
+ /** Height of the glyphs as drawn. */
28
+ height: number;
29
+ /** Horizontal distance to advance after drawing the glyphs. */
30
+ xAdvance: number;
31
+ /** Vertical distance to advance after drawing the glyphs. */
32
+ yAdvance: number;
33
+ };
34
+
35
+ /** Metrics of a font in user space. */
36
+ type FontExtents = {
37
+ /** Distance the font extends above the baseline. */
38
+ ascent: number;
39
+ /** Distance the font extends below the baseline. */
40
+ descent: number;
41
+ /** Recommended vertical distance between baselines. */
42
+ height: number;
43
+ /** Maximum horizontal advance of any glyph in the font. */
44
+ maxXAdvance: number;
45
+ /** Maximum vertical advance of any glyph in the font. */
46
+ maxYAdvance: number;
47
+ };
48
+
49
+ /** A path segment starting a new sub-path at a point. */
50
+ type MoveToSegment = {
51
+ /** Tag of the segment. */
52
+ type: "moveTo";
53
+ /** Horizontal position of the point. */
54
+ x: number;
55
+ /** Vertical position of the point. */
56
+ y: number;
57
+ };
58
+
59
+ /** A path segment drawing a straight line to a point. */
60
+ type LineToSegment = {
61
+ /** Tag of the segment. */
62
+ type: "lineTo";
63
+ /** Horizontal position of the end point. */
64
+ x: number;
65
+ /** Vertical position of the end point. */
66
+ y: number;
67
+ };
68
+
69
+ /** A path segment drawing a cubic Bézier curve through two control points to an end point. */
70
+ type CurveToSegment = {
71
+ /** Tag of the segment. */
72
+ type: "curveTo";
73
+ /** Horizontal position of the first control point. */
74
+ x1: number;
75
+ /** Vertical position of the first control point. */
76
+ y1: number;
77
+ /** Horizontal position of the second control point. */
78
+ x2: number;
79
+ /** Vertical position of the second control point. */
80
+ y2: number;
81
+ /** Horizontal position of the end point. */
82
+ x3: number;
83
+ /** Vertical position of the end point. */
84
+ y3: number;
85
+ };
86
+
87
+ /** A path segment closing the current sub-path. */
88
+ type ClosePathSegment = {
89
+ /** Tag of the segment. */
90
+ type: "closePath";
91
+ };
92
+
93
+ /** One segment of a path copied out of a context or a mesh pattern. */
94
+ type PathData = MoveToSegment | LineToSegment | CurveToSegment | ClosePathSegment;
95
+
96
+ /** A position in user or device space. */
97
+ type Point = {
98
+ /** Horizontal coordinate. */
99
+ x: number;
100
+ /** Vertical coordinate. */
101
+ y: number;
102
+ };
103
+
104
+ /** A displacement in user or device space, unaffected by translation. */
105
+ type Distance = {
106
+ /** Horizontal component. */
107
+ dx: number;
108
+ /** Vertical component. */
109
+ dy: number;
110
+ };
111
+
112
+ /** A bounding box given by its two opposite corners in user space. */
113
+ type Extents = {
114
+ /** Left edge. */
115
+ x1: number;
116
+ /** Top edge. */
117
+ y1: number;
118
+ /** Right edge. */
119
+ x2: number;
120
+ /** Bottom edge. */
121
+ y2: number;
122
+ };
123
+
124
+ /** A dash pattern as a context reports it: alternating on and off lengths and the offset into them. */
125
+ type DashPattern = {
126
+ /** Alternating on and off lengths in user space; empty for a solid line. */
127
+ dashes: number[];
128
+ /** Offset into the pattern at which the stroke starts. */
129
+ offset: number;
130
+ };
131
+
132
+ /** A rectangle as plain data, for the calls that take or return many at once. */
133
+ type RectangleData = {
134
+ /** Horizontal position of the left edge. */
135
+ x: number;
136
+ /** Vertical position of the top edge. */
137
+ y: number;
138
+ /** Width of the rectangle. */
139
+ width: number;
140
+ /** Height of the rectangle. */
141
+ height: number;
142
+ };
143
+
144
+ /** A color with straight (non-premultiplied) components in the 0 to 1 range. */
145
+ type RgbaColor = {
146
+ /** Red component. */
147
+ red: number;
148
+ /** Green component. */
149
+ green: number;
150
+ /** Blue component. */
151
+ blue: number;
152
+ /** Alpha component. */
153
+ alpha: number;
154
+ };
155
+
156
+ /** A color stop of a gradient pattern: its offset along the gradient and its color. */
157
+ type ColorStop = {
158
+ /** Position of the stop along the gradient, from 0 at the start to 1 at the end. */
159
+ offset: number;
160
+ /** Red component. */
161
+ red: number;
162
+ /** Green component. */
163
+ green: number;
164
+ /** Blue component. */
165
+ blue: number;
166
+ /** Alpha component. */
167
+ alpha: number;
168
+ };
169
+
170
+ /** The two end points of a linear gradient in pattern space. */
171
+ type LinearPoints = {
172
+ /** Horizontal coordinate of the start point. */
173
+ x0: number;
174
+ /** Vertical coordinate of the start point. */
175
+ y0: number;
176
+ /** Horizontal coordinate of the end point. */
177
+ x1: number;
178
+ /** Vertical coordinate of the end point. */
179
+ y1: number;
180
+ };
181
+
182
+ /** The two circles of a radial gradient in pattern space. */
183
+ type RadialCircles = {
184
+ /** Horizontal center of the start circle. */
185
+ x0: number;
186
+ /** Vertical center of the start circle. */
187
+ y0: number;
188
+ /** Radius of the start circle. */
189
+ r0: number;
190
+ /** Horizontal center of the end circle. */
191
+ x1: number;
192
+ /** Vertical center of the end circle. */
193
+ y1: number;
194
+ /** Radius of the end circle. */
195
+ r1: number;
196
+ };
197
+
198
+ /** The offset a surface adds to device coordinates. */
199
+ type DeviceOffset = {
200
+ /** Horizontal offset in device units. */
201
+ xOffset: number;
202
+ /** Vertical offset in device units. */
203
+ yOffset: number;
204
+ };
205
+
206
+ /** The scale a surface applies between user and device units. */
207
+ type DeviceScale = {
208
+ /** Horizontal scale factor. */
209
+ xScale: number;
210
+ /** Vertical scale factor. */
211
+ yScale: number;
212
+ };
213
+
214
+ /** The resolution a surface falls back to when it rasterizes vector content. */
215
+ type FallbackResolution = {
216
+ /** Horizontal pixels per inch. */
217
+ xPixelsPerInch: number;
218
+ /** Vertical pixels per inch. */
219
+ yPixelsPerInch: number;
220
+ };
221
+
222
+ /** The area a recording surface has been drawn on, in its coordinate space. */
223
+ type InkExtents = {
224
+ /** Horizontal position of the left edge. */
225
+ x0: number;
226
+ /** Vertical position of the top edge. */
227
+ y0: number;
228
+ /** Width of the drawn area. */
229
+ width: number;
230
+ /** Height of the drawn area. */
231
+ height: number;
232
+ };
233
+
234
+ /** @deprecated Since 1.3. Props of the generated stub constructor that `@gtkx/cairo` replaced; removed in v2. */
235
+ type ContextConstructorProps = Record<string, never>;
236
+ /** @deprecated Since 1.3. Props of the generated stub constructor that `@gtkx/cairo` replaced; removed in v2. */
237
+ type DeviceConstructorProps = Record<string, never>;
238
+ /** @deprecated Since 1.3. Props of the generated stub constructor that `@gtkx/cairo` replaced; removed in v2. */
239
+ type SurfaceConstructorProps = Record<string, never>;
240
+ /** @deprecated Since 1.3. Props of the generated stub constructor that `@gtkx/cairo` replaced; removed in v2. */
241
+ type PatternConstructorProps = Record<string, never>;
242
+ /** @deprecated Since 1.3. Props of the generated stub constructor that `@gtkx/cairo` replaced; removed in v2. */
243
+ type RegionConstructorProps = Record<string, never>;
244
+ /** @deprecated Since 1.3. Props of the generated stub constructor that `@gtkx/cairo` replaced; removed in v2. */
245
+ type FontOptionsConstructorProps = Record<string, never>;
246
+ /** @deprecated Since 1.3. Props of the generated stub constructor that `@gtkx/cairo` replaced; removed in v2. */
247
+ type FontFaceConstructorProps = Record<string, never>;
248
+ /** @deprecated Since 1.3. Props of the generated stub constructor that `@gtkx/cairo` replaced; removed in v2. */
249
+ type ScaledFontConstructorProps = Record<string, never>;
250
+
251
+ export type {
252
+ CairoGlyph,
253
+ CairoTextCluster,
254
+ ClosePathSegment,
255
+ ColorStop,
256
+ /** @deprecated Since 1.3. Removed in v2. */
257
+ ContextConstructorProps,
258
+ CurveToSegment,
259
+ DashPattern,
260
+ /** @deprecated Since 1.3. Removed in v2. */
261
+ DeviceConstructorProps,
262
+ DeviceOffset,
263
+ DeviceScale,
264
+ Distance,
265
+ Extents,
266
+ FallbackResolution,
267
+ FontExtents,
268
+ /** @deprecated Since 1.3. Removed in v2. */
269
+ FontFaceConstructorProps,
270
+ /** @deprecated Since 1.3. Removed in v2. */
271
+ FontOptionsConstructorProps,
272
+ InkExtents,
273
+ LinearPoints,
274
+ LineToSegment,
275
+ MoveToSegment,
276
+ PathData,
277
+ /** @deprecated Since 1.3. Removed in v2. */
278
+ PatternConstructorProps,
279
+ Point,
280
+ RadialCircles,
281
+ RectangleData,
282
+ /** @deprecated Since 1.3. Removed in v2. */
283
+ RegionConstructorProps,
284
+ RgbaColor,
285
+ /** @deprecated Since 1.3. Removed in v2. */
286
+ ScaledFontConstructorProps,
287
+ /** @deprecated Since 1.3. Removed in v2. */
288
+ SurfaceConstructorProps,
289
+ TextExtents,
290
+ };
package/src/version.ts ADDED
@@ -0,0 +1,16 @@
1
+ import { t } from "@gtkx/runtime";
2
+ import type { Status } from "./enums.js";
3
+ import { bindCairo } from "./lib.js";
4
+
5
+ const cairoVersion = bindCairo("cairo_version", [], t.int32);
6
+ const cairoVersionString = bindCairo("cairo_version_string", [], t.string("borrowed"));
7
+ const cairoStatusToString = bindCairo("cairo_status_to_string", [t.int32], t.string("borrowed"));
8
+
9
+ /** Returns the version of the cairo library in use, encoded as `major * 10000 + minor * 100 + micro`. */
10
+ const version = (): number => cairoVersion() as number;
11
+ /** Returns the version of the cairo library in use as a string such as `"1.18.2"`. */
12
+ const versionString = (): string => cairoVersionString() as string;
13
+ /** Returns a human-readable description of a status code. */
14
+ const statusToString = (status: Status): string => cairoStatusToString(status) as string;
15
+
16
+ export { statusToString, version, versionString };