linearly 0.36.1 → 0.37.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.
@@ -1,329 +0,0 @@
1
- import { mat2 } from './mat2';
2
- import { vec2 } from './vec2';
3
- /**
4
- * Represents 2D affine transformation (translation, rotation, scaling, skewing), omitting the redundant third row which is always set to `[0, 0, 1]`. The order of six elements is the same as CSS transform matrix.
5
- *
6
- * A mat2d contains six elements defined as:
7
- * ```ts
8
- * [a, b,
9
- * c, d,
10
- * tx, ty]
11
- * ```
12
- * This is a short form for the {@link mat3}:
13
- * ```ts
14
- * [xx, xy, 0,
15
- * yx, yy, 0,
16
- * tx, ty, 1]
17
- * ```
18
- * The last column is ignored so the array is shorter and operations are faster.
19
- *
20
- * @category Types
21
- * @see https://developer.mozilla.org/en-US/docs/Web/CSS/transform-function/matrix
22
- */
23
- export type mat2d = readonly [
24
- a: number,
25
- b: number,
26
- c: number,
27
- d: number,
28
- tx: number,
29
- ty: number
30
- ];
31
- /**
32
- * Functions for {@link mat2d}, 2D affine transformation (translation, rotation, scaling, skewing).
33
- * @see https://developer.mozilla.org/en-US/docs/Web/CSS/transform-function/matrix
34
- * @category Modules
35
- */
36
- export declare namespace mat2d {
37
- /**
38
- * Mutable version of {@link mat2d}
39
- * @category Types
40
- */
41
- type Mutable = [
42
- a: number,
43
- b: number,
44
- c: number,
45
- d: number,
46
- tx: number,
47
- ty: number
48
- ];
49
- /**
50
- * Creates a new matrix from given elements
51
- * @category Generators
52
- */
53
- function of(a: number, b: number, c: number, d: number, tx: number, ty: number): mat2d;
54
- /**
55
- * Creates a mutable clone of given mat2d
56
- * @category Generators
57
- */
58
- function clone(a: mat2d): Mutable;
59
- /**
60
- * The identity matrix of mat2d
61
- * ```ts
62
- * [1, 0,
63
- * 0, 1,
64
- * 0, 0]
65
- * ```
66
- * @category Constants
67
- *
68
- * @shorthands
69
- * - {@link id}
70
- * - {@link ident}
71
- */
72
- const identity: mat2d;
73
- /**
74
- * Alias for {@link identity}
75
- * @category Shorthands
76
- */
77
- const I: mat2d;
78
- /**
79
- * Alias for {@link identity}
80
- * @category Shorthands
81
- */
82
- const id: mat2d;
83
- /**
84
- * Alias for {@link identity}
85
- * @category Shorthands
86
- */
87
- const ident: mat2d;
88
- /**
89
- * The mat2d matrix filled with zeros.
90
- * @category Constants
91
- */
92
- const zero: mat2d;
93
- /**
94
- * Inverts a mat2d
95
- *
96
- * @shorthands
97
- * - {@link inv}
98
- */
99
- function invert(a: mat2d): mat2d | null;
100
- /**
101
- * Alias for {@link invert}
102
- * @category Shorthands
103
- */
104
- const inv: typeof invert;
105
- /**
106
- * Calculates the determinant of a mat2d
107
- *
108
- * @shorthands
109
- * - {@link det}
110
- */
111
- function determinant(a: mat2d): number;
112
- /**
113
- * Alias for {@link determinant}
114
- * @category Shorthands
115
- */
116
- const det: typeof determinant;
117
- /**
118
- * Multiplies given mat2d's
119
- *
120
- * @shorthands
121
- * - {@link mul}
122
- */
123
- function multiply(...ms: mat2d[]): mat2d;
124
- /**
125
- * Alias for {@link multiply}
126
- * @category Shorthands
127
- */
128
- const mul: typeof multiply;
129
- /**
130
- * Rotates a mat2d by the given angle
131
- */
132
- function rotate(m: mat2d, deg: number, origin?: vec2): mat2d;
133
- /**
134
- * Scales the mat2d by the dimensions in the given vec2
135
- **/
136
- function scale(m: mat2d, s: vec2, origin?: vec2): mat2d;
137
- /**
138
- * Translates the mat2d by the dimensions in the given vec2
139
- **/
140
- function translate(m: mat2d, v: vec2): mat2d;
141
- /**
142
- * Applies a transformation around a given origin point
143
- */
144
- function pivot(m: mat2d, origin: vec2): mat2d;
145
- /**
146
- * Applies skew to the mat2d by the given angles in degrees
147
- * @see https://developer.mozilla.org/en-US/docs/Web/CSS/transform-function/skew
148
- */
149
- function skew(m: mat2d, deg: vec2, origin: vec2): mat2d;
150
- /**
151
- * Creates a matrix from a given angle.
152
- * @param deg The angle to rotate the matrix by, in degrees
153
- * @category Generators
154
- *
155
- * @shorthands
156
- * - {@link rotation}
157
- */
158
- function fromRotation(deg: number, origin?: vec2): mat2d;
159
- /**
160
- * Alias for {@link fromRotation}
161
- * @category Shorthands
162
- */
163
- const rotation: typeof fromRotation;
164
- /**
165
- * Creates a matrix from a vector scaling
166
- * @category Generators
167
- *
168
- * @shorthands
169
- * - {@link scaling}
170
- */
171
- function fromScaling(v: vec2 | number, origin?: vec2): mat2d;
172
- /**
173
- * Alias for {@link fromScaling}
174
- * @category Shorthands
175
- */
176
- const scaling: typeof fromScaling;
177
- /**
178
- * Creates a matrix from a vector translation
179
- * @category Generators
180
- *
181
- * @shorthands
182
- * - {@link translation}
183
- */
184
- function fromTranslation(v: vec2 | number): mat2d;
185
- /**
186
- * Alias for {@link fromTranslation}
187
- * @category Shorthands
188
- */
189
- const translation: typeof fromTranslation;
190
- /**
191
- * Creates a matrix from a vector skew
192
- * https://developer.mozilla.org/en-US/docs/Web/CSS/transform-function/skew
193
- * @category Generators
194
- *
195
- * @shorthands
196
- * - {@link skewing}
197
- */
198
- function fromSkew(deg: vec2, origin?: vec2): mat2d;
199
- /**
200
- * Alias for {@link fromSkew}
201
- * @category Shorthands
202
- */
203
- const skewing: typeof fromSkew;
204
- /**
205
- * Computes a fixed point of the given matrix.
206
- * @param m The matrix to compute a fixed point of
207
- * @returns The fixed point of the given matrix, or null if the matrix is not invertible
208
- */
209
- function fixedPoint(m: mat2d): vec2 | null;
210
- /**
211
- * Returns Frobenius norm of a mat2d
212
- */
213
- function frob(a: mat2d): number;
214
- /**
215
- * Adds given mat2d's
216
- */
217
- function add(...ms: mat2d[]): mat2d;
218
- /**
219
- * Subtracts matrix b from matrix a
220
- *
221
- * @shorthands
222
- * - {@link sub}
223
- */
224
- function subtract(...ms: mat2d[]): mat2d;
225
- /**
226
- * Alias for {@link subtract}
227
- * @category Shorthands
228
- */
229
- const sub: typeof subtract;
230
- /**
231
- * Subtracts b from a
232
- */
233
- function delta(a: mat2d, b: mat2d): mat2d;
234
- /**
235
- * Multiply each element of the matrix by a scalar.
236
- */
237
- function multiplyScalar(a: mat2d, s: number): mat2d;
238
- /**
239
- Adds given mat2d's after multiplying each element of the second operand by a scalar value.
240
- */
241
- function multiplyScalarAndAdd(a: mat2d, b: mat2d, scale: number): mat2d;
242
- /**
243
- * Constrain each element to lie between min and max
244
- * @see https://thebookofshaders.com/glossary/?search=clamp
245
- */
246
- function clamp(a: mat2d, min: number, max: number): mat2d;
247
- /**
248
- * Clamps each element to [0, 1]
249
- */
250
- function clamp01(a: mat2d): mat2d;
251
- /**
252
- * Clamps each element to [-1, 1]
253
- */
254
- function clamp11(a: mat2d): mat2d;
255
- /**
256
- * Creates a matrix that maps from the given points to another. If the third point is not given, the orthogonal matrix is returned.
257
- * ```text
258
- * f-s f'-s'
259
- * |/ ---M--> |/
260
- * t t'
261
- * ```
262
- * @category Generators
263
- * @param first a pair of first point
264
- * @param second a pair of second point
265
- * @param third a pair of third point
266
- */
267
- function fromPoints(first: [vec2, vec2], second: [vec2, vec2], third?: [vec2, vec2]): mat2d | null;
268
- /**
269
- * Creates a matrix from given translation, rotation, and scaling. The order of the transformations is translation, rotation, and scaling, like most of the graphics software.
270
- * @param t Translation vector
271
- * @param r Rotation angle in degrees
272
- * @param s Scaling vector or a number
273
- * @returns The matrix that represents the transformation
274
- *
275
- * @shorthands
276
- * - {@link trs}
277
- */
278
- function fromTRS(t?: vec2 | null, r?: number | null, s?: vec2 | number | null): mat2d;
279
- /**
280
- * Alias for {@link fromTRS}
281
- * @category Shorthands
282
- */
283
- const trs: typeof fromTRS;
284
- /**
285
- * Copies a the values from {@link mat2}, assuming the translation component is `[0, 0]`
286
- * @param m The matrix to convert
287
- * @returns The newly created matrix
288
- * @category Generators
289
- */
290
- function fromMat2(m: mat2): mat2d;
291
- /**
292
- * Returns whether or not the matrices have exactly the same elements in the same position (when compared with `===`)
293
- *
294
- * @shorthands
295
- * - {@link eq}
296
- */
297
- function exactEquals(a: mat2d, b: mat2d): boolean;
298
- /**
299
- * Alias for {@link exactEquals}
300
- * @category Shorthands
301
- */
302
- const eq: typeof exactEquals;
303
- /**
304
- * Returns whether or not the matrices have approximately the same elements in the same position.
305
- *
306
- * @shorthands
307
- * - {@link approx}
308
- * - {@link equals}
309
- */
310
- function approxEquals(a: mat2d, b: mat2d): boolean;
311
- /**
312
- * Alias for {@link approxEquals}
313
- * @category Shorthands
314
- */
315
- const approx: typeof approxEquals;
316
- /**
317
- * Alias for {@link approxEquals}. This is provided for compatibility with gl-matrix.
318
- * @category Shorthands
319
- * @deprecated Use {@link approxEquals} instead
320
- */
321
- const equals: typeof approxEquals;
322
- /**
323
- * Returns a string representation of a mat2d
324
- * @param m matrix to represent as a string
325
- * @param fractionDigits number of digits to appear after the decimal point
326
- */
327
- const toString: (m: mat2d, fractionDigits?: number) => string;
328
- }
329
- //# sourceMappingURL=mat2d.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"mat2d.d.ts","sourceRoot":"","sources":["../../src/mat2d.ts"],"names":[],"mappings":"AACA,OAAO,EAAC,IAAI,EAAC,MAAM,QAAQ,CAAA;AAC3B,OAAO,EAAC,IAAI,EAAC,MAAM,QAAQ,CAAA;AAE3B;;;;;;;;;;;;;;;;;;;GAmBG;AAEH,MAAM,MAAM,KAAK,GAAG,SAAS;IAC5B,CAAC,EAAE,MAAM;IAAE,CAAC,EAAE,MAAM;IACpB,CAAC,EAAE,MAAM;IAAE,CAAC,EAAE,MAAM;IACpB,EAAE,EAAE,MAAM;IAAE,EAAE,EAAE,MAAM;CACtB,CAAA;AAED;;;;GAIG;AACH,yBAAiB,KAAK,CAAC;IACtB;;;OAGG;IAEH,KAAY,OAAO,GAAG;QACrB,CAAC,EAAE,MAAM;QAAE,CAAC,EAAE,MAAM;QACpB,CAAC,EAAE,MAAM;QAAE,CAAC,EAAE,MAAM;QACpB,EAAE,EAAE,MAAM;QAAE,EAAE,EAAE,MAAM;KACtB,CAAA;IAED;;;OAGG;IAEH,SAAgB,EAAE,CACjB,CAAC,EA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