@lexmata/micropdf 0.4.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/LICENSE +191 -0
- package/README.md +985 -0
- package/binding.gyp +73 -0
- package/dist/annot.d.ts +458 -0
- package/dist/annot.d.ts.map +1 -0
- package/dist/annot.js +697 -0
- package/dist/annot.js.map +1 -0
- package/dist/archive.d.ts +128 -0
- package/dist/archive.d.ts.map +1 -0
- package/dist/archive.js +268 -0
- package/dist/archive.js.map +1 -0
- package/dist/buffer.d.ts +572 -0
- package/dist/buffer.d.ts.map +1 -0
- package/dist/buffer.js +971 -0
- package/dist/buffer.js.map +1 -0
- package/dist/colorspace.d.ts +287 -0
- package/dist/colorspace.d.ts.map +1 -0
- package/dist/colorspace.js +542 -0
- package/dist/colorspace.js.map +1 -0
- package/dist/context.d.ts +184 -0
- package/dist/context.d.ts.map +1 -0
- package/dist/context.js +320 -0
- package/dist/context.js.map +1 -0
- package/dist/cookie.d.ts +164 -0
- package/dist/cookie.d.ts.map +1 -0
- package/dist/cookie.js +306 -0
- package/dist/cookie.js.map +1 -0
- package/dist/device.d.ts +169 -0
- package/dist/device.d.ts.map +1 -0
- package/dist/device.js +350 -0
- package/dist/device.js.map +1 -0
- package/dist/display-list.d.ts +202 -0
- package/dist/display-list.d.ts.map +1 -0
- package/dist/display-list.js +410 -0
- package/dist/display-list.js.map +1 -0
- package/dist/document.d.ts +637 -0
- package/dist/document.d.ts.map +1 -0
- package/dist/document.js +902 -0
- package/dist/document.js.map +1 -0
- package/dist/easy.d.ts +423 -0
- package/dist/easy.d.ts.map +1 -0
- package/dist/easy.js +644 -0
- package/dist/easy.js.map +1 -0
- package/dist/enhanced.d.ts +226 -0
- package/dist/enhanced.d.ts.map +1 -0
- package/dist/enhanced.js +368 -0
- package/dist/enhanced.js.map +1 -0
- package/dist/filter.d.ts +51 -0
- package/dist/filter.d.ts.map +1 -0
- package/dist/filter.js +381 -0
- package/dist/filter.js.map +1 -0
- package/dist/font.d.ts +222 -0
- package/dist/font.d.ts.map +1 -0
- package/dist/font.js +381 -0
- package/dist/font.js.map +1 -0
- package/dist/form.d.ts +214 -0
- package/dist/form.d.ts.map +1 -0
- package/dist/form.js +497 -0
- package/dist/form.js.map +1 -0
- package/dist/geometry.d.ts +469 -0
- package/dist/geometry.d.ts.map +1 -0
- package/dist/geometry.js +780 -0
- package/dist/geometry.js.map +1 -0
- package/dist/image.d.ts +172 -0
- package/dist/image.d.ts.map +1 -0
- package/dist/image.js +348 -0
- package/dist/image.js.map +1 -0
- package/dist/index.d.ts +171 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +339 -0
- package/dist/index.js.map +1 -0
- package/dist/link.d.ts +168 -0
- package/dist/link.d.ts.map +1 -0
- package/dist/link.js +343 -0
- package/dist/link.js.map +1 -0
- package/dist/micropdf.d.ts +40 -0
- package/dist/micropdf.d.ts.map +1 -0
- package/dist/micropdf.js +45 -0
- package/dist/micropdf.js.map +1 -0
- package/dist/nanopdf.d.ts +40 -0
- package/dist/nanopdf.d.ts.map +1 -0
- package/dist/nanopdf.js +45 -0
- package/dist/nanopdf.js.map +1 -0
- package/dist/native.d.ts +242 -0
- package/dist/native.d.ts.map +1 -0
- package/dist/native.js +509 -0
- package/dist/native.js.map +1 -0
- package/dist/output.d.ts +166 -0
- package/dist/output.d.ts.map +1 -0
- package/dist/output.js +365 -0
- package/dist/output.js.map +1 -0
- package/dist/path.d.ts +420 -0
- package/dist/path.d.ts.map +1 -0
- package/dist/path.js +687 -0
- package/dist/path.js.map +1 -0
- package/dist/pdf/object.d.ts +489 -0
- package/dist/pdf/object.d.ts.map +1 -0
- package/dist/pdf/object.js +1045 -0
- package/dist/pdf/object.js.map +1 -0
- package/dist/pixmap.d.ts +315 -0
- package/dist/pixmap.d.ts.map +1 -0
- package/dist/pixmap.js +590 -0
- package/dist/pixmap.js.map +1 -0
- package/dist/profiler.d.ts +159 -0
- package/dist/profiler.d.ts.map +1 -0
- package/dist/profiler.js +380 -0
- package/dist/profiler.js.map +1 -0
- package/dist/render-options.d.ts +227 -0
- package/dist/render-options.d.ts.map +1 -0
- package/dist/render-options.js +130 -0
- package/dist/render-options.js.map +1 -0
- package/dist/resource-tracking.d.ts +332 -0
- package/dist/resource-tracking.d.ts.map +1 -0
- package/dist/resource-tracking.js +653 -0
- package/dist/resource-tracking.js.map +1 -0
- package/dist/simple.d.ts +276 -0
- package/dist/simple.d.ts.map +1 -0
- package/dist/simple.js +343 -0
- package/dist/simple.js.map +1 -0
- package/dist/stext.d.ts +290 -0
- package/dist/stext.d.ts.map +1 -0
- package/dist/stext.js +312 -0
- package/dist/stext.js.map +1 -0
- package/dist/stream.d.ts +174 -0
- package/dist/stream.d.ts.map +1 -0
- package/dist/stream.js +476 -0
- package/dist/stream.js.map +1 -0
- package/dist/text.d.ts +337 -0
- package/dist/text.d.ts.map +1 -0
- package/dist/text.js +454 -0
- package/dist/text.js.map +1 -0
- package/dist/typed-arrays.d.ts +127 -0
- package/dist/typed-arrays.d.ts.map +1 -0
- package/dist/typed-arrays.js +410 -0
- package/dist/typed-arrays.js.map +1 -0
- package/dist/types.d.ts +358 -0
- package/dist/types.d.ts.map +1 -0
- package/dist/types.js +216 -0
- package/dist/types.js.map +1 -0
- package/native/annot.cc +557 -0
- package/native/buffer.cc +204 -0
- package/native/colorspace.cc +166 -0
- package/native/context.cc +84 -0
- package/native/cookie.cc +179 -0
- package/native/device.cc +179 -0
- package/native/display_list.cc +179 -0
- package/native/document.cc +268 -0
- package/native/enhanced.cc +70 -0
- package/native/font.cc +282 -0
- package/native/form.cc +523 -0
- package/native/geometry.cc +255 -0
- package/native/image.cc +216 -0
- package/native/include/micropdf/enhanced.h +38 -0
- package/native/include/micropdf/types.h +36 -0
- package/native/include/micropdf.h +106 -0
- package/native/include/mupdf-ffi.h +39 -0
- package/native/include/mupdf.h +11 -0
- package/native/include/mupdf_minimal.h +381 -0
- package/native/lib/linux-x64/libmicropdf.a +0 -0
- package/native/link.cc +234 -0
- package/native/micropdf.cc +71 -0
- package/native/output.cc +229 -0
- package/native/page.cc +572 -0
- package/native/path.cc +259 -0
- package/native/pixmap.cc +240 -0
- package/native/stext.cc +610 -0
- package/native/stream.cc +239 -0
- package/package.json +120 -0
- package/scripts/build-from-rust.js +97 -0
- package/scripts/install.js +184 -0
|
@@ -0,0 +1,469 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Geometry primitives - Point, Rect, IRect, Matrix, Quad
|
|
3
|
+
*
|
|
4
|
+
* This module provides fundamental 2D geometry types used throughout the MicroPDF library.
|
|
5
|
+
* All types are immutable and follow functional programming principles.
|
|
6
|
+
*
|
|
7
|
+
* This implementation mirrors the Rust `fitz::geometry` module for 100% API compatibility.
|
|
8
|
+
*
|
|
9
|
+
* @module geometry
|
|
10
|
+
* @example
|
|
11
|
+
* ```typescript
|
|
12
|
+
* import { Point, Rect, Matrix } from 'micropdf';
|
|
13
|
+
*
|
|
14
|
+
* // Create a point
|
|
15
|
+
* const p = new Point(100, 200);
|
|
16
|
+
*
|
|
17
|
+
* // Create a rectangle
|
|
18
|
+
* const rect = new Rect(0, 0, 100, 100);
|
|
19
|
+
*
|
|
20
|
+
* // Transform with a matrix
|
|
21
|
+
* const matrix = Matrix.scale(2, 2);
|
|
22
|
+
* const transformed = p.transform(matrix);
|
|
23
|
+
* ```
|
|
24
|
+
*/
|
|
25
|
+
import type { PointLike, RectLike, IRectLike, MatrixLike, QuadLike } from './types.js';
|
|
26
|
+
export type { PointLike, RectLike, IRectLike, MatrixLike, QuadLike };
|
|
27
|
+
/**
|
|
28
|
+
* A 2D point with floating-point coordinates.
|
|
29
|
+
*
|
|
30
|
+
* Points are immutable - all operations return new Point instances rather than
|
|
31
|
+
* modifying the existing point. This makes them safe to use in functional programming
|
|
32
|
+
* contexts and prevents accidental mutations.
|
|
33
|
+
*
|
|
34
|
+
* @class Point
|
|
35
|
+
* @implements {PointLike}
|
|
36
|
+
* @example
|
|
37
|
+
* ```typescript
|
|
38
|
+
* // Create a point
|
|
39
|
+
* const p1 = new Point(10, 20);
|
|
40
|
+
*
|
|
41
|
+
* // Transform it
|
|
42
|
+
* const p2 = p1.scale(2); // Point(20, 40)
|
|
43
|
+
*
|
|
44
|
+
* // Calculate distance
|
|
45
|
+
* const distance = p1.distanceTo(p2); // 22.36...
|
|
46
|
+
*
|
|
47
|
+
* // Points are immutable
|
|
48
|
+
* const p3 = p1.add(new Point(5, 5)); // p1 is unchanged
|
|
49
|
+
* ```
|
|
50
|
+
*/
|
|
51
|
+
export declare class Point implements PointLike {
|
|
52
|
+
/**
|
|
53
|
+
* The x-coordinate of the point.
|
|
54
|
+
* @readonly
|
|
55
|
+
* @type {number}
|
|
56
|
+
*/
|
|
57
|
+
readonly x: number;
|
|
58
|
+
/**
|
|
59
|
+
* The y-coordinate of the point.
|
|
60
|
+
* @readonly
|
|
61
|
+
* @type {number}
|
|
62
|
+
*/
|
|
63
|
+
readonly y: number;
|
|
64
|
+
/**
|
|
65
|
+
* Creates a new Point with the specified coordinates.
|
|
66
|
+
*
|
|
67
|
+
* @param {number} x - The x-coordinate
|
|
68
|
+
* @param {number} y - The y-coordinate
|
|
69
|
+
* @example
|
|
70
|
+
* ```typescript
|
|
71
|
+
* const point = new Point(100, 200);
|
|
72
|
+
* console.log(point.x); // 100
|
|
73
|
+
* console.log(point.y); // 200
|
|
74
|
+
* ```
|
|
75
|
+
*/
|
|
76
|
+
constructor(x: number, y: number);
|
|
77
|
+
/**
|
|
78
|
+
* The origin point at coordinates (0, 0).
|
|
79
|
+
*
|
|
80
|
+
* This is a convenience constant for the most commonly used point.
|
|
81
|
+
*
|
|
82
|
+
* @static
|
|
83
|
+
* @readonly
|
|
84
|
+
* @type {Point}
|
|
85
|
+
* @example
|
|
86
|
+
* ```typescript
|
|
87
|
+
* const origin = Point.ORIGIN;
|
|
88
|
+
* console.log(origin.x, origin.y); // 0, 0
|
|
89
|
+
* ```
|
|
90
|
+
*/
|
|
91
|
+
static readonly ORIGIN: Point;
|
|
92
|
+
/**
|
|
93
|
+
* Creates a Point from a point-like object.
|
|
94
|
+
*
|
|
95
|
+
* This method accepts any object with `x` and `y` properties and converts it
|
|
96
|
+
* to a proper Point instance. If the input is already a Point, it returns it unchanged.
|
|
97
|
+
*
|
|
98
|
+
* @static
|
|
99
|
+
* @param {PointLike} p - A point-like object with x and y properties
|
|
100
|
+
* @returns {Point} A Point instance
|
|
101
|
+
* @example
|
|
102
|
+
* ```typescript
|
|
103
|
+
* // From a plain object
|
|
104
|
+
* const p1 = Point.from({ x: 10, y: 20 });
|
|
105
|
+
*
|
|
106
|
+
* // From an existing Point (returns the same instance)
|
|
107
|
+
* const p2 = new Point(10, 20);
|
|
108
|
+
* const p3 = Point.from(p2); // p2 === p3
|
|
109
|
+
* ```
|
|
110
|
+
*/
|
|
111
|
+
static from(p: PointLike): Point;
|
|
112
|
+
/**
|
|
113
|
+
* Transforms this point by a transformation matrix.
|
|
114
|
+
*
|
|
115
|
+
* Applies a 2D affine transformation to the point. This is commonly used for
|
|
116
|
+
* scaling, rotation, translation, and skewing operations.
|
|
117
|
+
*
|
|
118
|
+
* @param {MatrixLike} m - The transformation matrix to apply
|
|
119
|
+
* @returns {Point} A new transformed point
|
|
120
|
+
* @example
|
|
121
|
+
* ```typescript
|
|
122
|
+
* const p = new Point(10, 20);
|
|
123
|
+
*
|
|
124
|
+
* // Scale by 2x
|
|
125
|
+
* const scaled = p.transform(Matrix.scale(2, 2));
|
|
126
|
+
* console.log(scaled); // Point(20, 40)
|
|
127
|
+
*
|
|
128
|
+
* // Rotate 90 degrees
|
|
129
|
+
* const rotated = p.transform(Matrix.rotate(90));
|
|
130
|
+
* ```
|
|
131
|
+
*/
|
|
132
|
+
transform(m: MatrixLike): Point;
|
|
133
|
+
/**
|
|
134
|
+
* Calculates the Euclidean distance to another point.
|
|
135
|
+
*
|
|
136
|
+
* Uses the Pythagorean theorem to compute the straight-line distance
|
|
137
|
+
* between this point and another point in 2D space.
|
|
138
|
+
*
|
|
139
|
+
* @param {PointLike} other - The point to measure distance to
|
|
140
|
+
* @returns {number} The distance in the same units as the coordinates
|
|
141
|
+
* @example
|
|
142
|
+
* ```typescript
|
|
143
|
+
* const p1 = new Point(0, 0);
|
|
144
|
+
* const p2 = new Point(3, 4);
|
|
145
|
+
* const distance = p1.distanceTo(p2); // 5.0
|
|
146
|
+
*
|
|
147
|
+
* // Distance is symmetric
|
|
148
|
+
* p2.distanceTo(p1) === p1.distanceTo(p2); // true
|
|
149
|
+
* ```
|
|
150
|
+
*/
|
|
151
|
+
distanceTo(other: PointLike): number;
|
|
152
|
+
/**
|
|
153
|
+
* Adds another point to this point (vector addition).
|
|
154
|
+
*
|
|
155
|
+
* Returns a new point whose coordinates are the sum of this point's
|
|
156
|
+
* coordinates and the other point's coordinates.
|
|
157
|
+
*
|
|
158
|
+
* @param {PointLike} other - The point to add
|
|
159
|
+
* @returns {Point} A new point with summed coordinates
|
|
160
|
+
* @example
|
|
161
|
+
* ```typescript
|
|
162
|
+
* const p1 = new Point(10, 20);
|
|
163
|
+
* const p2 = new Point(5, 10);
|
|
164
|
+
* const sum = p1.add(p2);
|
|
165
|
+
* console.log(sum); // Point(15, 30)
|
|
166
|
+
* ```
|
|
167
|
+
*/
|
|
168
|
+
add(other: PointLike): Point;
|
|
169
|
+
/**
|
|
170
|
+
* Subtracts another point from this point (vector subtraction).
|
|
171
|
+
*
|
|
172
|
+
* Returns a new point whose coordinates are the difference between
|
|
173
|
+
* this point's coordinates and the other point's coordinates.
|
|
174
|
+
*
|
|
175
|
+
* @param {PointLike} other - The point to subtract
|
|
176
|
+
* @returns {Point} A new point with the difference
|
|
177
|
+
* @example
|
|
178
|
+
* ```typescript
|
|
179
|
+
* const p1 = new Point(10, 20);
|
|
180
|
+
* const p2 = new Point(5, 10);
|
|
181
|
+
* const diff = p1.subtract(p2);
|
|
182
|
+
* console.log(diff); // Point(5, 10)
|
|
183
|
+
* ```
|
|
184
|
+
*/
|
|
185
|
+
subtract(other: PointLike): Point;
|
|
186
|
+
/**
|
|
187
|
+
* Scales this point by a factor (scalar multiplication).
|
|
188
|
+
*
|
|
189
|
+
* Multiplies both x and y coordinates by the given factor.
|
|
190
|
+
*
|
|
191
|
+
* @param {number} factor - The scaling factor
|
|
192
|
+
* @returns {Point} A new scaled point
|
|
193
|
+
* @example
|
|
194
|
+
* ```typescript
|
|
195
|
+
* const p = new Point(10, 20);
|
|
196
|
+
* const doubled = p.scale(2); // Point(20, 40)
|
|
197
|
+
* const halved = p.scale(0.5); // Point(5, 10)
|
|
198
|
+
* const negated = p.scale(-1); // Point(-10, -20)
|
|
199
|
+
* ```
|
|
200
|
+
*/
|
|
201
|
+
scale(factor: number): Point;
|
|
202
|
+
/**
|
|
203
|
+
* Normalizes this point to unit length.
|
|
204
|
+
*
|
|
205
|
+
* Returns a point in the same direction but with length 1.0.
|
|
206
|
+
* If the point is at the origin (length 0), returns the origin.
|
|
207
|
+
*
|
|
208
|
+
* @returns {Point} A normalized point with length 1.0 (or origin if length is 0)
|
|
209
|
+
* @example
|
|
210
|
+
* ```typescript
|
|
211
|
+
* const p = new Point(3, 4);
|
|
212
|
+
* const normalized = p.normalize();
|
|
213
|
+
* console.log(normalized); // Point(0.6, 0.8)
|
|
214
|
+
* console.log(normalized.length); // 1.0
|
|
215
|
+
*
|
|
216
|
+
* // Origin stays at origin
|
|
217
|
+
* Point.ORIGIN.normalize(); // Point(0, 0)
|
|
218
|
+
* ```
|
|
219
|
+
*/
|
|
220
|
+
normalize(): Point;
|
|
221
|
+
/**
|
|
222
|
+
* Gets the length (magnitude) of this point when treated as a vector.
|
|
223
|
+
*
|
|
224
|
+
* Computes the Euclidean distance from the origin to this point.
|
|
225
|
+
*
|
|
226
|
+
* @readonly
|
|
227
|
+
* @type {number}
|
|
228
|
+
* @example
|
|
229
|
+
* ```typescript
|
|
230
|
+
* const p = new Point(3, 4);
|
|
231
|
+
* console.log(p.length); // 5.0
|
|
232
|
+
*
|
|
233
|
+
* // Right triangle: 3² + 4² = 5²
|
|
234
|
+
* ```
|
|
235
|
+
*/
|
|
236
|
+
get length(): number;
|
|
237
|
+
/**
|
|
238
|
+
* Checks if this point is equal to another point.
|
|
239
|
+
*
|
|
240
|
+
* Two points are considered equal if both their x and y coordinates are exactly equal.
|
|
241
|
+
* Note: This uses strict equality, so floating point precision issues may affect the result.
|
|
242
|
+
*
|
|
243
|
+
* @param {PointLike} other - The point to compare with
|
|
244
|
+
* @returns {boolean} True if the points have identical coordinates
|
|
245
|
+
* @example
|
|
246
|
+
* ```typescript
|
|
247
|
+
* const p1 = new Point(10, 20);
|
|
248
|
+
* const p2 = new Point(10, 20);
|
|
249
|
+
* const p3 = new Point(10, 21);
|
|
250
|
+
*
|
|
251
|
+
* p1.equals(p2); // true
|
|
252
|
+
* p1.equals(p3); // false
|
|
253
|
+
* ```
|
|
254
|
+
*/
|
|
255
|
+
equals(other: PointLike): boolean;
|
|
256
|
+
/**
|
|
257
|
+
* Returns a string representation of the point.
|
|
258
|
+
*
|
|
259
|
+
* @returns {string} A string in the format "Point(x, y)"
|
|
260
|
+
* @example
|
|
261
|
+
* ```typescript
|
|
262
|
+
* const p = new Point(10.5, 20.3);
|
|
263
|
+
* console.log(p.toString()); // "Point(10.5, 20.3)"
|
|
264
|
+
* console.log(String(p)); // "Point(10.5, 20.3)"
|
|
265
|
+
* ```
|
|
266
|
+
*/
|
|
267
|
+
toString(): string;
|
|
268
|
+
}
|
|
269
|
+
/**
|
|
270
|
+
* A rectangle defined by two corner points (floating point)
|
|
271
|
+
*/
|
|
272
|
+
export declare class Rect implements RectLike {
|
|
273
|
+
readonly x0: number;
|
|
274
|
+
readonly y0: number;
|
|
275
|
+
readonly x1: number;
|
|
276
|
+
readonly y1: number;
|
|
277
|
+
constructor(x0: number, y0: number, x1: number, y1: number);
|
|
278
|
+
/** Empty rectangle */
|
|
279
|
+
static readonly EMPTY: Rect;
|
|
280
|
+
/** Infinite rectangle */
|
|
281
|
+
static readonly INFINITE: Rect;
|
|
282
|
+
/** Unit rectangle (0,0) to (1,1) */
|
|
283
|
+
static readonly UNIT: Rect;
|
|
284
|
+
/** Create a rect from a rect-like object */
|
|
285
|
+
static from(r: RectLike): Rect;
|
|
286
|
+
/** Create a rect from position and size */
|
|
287
|
+
static fromXYWH(x: number, y: number, width: number, height: number): Rect;
|
|
288
|
+
/** Create a rect from an IRect */
|
|
289
|
+
static fromIRect(r: IRectLike): Rect;
|
|
290
|
+
/** Width of the rectangle */
|
|
291
|
+
get width(): number;
|
|
292
|
+
/** Height of the rectangle */
|
|
293
|
+
get height(): number;
|
|
294
|
+
/** Check if the rectangle is empty */
|
|
295
|
+
get isEmpty(): boolean;
|
|
296
|
+
/** Check if the rectangle is infinite */
|
|
297
|
+
get isInfinite(): boolean;
|
|
298
|
+
/** Check if a point is inside the rectangle */
|
|
299
|
+
containsPoint(p: PointLike): boolean;
|
|
300
|
+
containsPoint(x: number, y: number): boolean;
|
|
301
|
+
/** Check if this rectangle contains another rectangle */
|
|
302
|
+
containsRect(other: RectLike): boolean;
|
|
303
|
+
/** Union with another rectangle */
|
|
304
|
+
union(other: RectLike): Rect;
|
|
305
|
+
/** Intersection with another rectangle */
|
|
306
|
+
intersect(other: RectLike): Rect;
|
|
307
|
+
/** Expand by including a point */
|
|
308
|
+
includePoint(p: PointLike): Rect;
|
|
309
|
+
/** Translate by offset */
|
|
310
|
+
translate(dx: number, dy: number): Rect;
|
|
311
|
+
/** Scale by factor */
|
|
312
|
+
scale(sx: number, sy?: number): Rect;
|
|
313
|
+
/** Transform by a matrix */
|
|
314
|
+
transform(m: MatrixLike): Rect;
|
|
315
|
+
/** Normalize (ensure x0 <= x1 and y0 <= y1) */
|
|
316
|
+
normalize(): Rect;
|
|
317
|
+
/** Round to integer rectangle */
|
|
318
|
+
round(): IRect;
|
|
319
|
+
/** Check equality */
|
|
320
|
+
equals(other: RectLike): boolean;
|
|
321
|
+
toString(): string;
|
|
322
|
+
}
|
|
323
|
+
/**
|
|
324
|
+
* An integer rectangle defined by two corner points
|
|
325
|
+
*/
|
|
326
|
+
export declare class IRect implements IRectLike {
|
|
327
|
+
readonly x0: number;
|
|
328
|
+
readonly y0: number;
|
|
329
|
+
readonly x1: number;
|
|
330
|
+
readonly y1: number;
|
|
331
|
+
constructor(x0: number, y0: number, x1: number, y1: number);
|
|
332
|
+
/** Empty integer rectangle */
|
|
333
|
+
static readonly EMPTY: IRect;
|
|
334
|
+
/** Infinite integer rectangle */
|
|
335
|
+
static readonly INFINITE: IRect;
|
|
336
|
+
/** Create from a rect-like object */
|
|
337
|
+
static from(r: IRectLike): IRect;
|
|
338
|
+
/** Create from a Rect by rounding */
|
|
339
|
+
static fromRect(r: RectLike): IRect;
|
|
340
|
+
/** Width */
|
|
341
|
+
get width(): number;
|
|
342
|
+
/** Height */
|
|
343
|
+
get height(): number;
|
|
344
|
+
/** Check if empty */
|
|
345
|
+
get isEmpty(): boolean;
|
|
346
|
+
/** Union with another integer rectangle */
|
|
347
|
+
union(other: IRectLike): IRect;
|
|
348
|
+
/** Intersection with another integer rectangle */
|
|
349
|
+
intersect(other: IRectLike): IRect;
|
|
350
|
+
/** Translate by offset */
|
|
351
|
+
translate(dx: number, dy: number): IRect;
|
|
352
|
+
/** Convert to Rect */
|
|
353
|
+
toRect(): Rect;
|
|
354
|
+
/** Check equality */
|
|
355
|
+
equals(other: IRectLike): boolean;
|
|
356
|
+
toString(): string;
|
|
357
|
+
}
|
|
358
|
+
/**
|
|
359
|
+
* A 2D transformation matrix (affine transform)
|
|
360
|
+
*/
|
|
361
|
+
export declare class Matrix implements MatrixLike {
|
|
362
|
+
readonly a: number;
|
|
363
|
+
readonly b: number;
|
|
364
|
+
readonly c: number;
|
|
365
|
+
readonly d: number;
|
|
366
|
+
readonly e: number;
|
|
367
|
+
readonly f: number;
|
|
368
|
+
constructor(a: number, b: number, c: number, d: number, e: number, f: number);
|
|
369
|
+
/** Identity matrix */
|
|
370
|
+
static readonly IDENTITY: Matrix;
|
|
371
|
+
/** Create a matrix from a matrix-like object */
|
|
372
|
+
static from(m: MatrixLike): Matrix;
|
|
373
|
+
/** Create a translation matrix */
|
|
374
|
+
static translate(tx: number, ty: number): Matrix;
|
|
375
|
+
/** Create a scaling matrix */
|
|
376
|
+
static scale(sx: number, sy?: number): Matrix;
|
|
377
|
+
/** Create a rotation matrix (degrees) */
|
|
378
|
+
static rotate(degrees: number): Matrix;
|
|
379
|
+
/** Create a shear matrix */
|
|
380
|
+
static shear(sx: number, sy: number): Matrix;
|
|
381
|
+
/** Check if this is the identity matrix */
|
|
382
|
+
get isIdentity(): boolean;
|
|
383
|
+
/** Check if this is a rectilinear matrix (no rotation/shear) */
|
|
384
|
+
get isRectilinear(): boolean;
|
|
385
|
+
/** Concatenate with another matrix */
|
|
386
|
+
concat(other: MatrixLike): Matrix;
|
|
387
|
+
/** Invert the matrix */
|
|
388
|
+
invert(): Matrix | null;
|
|
389
|
+
/** Pre-translate this matrix */
|
|
390
|
+
preTranslate(tx: number, ty: number): Matrix;
|
|
391
|
+
/** Post-translate this matrix */
|
|
392
|
+
postTranslate(tx: number, ty: number): Matrix;
|
|
393
|
+
/** Pre-scale this matrix */
|
|
394
|
+
preScale(sx: number, sy?: number): Matrix;
|
|
395
|
+
/** Post-scale this matrix */
|
|
396
|
+
postScale(sx: number, sy?: number): Matrix;
|
|
397
|
+
/** Pre-rotate this matrix */
|
|
398
|
+
preRotate(degrees: number): Matrix;
|
|
399
|
+
/** Post-rotate this matrix */
|
|
400
|
+
postRotate(degrees: number): Matrix;
|
|
401
|
+
/** Pre-shear this matrix */
|
|
402
|
+
preShear(sx: number, sy: number): Matrix;
|
|
403
|
+
/** Post-shear this matrix */
|
|
404
|
+
postShear(sx: number, sy: number): Matrix;
|
|
405
|
+
/** Transform a point */
|
|
406
|
+
transformPoint(p: PointLike): Point;
|
|
407
|
+
/** Check equality */
|
|
408
|
+
equals(other: MatrixLike): boolean;
|
|
409
|
+
toString(): string;
|
|
410
|
+
}
|
|
411
|
+
/**
|
|
412
|
+
* A quadrilateral defined by four corner points
|
|
413
|
+
*/
|
|
414
|
+
export declare class Quad implements QuadLike {
|
|
415
|
+
readonly ul: Point;
|
|
416
|
+
readonly ur: Point;
|
|
417
|
+
readonly ll: Point;
|
|
418
|
+
readonly lr: Point;
|
|
419
|
+
constructor(ul: PointLike, ur: PointLike, ll: PointLike, lr: PointLike);
|
|
420
|
+
/** Create a quad from a rectangle */
|
|
421
|
+
static fromRect(r: RectLike): Quad;
|
|
422
|
+
/** Transform this quad by a matrix */
|
|
423
|
+
transform(m: MatrixLike): Quad;
|
|
424
|
+
/** Get the bounding rectangle */
|
|
425
|
+
get bounds(): Rect;
|
|
426
|
+
/** Check if a point is inside the quad */
|
|
427
|
+
containsPoint(p: PointLike): boolean;
|
|
428
|
+
/** Check if this is a valid quad (non-self-intersecting) */
|
|
429
|
+
get isValid(): boolean;
|
|
430
|
+
toString(): string;
|
|
431
|
+
}
|
|
432
|
+
/**
|
|
433
|
+
* Color-like type
|
|
434
|
+
*/
|
|
435
|
+
export type ColorLike = Color | {
|
|
436
|
+
r: number;
|
|
437
|
+
g: number;
|
|
438
|
+
b: number;
|
|
439
|
+
a?: number;
|
|
440
|
+
} | [number, number, number] | [number, number, number, number];
|
|
441
|
+
/**
|
|
442
|
+
* An RGBA color
|
|
443
|
+
*/
|
|
444
|
+
export declare class Color {
|
|
445
|
+
readonly r: number;
|
|
446
|
+
readonly g: number;
|
|
447
|
+
readonly b: number;
|
|
448
|
+
readonly a: number;
|
|
449
|
+
constructor(r: number, g: number, b: number, a?: number);
|
|
450
|
+
/**
|
|
451
|
+
* Create color from color-like object
|
|
452
|
+
*/
|
|
453
|
+
static from(c: ColorLike): Color;
|
|
454
|
+
/** Black color */
|
|
455
|
+
static readonly BLACK: Color;
|
|
456
|
+
/** White color */
|
|
457
|
+
static readonly WHITE: Color;
|
|
458
|
+
/** Red color */
|
|
459
|
+
static readonly RED: Color;
|
|
460
|
+
/** Green color */
|
|
461
|
+
static readonly GREEN: Color;
|
|
462
|
+
/** Blue color */
|
|
463
|
+
static readonly BLUE: Color;
|
|
464
|
+
/**
|
|
465
|
+
* Get as array [r, g, b, a]
|
|
466
|
+
*/
|
|
467
|
+
toArray(): [number, number, number, number];
|
|
468
|
+
}
|
|
469
|
+
//# sourceMappingURL=geometry.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"geometry.d.ts","sourceRoot":"","sources":["../src/geometry.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;GAuBG;AAEH,OAAO,KAAK,EAAE,SAAS,EAAE,QAAQ,EAAE,SAAS,EAAE,UAAU,EAAE,QAAQ,EAAE,MAAM,YAAY,CAAC;AAGvF,YAAY,EAAE,SAAS,EAAE,QAAQ,EAAE,SAAS,EAAE,UAAU,EAAE,QAAQ,EAAE,CAAC;AAErE;;;;;;;;;;;;;;;;;;;;;;;GAuBG;AACH,qBAAa,KAAM,YAAW,SAAS;IACrC;;;;OAIG;IACH,QAAQ,CAAC,CAAC,EAAE,MAAM,CAAC;IAEnB;;;;OAIG;IACH,QAAQ,CAAC,CAAC,EAAE,MAAM,CAAC;IAEnB;;;;;;;;;;;OAWG;gBACS,CAAC,EAAE,MAAM,EAAE,CAAC,EAAE,MAAM;IAShC;;;;;;;;;;;;;OAaG;IACH,MAAM,CAAC,QAAQ,CAAC,MAAM,QAAmB;IAMzC;;;;;;;;;;;;;;;;;;OAkBG;IACH,MAAM,CAAC,IAAI,CAAC,CAAC,EAAE,SAAS,GAAG,KAAK;IAWhC;;;;;;;;;;;;;;;;;;;OAmBG;IACH,SAAS,CAAC,CAAC,EAAE,UAAU,GAAG,KAAK;IAI/B;;;;;;;;;;;;;;;;;OAiBG;IACH,UAAU,CAAC,KAAK,EAAE,SAAS,GAAG,MAAM;IAMpC;;;;;;;;;;;;;;;OAeG;IACH,GAAG,CAAC,KAAK,EAAE,SAAS,GAAG,KAAK;IAI5B;;;;;;;;;;;;;;;OAeG;IAC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