@shopify/react-native-skia 0.1.227 → 0.1.229
Sign up to get free protection for your applications and to get access to all the features.
- package/cpp/api/JsiSkCanvas.h +2 -1
- package/cpp/api/JsiSkMatrix.h +27 -11
- package/cpp/api/JsiSkTypeface.h +1 -0
- package/cpp/rnskia/dom/props/MatrixProp.h +14 -3
- package/lib/commonjs/dom/types/Common.d.ts +2 -2
- package/lib/commonjs/dom/types/Common.js.map +1 -1
- package/lib/commonjs/external/reanimated/interpolators.d.ts +1 -0
- package/lib/commonjs/external/reanimated/interpolators.js +16 -3
- package/lib/commonjs/external/reanimated/interpolators.js.map +1 -1
- package/lib/commonjs/external/reanimated/moduleWrapper.d.ts +2 -1
- package/lib/commonjs/external/reanimated/moduleWrapper.js +9 -7
- package/lib/commonjs/external/reanimated/moduleWrapper.js.map +1 -1
- package/lib/commonjs/renderer/Canvas.js +7 -13
- package/lib/commonjs/renderer/Canvas.js.map +1 -1
- package/lib/commonjs/skia/core/Vector.d.ts +0 -5
- package/lib/commonjs/skia/core/Vector.js +1 -17
- package/lib/commonjs/skia/core/Vector.js.map +1 -1
- package/lib/commonjs/skia/types/Canvas.d.ts +2 -2
- package/lib/commonjs/skia/types/Canvas.js.map +1 -1
- package/lib/commonjs/skia/types/Matrix.d.ts +3 -13
- package/lib/commonjs/skia/types/Matrix.js +1 -16
- package/lib/commonjs/skia/types/Matrix.js.map +1 -1
- package/lib/commonjs/skia/types/Matrix4.d.ts +60 -1
- package/lib/commonjs/skia/types/Matrix4.js +159 -14
- package/lib/commonjs/skia/types/Matrix4.js.map +1 -1
- package/lib/commonjs/skia/types/Path/Path.d.ts +2 -2
- package/lib/commonjs/skia/types/Path/Path.js.map +1 -1
- package/lib/commonjs/skia/web/Host.d.ts +2 -3
- package/lib/commonjs/skia/web/Host.js +4 -12
- package/lib/commonjs/skia/web/Host.js.map +1 -1
- package/lib/commonjs/skia/web/JsiSkCanvas.js +12 -12
- package/lib/commonjs/skia/web/JsiSkCanvas.js.map +1 -1
- package/lib/commonjs/skia/web/JsiSkColorFilterFactory.js +1 -1
- package/lib/commonjs/skia/web/JsiSkColorFilterFactory.js.map +1 -1
- package/lib/commonjs/skia/web/JsiSkFont.js +2 -2
- package/lib/commonjs/skia/web/JsiSkFont.js.map +1 -1
- package/lib/commonjs/skia/web/JsiSkImage.js +6 -6
- package/lib/commonjs/skia/web/JsiSkImage.js.map +1 -1
- package/lib/commonjs/skia/web/JsiSkImageFactory.js +2 -2
- package/lib/commonjs/skia/web/JsiSkImageFactory.js.map +1 -1
- package/lib/commonjs/skia/web/JsiSkImageFilterFactory.js +3 -3
- package/lib/commonjs/skia/web/JsiSkImageFilterFactory.js.map +1 -1
- package/lib/commonjs/skia/web/JsiSkMaskFilterFactory.js +1 -1
- package/lib/commonjs/skia/web/JsiSkMaskFilterFactory.js.map +1 -1
- package/lib/commonjs/skia/web/JsiSkMatrix.d.ts +2 -2
- package/lib/commonjs/skia/web/JsiSkMatrix.js +6 -1
- package/lib/commonjs/skia/web/JsiSkMatrix.js.map +1 -1
- package/lib/commonjs/skia/web/JsiSkPaint.js +3 -3
- package/lib/commonjs/skia/web/JsiSkPaint.js.map +1 -1
- package/lib/commonjs/skia/web/JsiSkPath.js +4 -4
- package/lib/commonjs/skia/web/JsiSkPath.js.map +1 -1
- package/lib/commonjs/skia/web/JsiSkPathEffectFactory.js +1 -1
- package/lib/commonjs/skia/web/JsiSkPathEffectFactory.js.map +1 -1
- package/lib/commonjs/skia/web/JsiSkPathFactory.js +1 -1
- package/lib/commonjs/skia/web/JsiSkPathFactory.js.map +1 -1
- package/lib/commonjs/skia/web/JsiSkPicture.js +1 -1
- package/lib/commonjs/skia/web/JsiSkPicture.js.map +1 -1
- package/lib/commonjs/skia/web/JsiSkShaderFactory.js +5 -5
- package/lib/commonjs/skia/web/JsiSkShaderFactory.js.map +1 -1
- package/lib/commonjs/skia/web/JsiSkVerticesFactory.js +3 -3
- package/lib/commonjs/skia/web/JsiSkVerticesFactory.js.map +1 -1
- package/lib/module/dom/types/Common.d.ts +2 -2
- package/lib/module/dom/types/Common.js.map +1 -1
- package/lib/module/external/reanimated/interpolators.d.ts +1 -0
- package/lib/module/external/reanimated/interpolators.js +14 -4
- package/lib/module/external/reanimated/interpolators.js.map +1 -1
- package/lib/module/external/reanimated/moduleWrapper.d.ts +2 -1
- package/lib/module/external/reanimated/moduleWrapper.js +7 -6
- package/lib/module/external/reanimated/moduleWrapper.js.map +1 -1
- package/lib/module/renderer/Canvas.js +7 -12
- package/lib/module/renderer/Canvas.js.map +1 -1
- package/lib/module/skia/core/Vector.d.ts +0 -5
- package/lib/module/skia/core/Vector.js +0 -13
- package/lib/module/skia/core/Vector.js.map +1 -1
- package/lib/module/skia/types/Canvas.d.ts +2 -2
- package/lib/module/skia/types/Canvas.js.map +1 -1
- package/lib/module/skia/types/Matrix.d.ts +3 -13
- package/lib/module/skia/types/Matrix.js +0 -14
- package/lib/module/skia/types/Matrix.js.map +1 -1
- package/lib/module/skia/types/Matrix4.d.ts +60 -1
- package/lib/module/skia/types/Matrix4.js +132 -18
- package/lib/module/skia/types/Matrix4.js.map +1 -1
- package/lib/module/skia/types/Path/Path.d.ts +2 -2
- package/lib/module/skia/types/Path/Path.js.map +1 -1
- package/lib/module/skia/web/Host.d.ts +2 -3
- package/lib/module/skia/web/Host.js +2 -7
- package/lib/module/skia/web/Host.js.map +1 -1
- package/lib/module/skia/web/JsiSkCanvas.js +13 -13
- package/lib/module/skia/web/JsiSkCanvas.js.map +1 -1
- package/lib/module/skia/web/JsiSkColorFilterFactory.js +2 -2
- package/lib/module/skia/web/JsiSkColorFilterFactory.js.map +1 -1
- package/lib/module/skia/web/JsiSkFont.js +3 -3
- package/lib/module/skia/web/JsiSkFont.js.map +1 -1
- package/lib/module/skia/web/JsiSkImage.js +7 -7
- package/lib/module/skia/web/JsiSkImage.js.map +1 -1
- package/lib/module/skia/web/JsiSkImageFactory.js +3 -3
- package/lib/module/skia/web/JsiSkImageFactory.js.map +1 -1
- package/lib/module/skia/web/JsiSkImageFilterFactory.js +4 -4
- package/lib/module/skia/web/JsiSkImageFilterFactory.js.map +1 -1
- package/lib/module/skia/web/JsiSkMaskFilterFactory.js +2 -2
- package/lib/module/skia/web/JsiSkMaskFilterFactory.js.map +1 -1
- package/lib/module/skia/web/JsiSkMatrix.d.ts +2 -2
- package/lib/module/skia/web/JsiSkMatrix.js +6 -1
- package/lib/module/skia/web/JsiSkMatrix.js.map +1 -1
- package/lib/module/skia/web/JsiSkPaint.js +4 -4
- package/lib/module/skia/web/JsiSkPaint.js.map +1 -1
- package/lib/module/skia/web/JsiSkPath.js +5 -5
- package/lib/module/skia/web/JsiSkPath.js.map +1 -1
- package/lib/module/skia/web/JsiSkPathEffectFactory.js +2 -2
- package/lib/module/skia/web/JsiSkPathEffectFactory.js.map +1 -1
- package/lib/module/skia/web/JsiSkPathFactory.js +2 -2
- package/lib/module/skia/web/JsiSkPathFactory.js.map +1 -1
- package/lib/module/skia/web/JsiSkPicture.js +2 -2
- package/lib/module/skia/web/JsiSkPicture.js.map +1 -1
- package/lib/module/skia/web/JsiSkShaderFactory.js +6 -6
- package/lib/module/skia/web/JsiSkShaderFactory.js.map +1 -1
- package/lib/module/skia/web/JsiSkVerticesFactory.js +2 -2
- package/lib/module/skia/web/JsiSkVerticesFactory.js.map +1 -1
- package/lib/typescript/src/dom/types/Common.d.ts +2 -2
- package/lib/typescript/src/external/reanimated/interpolators.d.ts +1 -0
- package/lib/typescript/src/external/reanimated/moduleWrapper.d.ts +2 -1
- package/lib/typescript/src/skia/core/Vector.d.ts +0 -5
- package/lib/typescript/src/skia/types/Canvas.d.ts +2 -2
- package/lib/typescript/src/skia/types/Matrix.d.ts +3 -13
- package/lib/typescript/src/skia/types/Matrix4.d.ts +60 -1
- package/lib/typescript/src/skia/types/Path/Path.d.ts +2 -2
- package/lib/typescript/src/skia/web/Host.d.ts +2 -3
- package/lib/typescript/src/skia/web/JsiSkMatrix.d.ts +2 -2
- package/package.json +2 -1
- package/src/dom/types/Common.ts +2 -2
- package/src/external/reanimated/interpolators.ts +20 -5
- package/src/external/reanimated/moduleWrapper.ts +6 -0
- package/src/renderer/Canvas.tsx +6 -13
- package/src/skia/core/Vector.ts +0 -7
- package/src/skia/types/Canvas.ts +2 -2
- package/src/skia/types/Matrix.ts +4 -13
- package/src/skia/types/Matrix4.ts +190 -81
- package/src/skia/types/Path/Path.ts +2 -2
- package/src/skia/web/Host.ts +4 -3
- package/src/skia/web/JsiSkCanvas.ts +22 -15
- package/src/skia/web/JsiSkColorFilterFactory.ts +5 -2
- package/src/skia/web/JsiSkFont.ts +3 -3
- package/src/skia/web/JsiSkImage.ts +14 -11
- package/src/skia/web/JsiSkImageFactory.ts +3 -3
- package/src/skia/web/JsiSkImageFilterFactory.ts +5 -5
- package/src/skia/web/JsiSkMaskFilterFactory.ts +6 -2
- package/src/skia/web/JsiSkMatrix.ts +12 -3
- package/src/skia/web/JsiSkPaint.ts +4 -4
- package/src/skia/web/JsiSkPath.ts +8 -5
- package/src/skia/web/JsiSkPathEffectFactory.ts +2 -2
- package/src/skia/web/JsiSkPathFactory.ts +2 -2
- package/src/skia/web/JsiSkPicture.ts +4 -4
- package/src/skia/web/JsiSkShaderFactory.ts +6 -6
- package/src/skia/web/JsiSkVerticesFactory.ts +2 -2
@@ -1,5 +1,20 @@
|
|
1
|
+
type Point = {
|
2
|
+
x: number;
|
3
|
+
y: number;
|
4
|
+
};
|
1
5
|
type Vec2 = readonly [number, number];
|
2
6
|
type Vec3 = readonly [number, number, number];
|
7
|
+
export type Matrix3 = readonly [
|
8
|
+
number,
|
9
|
+
number,
|
10
|
+
number,
|
11
|
+
number,
|
12
|
+
number,
|
13
|
+
number,
|
14
|
+
number,
|
15
|
+
number,
|
16
|
+
number
|
17
|
+
];
|
3
18
|
export type Matrix4 = readonly [
|
4
19
|
number,
|
5
20
|
number,
|
@@ -28,6 +43,14 @@ export type Transforms3d = Transform3d[];
|
|
28
43
|
* @worklet
|
29
44
|
*/
|
30
45
|
export declare const Matrix4: () => Matrix4;
|
46
|
+
/**
|
47
|
+
* @worklet
|
48
|
+
*/
|
49
|
+
export declare const translate: (x: number, y: number, z?: number) => Matrix4;
|
50
|
+
/**
|
51
|
+
* @worklet
|
52
|
+
*/
|
53
|
+
export declare const perspective: (p: number) => Matrix4;
|
31
54
|
/**
|
32
55
|
* @worklet
|
33
56
|
*/
|
@@ -35,5 +58,41 @@ export declare const mapPoint3d: (m: Matrix4, v: Vec3) => readonly [number, numb
|
|
35
58
|
/**
|
36
59
|
* @worklet
|
37
60
|
*/
|
38
|
-
export declare const
|
61
|
+
export declare const multiply4: (a: Matrix4, b: Matrix4) => Matrix4;
|
62
|
+
/**
|
63
|
+
* @worklet
|
64
|
+
*/
|
65
|
+
export declare const toMatrix3: (m: Matrix4) => number[];
|
66
|
+
/**
|
67
|
+
* @worklet
|
68
|
+
*/
|
69
|
+
export declare const pivot: (m: Matrix4, p: Point) => Matrix4;
|
70
|
+
/**
|
71
|
+
* @worklet
|
72
|
+
*/
|
73
|
+
export declare const scale: (sx: number, sy: number, sz?: number, p?: Point) => Matrix4;
|
74
|
+
/**
|
75
|
+
* @worklet
|
76
|
+
*/
|
77
|
+
export declare const rotateZ: (value: number, p?: Point) => Matrix4;
|
78
|
+
/**
|
79
|
+
* @worklet
|
80
|
+
*/
|
81
|
+
export declare const rotateX: (value: number, p?: Point) => Matrix4;
|
82
|
+
/**
|
83
|
+
* @worklet
|
84
|
+
*/
|
85
|
+
export declare const rotateY: (value: number, p?: Point) => Matrix4;
|
86
|
+
/**
|
87
|
+
* @worklet
|
88
|
+
*/
|
89
|
+
export declare const processTransform3d: (transforms: Transforms3d) => Matrix4;
|
90
|
+
/**
|
91
|
+
* @worklet
|
92
|
+
*/
|
93
|
+
export declare const convertToColumnMajor: (rowMajorMatrix: Matrix4) => number[];
|
94
|
+
/**
|
95
|
+
* @worklet
|
96
|
+
*/
|
97
|
+
export declare const convertToAffineMatrix: (m4: number[]) => number[];
|
39
98
|
export {};
|
@@ -3,7 +3,7 @@
|
|
3
3
|
Object.defineProperty(exports, "__esModule", {
|
4
4
|
value: true
|
5
5
|
});
|
6
|
-
exports.processTransform3d = exports.mapPoint3d = exports.Matrix4 = void 0;
|
6
|
+
exports.translate = exports.toMatrix3 = exports.scale = exports.rotateZ = exports.rotateY = exports.rotateX = exports.processTransform3d = exports.pivot = exports.perspective = exports.multiply4 = exports.mapPoint3d = exports.convertToColumnMajor = exports.convertToAffineMatrix = exports.Matrix4 = void 0;
|
7
7
|
|
8
8
|
const exhaustiveCheck = a => {
|
9
9
|
"worklet";
|
@@ -20,20 +20,25 @@ const Matrix4 = () => {
|
|
20
20
|
|
21
21
|
return [1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1];
|
22
22
|
};
|
23
|
+
/**
|
24
|
+
* @worklet
|
25
|
+
*/
|
26
|
+
|
23
27
|
|
24
28
|
exports.Matrix4 = Matrix4;
|
25
29
|
|
26
|
-
const translate = (x, y
|
30
|
+
const translate = function (x, y) {
|
27
31
|
"worklet";
|
28
32
|
|
33
|
+
let z = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : 0;
|
29
34
|
return [1, 0, 0, x, 0, 1, 0, y, 0, 0, 1, z, 0, 0, 0, 1];
|
30
35
|
};
|
36
|
+
/**
|
37
|
+
* @worklet
|
38
|
+
*/
|
31
39
|
|
32
|
-
const scale = (sx, sy, sz) => {
|
33
|
-
"worklet";
|
34
40
|
|
35
|
-
|
36
|
-
};
|
41
|
+
exports.translate = translate;
|
37
42
|
|
38
43
|
const perspective = p => {
|
39
44
|
"worklet";
|
@@ -41,6 +46,8 @@ const perspective = p => {
|
|
41
46
|
return [1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, -1 / p, 1];
|
42
47
|
};
|
43
48
|
|
49
|
+
exports.perspective = perspective;
|
50
|
+
|
44
51
|
const normalizeVec = vec => {
|
45
52
|
"worklet";
|
46
53
|
|
@@ -66,12 +73,6 @@ const rotatedUnitSinCos = (axisVec, sinAngle, cosAngle) => {
|
|
66
73
|
return [t * x * x + c, t * x * y - s * z, t * x * z + s * y, 0, t * x * y + s * z, t * y * y + c, t * y * z - s * x, 0, t * x * z - s * y, t * y * z + s * x, t * z * z + c, 0, 0, 0, 0, 1];
|
67
74
|
};
|
68
75
|
|
69
|
-
const rotate = (axis, value) => {
|
70
|
-
"worklet";
|
71
|
-
|
72
|
-
return rotatedUnitSinCos(normalizeVec(axis), Math.sin(value), Math.cos(value));
|
73
|
-
};
|
74
|
-
|
75
76
|
const matrixVecMul4 = (m, v) => {
|
76
77
|
"worklet";
|
77
78
|
|
@@ -89,6 +90,10 @@ const mapPoint3d = (m, v) => {
|
|
89
90
|
const r = matrixVecMul4(m, [...v, 1]);
|
90
91
|
return [r[0] / r[3], r[1] / r[3], r[2] / r[3]];
|
91
92
|
};
|
93
|
+
/**
|
94
|
+
* @worklet
|
95
|
+
*/
|
96
|
+
|
92
97
|
|
93
98
|
exports.mapPoint3d = mapPoint3d;
|
94
99
|
|
@@ -106,6 +111,8 @@ const multiply4 = (a, b) => {
|
|
106
111
|
return result;
|
107
112
|
};
|
108
113
|
|
114
|
+
exports.multiply4 = multiply4;
|
115
|
+
|
109
116
|
const skewY = angle => {
|
110
117
|
"worklet";
|
111
118
|
|
@@ -117,21 +124,113 @@ const skewX = angle => {
|
|
117
124
|
|
118
125
|
return [1, 0, 0, 0, Math.tan(angle), 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1];
|
119
126
|
};
|
127
|
+
/**
|
128
|
+
* @worklet
|
129
|
+
*/
|
130
|
+
|
120
131
|
|
121
132
|
const toMatrix3 = m => {
|
122
133
|
"worklet";
|
123
134
|
|
124
135
|
return [m[0], m[1], m[3], m[4], m[5], m[7], m[12], m[13], m[15]];
|
125
136
|
};
|
137
|
+
|
138
|
+
exports.toMatrix3 = toMatrix3;
|
139
|
+
|
140
|
+
const rotate = (axis, value) => {
|
141
|
+
"worklet";
|
142
|
+
|
143
|
+
return rotatedUnitSinCos(normalizeVec(axis), Math.sin(value), Math.cos(value));
|
144
|
+
};
|
126
145
|
/**
|
127
146
|
* @worklet
|
128
147
|
*/
|
129
148
|
|
130
149
|
|
150
|
+
const pivot = (m, p) => {
|
151
|
+
"worklet";
|
152
|
+
|
153
|
+
return multiply4(translate(p.x, p.y), multiply4(m, translate(-p.x, -p.y)));
|
154
|
+
};
|
155
|
+
/**
|
156
|
+
* @worklet
|
157
|
+
*/
|
158
|
+
|
159
|
+
|
160
|
+
exports.pivot = pivot;
|
161
|
+
|
162
|
+
const scale = function (sx, sy) {
|
163
|
+
"worklet";
|
164
|
+
|
165
|
+
let sz = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : 1;
|
166
|
+
let p = arguments.length > 3 ? arguments[3] : undefined;
|
167
|
+
const m4 = [sx, 0, 0, 0, 0, sy, 0, 0, 0, 0, sz, 0, 0, 0, 0, 1];
|
168
|
+
|
169
|
+
if (p) {
|
170
|
+
return pivot(m4, p);
|
171
|
+
}
|
172
|
+
|
173
|
+
return m4;
|
174
|
+
};
|
175
|
+
|
176
|
+
exports.scale = scale;
|
177
|
+
|
178
|
+
const rotateAxis = (axis, angle, p) => {
|
179
|
+
"worklet";
|
180
|
+
|
181
|
+
const result = rotate(axis, angle);
|
182
|
+
|
183
|
+
if (p) {
|
184
|
+
return pivot(result, p);
|
185
|
+
}
|
186
|
+
|
187
|
+
return result;
|
188
|
+
};
|
189
|
+
/**
|
190
|
+
* @worklet
|
191
|
+
*/
|
192
|
+
|
193
|
+
|
194
|
+
const rotateZ = (value, p) => {
|
195
|
+
"worklet";
|
196
|
+
|
197
|
+
return rotateAxis([0, 0, 1], value, p);
|
198
|
+
};
|
199
|
+
/**
|
200
|
+
* @worklet
|
201
|
+
*/
|
202
|
+
|
203
|
+
|
204
|
+
exports.rotateZ = rotateZ;
|
205
|
+
|
206
|
+
const rotateX = (value, p) => {
|
207
|
+
"worklet";
|
208
|
+
|
209
|
+
return rotateAxis([1, 0, 0], value, p);
|
210
|
+
};
|
211
|
+
/**
|
212
|
+
* @worklet
|
213
|
+
*/
|
214
|
+
|
215
|
+
|
216
|
+
exports.rotateX = rotateX;
|
217
|
+
|
218
|
+
const rotateY = (value, p) => {
|
219
|
+
"worklet";
|
220
|
+
|
221
|
+
return rotateAxis([0, 1, 0], value, p);
|
222
|
+
};
|
223
|
+
/**
|
224
|
+
* @worklet
|
225
|
+
*/
|
226
|
+
|
227
|
+
|
228
|
+
exports.rotateY = rotateY;
|
229
|
+
|
131
230
|
const processTransform3d = transforms => {
|
132
231
|
"worklet";
|
133
232
|
|
134
|
-
return
|
233
|
+
return transforms.reduce((acc, val) => {
|
135
234
|
const key = Object.keys(val)[0];
|
136
235
|
const transform = val;
|
137
236
|
|
@@ -206,8 +305,54 @@ const processTransform3d = transforms => {
|
|
206
305
|
}
|
207
306
|
|
208
307
|
return exhaustiveCheck(key);
|
209
|
-
}, Matrix4())
|
308
|
+
}, Matrix4());
|
210
309
|
};
|
310
|
+
/**
|
311
|
+
* @worklet
|
312
|
+
*/
|
313
|
+
|
211
314
|
|
212
315
|
exports.processTransform3d = processTransform3d;
|
316
|
+
|
317
|
+
const convertToColumnMajor = rowMajorMatrix => {
|
318
|
+
"worklet";
|
319
|
+
|
320
|
+
const colMajorMatrix = new Array(16);
|
321
|
+
const size = 4;
|
322
|
+
|
323
|
+
for (let row = 0; row < size; row++) {
|
324
|
+
for (let col = 0; col < size; col++) {
|
325
|
+
colMajorMatrix[col * size + row] = rowMajorMatrix[row * size + col];
|
326
|
+
}
|
327
|
+
}
|
328
|
+
|
329
|
+
return colMajorMatrix;
|
330
|
+
};
|
331
|
+
/**
|
332
|
+
* @worklet
|
333
|
+
*/
|
334
|
+
|
335
|
+
|
336
|
+
exports.convertToColumnMajor = convertToColumnMajor;
|
337
|
+
|
338
|
+
const convertToAffineMatrix = m4 => {
|
339
|
+
"worklet"; // Extracting the relevant components from the 4x4 matrix
|
340
|
+
|
341
|
+
const a = m4[0]; // Scale X
|
342
|
+
|
343
|
+
const b = m4[1]; // Skew Y
|
344
|
+
|
345
|
+
const c = m4[4]; // Skew X
|
346
|
+
|
347
|
+
const d = m4[5]; // Scale Y
|
348
|
+
|
349
|
+
const tx = m4[12]; // Translate X
|
350
|
+
|
351
|
+
const ty = m4[13]; // Translate Y
|
352
|
+
// Returning the 6-element affine transformation matrix
|
353
|
+
|
354
|
+
return [a, b, c, d, tx, ty];
|
355
|
+
};
|
356
|
+
|
357
|
+
exports.convertToAffineMatrix = convertToAffineMatrix;
|
213
358
|
//# sourceMappingURL=Matrix4.js.map
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"names":["exhaustiveCheck","a","Error","Matrix4","translate","x","y","z","scale","sx","sy","sz","perspective","p","normalizeVec","vec","length","Math","sqrt","rotatedUnitSinCos","axisVec","sinAngle","cosAngle","c","s","t","rotate","axis","value","sin","cos","matrixVecMul4","m","v","vx","vy","vz","vw","mapPoint3d","r","multiply4","b","result","Array","fill","i","j","skewY","angle","tan","skewX","toMatrix3","processTransform3d","transforms","reduce","acc","val","key","Object","keys","transform"],"sources":["Matrix4.ts"],"sourcesContent":["type Vec2 = readonly [number, number];\ntype Vec3 = readonly [number, number, number];\ntype Vec4 = readonly [number, number, number, number];\n\nexport type Matrix4 = readonly [\n number,\n number,\n number,\n number,\n number,\n number,\n number,\n number,\n number,\n number,\n number,\n number,\n number,\n number,\n number,\n number\n];\n\ntype Transform3dName =\n | \"translateX\"\n | \"translateY\"\n | \"translateZ\"\n | \"translate\"\n | \"scale\"\n | \"scaleX\"\n | \"scaleY\"\n | \"skewX\"\n | \"skewY\"\n | \"rotateZ\"\n | \"rotate\"\n | \"perspective\"\n | \"rotateX\"\n | \"rotateY\"\n | \"matrix\";\n\ntype Transformations = {\n [Name in Transform3dName]: Name extends \"matrix\"\n ? Matrix4\n : Name extends \"translate\"\n ? Vec3 | Vec2\n : number;\n};\n\ntype Transform3d =\n | Pick<Transformations, \"translateX\">\n | Pick<Transformations, \"translateY\">\n | Pick<Transformations, \"translateZ\">\n | Pick<Transformations, \"translate\">\n | Pick<Transformations, \"scale\">\n | Pick<Transformations, \"scaleX\">\n | Pick<Transformations, \"scaleY\">\n | Pick<Transformations, \"skewX\">\n | Pick<Transformations, \"skewY\">\n | Pick<Transformations, \"perspective\">\n | Pick<Transformations, \"rotateX\">\n | Pick<Transformations, \"rotateY\">\n | Pick<Transformations, \"rotateZ\">\n | Pick<Transformations, \"rotate\">\n | Pick<Transformations, \"matrix\">;\n\nexport type Transforms3d = Transform3d[];\n\nconst exhaustiveCheck = (a: never): never => {\n \"worklet\";\n throw new Error(`Unexhaustive handling for ${a}`);\n};\n\n/**\n * @worklet\n */\nexport const Matrix4 = (): Matrix4 => {\n \"worklet\";\n return [1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1];\n};\n\nconst translate = (x: number, y: number, z: number): Matrix4 => {\n \"worklet\";\n return [1, 0, 0, x, 0, 1, 0, y, 0, 0, 1, z, 0, 0, 0, 1];\n};\n\nconst scale = (sx: number, sy: number, sz: number): Matrix4 => {\n \"worklet\";\n return [sx, 0, 0, 0, 0, sy, 0, 0, 0, 0, sz, 0, 0, 0, 0, 1];\n};\n\nconst perspective = (p: number): Matrix4 => {\n \"worklet\";\n return [1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, -1 / p, 1];\n};\n\nconst normalizeVec = (vec: Vec3): Vec3 => {\n \"worklet\";\n const [x, y, z] = vec;\n const length = Math.sqrt(x * x + y * y + z * z);\n // Check for zero length to avoid division by zero\n if (length === 0) {\n return [0, 0, 0];\n }\n return [x / length, y / length, z / length];\n};\n\nconst rotatedUnitSinCos = (\n axisVec: Vec3,\n sinAngle: number,\n cosAngle: number\n): Matrix4 => {\n \"worklet\";\n const x = axisVec[0];\n const y = axisVec[1];\n const z = axisVec[2];\n const c = cosAngle;\n const s = sinAngle;\n const t = 1 - c;\n return [\n t * x * x + c,\n t * x * y - s * z,\n t * x * z + s * y,\n 0,\n t * x * y + s * z,\n t * y * y + c,\n t * y * z - s * x,\n 0,\n t * x * z - s * y,\n t * y * z + s * x,\n t * z * z + c,\n 0,\n 0,\n 0,\n 0,\n 1,\n ];\n};\n\nconst rotate = (axis: Vec3, value: number) => {\n \"worklet\";\n return rotatedUnitSinCos(\n normalizeVec(axis),\n Math.sin(value),\n Math.cos(value)\n );\n};\n\nconst matrixVecMul4 = (m: Matrix4, v: Vec4) => {\n \"worklet\";\n const [vx, vy, vz, vw] = v;\n return [\n vx * m[0] + vy * m[4] + vz * m[8] + vw * m[12],\n vx * m[1] + vy * m[5] + vz * m[9] + vw * m[13],\n vx * m[2] + vy * m[6] + vz * m[10] + vw * m[14],\n vx * m[3] + vy * m[7] + vz * m[11] + vw * m[15],\n ];\n};\n\n/**\n * @worklet\n */\nexport const mapPoint3d = (m: Matrix4, v: Vec3) => {\n \"worklet\";\n const r = matrixVecMul4(m, [...v, 1]);\n return [r[0] / r[3], r[1] / r[3], r[2] / r[3]] as const;\n};\n\nconst multiply4 = (a: Matrix4, b: Matrix4): Matrix4 => {\n \"worklet\";\n const result = new Array(16).fill(0);\n for (let i = 0; i < 4; i++) {\n for (let j = 0; j < 4; j++) {\n result[i * 4 + j] =\n a[i * 4] * b[j] +\n a[i * 4 + 1] * b[j + 4] +\n a[i * 4 + 2] * b[j + 8] +\n a[i * 4 + 3] * b[j + 12];\n }\n }\n return result as unknown as Matrix4;\n};\n\nconst skewY = (angle: number): Matrix4 => {\n \"worklet\";\n return [1, Math.tan(angle), 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1];\n};\n\nconst skewX = (angle: number): Matrix4 => {\n \"worklet\";\n return [1, 0, 0, 0, Math.tan(angle), 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1];\n};\n\nconst toMatrix3 = (m: Matrix4) => {\n \"worklet\";\n return [m[0], m[1], m[3], m[4], m[5], m[7], m[12], m[13], m[15]];\n};\n\n/**\n * @worklet\n */\nexport const processTransform3d = (transforms: Transforms3d) => {\n \"worklet\";\n return toMatrix3(\n transforms.reduce((acc, val) => {\n const key = Object.keys(val)[0] as Transform3dName;\n const transform = val as Pick<Transformations, typeof key>;\n if (key === \"translateX\") {\n const value = transform[key];\n return multiply4(acc, translate(value, 0, 0));\n }\n if (key === \"translate\") {\n const [x, y, z = 0] = transform[key];\n return multiply4(acc, translate(x, y, z));\n }\n if (key === \"translateY\") {\n const value = transform[key];\n return multiply4(acc, translate(0, value, 0));\n }\n if (key === \"translateZ\") {\n const value = transform[key];\n return multiply4(acc, translate(0, 0, value));\n }\n if (key === \"scale\") {\n const value = transform[key];\n return multiply4(acc, scale(value, value, 1));\n }\n if (key === \"scaleX\") {\n const value = transform[key];\n return multiply4(acc, scale(value, 1, 1));\n }\n if (key === \"scaleY\") {\n const value = transform[key];\n return multiply4(acc, scale(1, value, 1));\n }\n if (key === \"skewX\") {\n const value = transform[key];\n return multiply4(acc, skewX(value));\n }\n if (key === \"skewY\") {\n const value = transform[key];\n return multiply4(acc, skewY(value));\n }\n if (key === \"rotateX\") {\n const value = transform[key];\n return multiply4(acc, rotate([1, 0, 0], value));\n }\n if (key === \"rotateY\") {\n const value = transform[key];\n return multiply4(acc, rotate([0, 1, 0], value));\n }\n if (key === \"perspective\") {\n const value = transform[key];\n return multiply4(acc, perspective(value));\n }\n if (key === \"rotate\" || key === \"rotateZ\") {\n const value = transform[key];\n return multiply4(acc, rotate([0, 0, 1], value));\n }\n if (key === \"matrix\") {\n const value = transform[key];\n return multiply4(acc, value);\n }\n return exhaustiveCheck(key);\n }, Matrix4())\n );\n};\n"],"mappings":";;;;;;;AAmEA,MAAMA,eAAe,GAAIC,CAAD,IAAqB;EAC3C;;EACA,MAAM,IAAIC,KAAJ,CAAW,6BAA4BD,CAAE,EAAzC,CAAN;AACD,CAHD;AAKA;AACA;AACA;;;AACO,MAAME,OAAO,GAAG,MAAe;EACpC;;EACA,OAAO,CAAC,CAAD,EAAI,CAAJ,EAAO,CAAP,EAA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;MACzB,MAAM7B,KAAK,GAAGgC,SAAS,CAACH,GAAD,CAAvB;MACA,OAAOjB,SAAS,CAACe,GAAD,EAAM3C,WAAW,CAACgB,KAAD,CAAjB,CAAhB;IACD;;IACD,IAAI6B,GAAG,KAAK,QAAR,IAAoBA,GAAG,KAAK,SAAhC,EAA2C;MACzC,MAAM7B,KAAK,GAAGgC,SAAS,CAACH,GAAD,CAAvB;MACA,OAAOjB,SAAS,CAACe,GAAD,EAAM7B,MAAM,CAAC,CAAC,CAAD,EAAI,CAAJ,EAAO,CAAP,CAAD,EAAYE,KAAZ,CAAZ,CAAhB;IACD;;IACD,IAAI6B,GAAG,KAAK,QAAZ,EAAsB;MACpB,MAAM7B,KAAK,GAAGgC,SAAS,CAACH,GAAD,CAAvB;MACA,OAAOjB,SAAS,CAACe,GAAD,EAAM3B,KAAN,CAAhB;IACD;;IACD,OAAO5B,eAAe,CAACyD,GAAD,CAAtB;EACD,CA5DD,EA4DGtD,OAAO,EA5DV,CADc,CAAhB;AA+DD,CAjEM"}
|
1
|
+
{"version":3,"names":["exhaustiveCheck","a","Error","Matrix4","translate","x","y","z","perspective","p","normalizeVec","vec","length","Math","sqrt","rotatedUnitSinCos","axisVec","sinAngle","cosAngle","c","s","t","matrixVecMul4","m","v","vx","vy","vz","vw","mapPoint3d","r","multiply4","b","result","Array","fill","i","j","skewY","angle","tan","skewX","toMatrix3","rotate","axis","value","sin","cos","pivot","scale","sx","sy","sz","m4","rotateAxis","rotateZ","rotateX","rotateY","processTransform3d","transforms","reduce","acc","val","key","Object","keys","transform","convertToColumnMajor","rowMajorMatrix","colMajorMatrix","size","row","col","convertToAffineMatrix","d","tx","ty"],"sources":["Matrix4.ts"],"sourcesContent":["type Point = { x: number; y: number };\ntype Vec2 = readonly [number, number];\ntype Vec3 = readonly [number, number, number];\ntype Vec4 = readonly [number, number, number, number];\n\nexport type Matrix3 = readonly [\n number,\n number,\n number,\n number,\n number,\n number,\n number,\n number,\n number\n];\n\nexport type Matrix4 = readonly [\n number,\n number,\n number,\n number,\n number,\n number,\n number,\n number,\n number,\n number,\n number,\n number,\n number,\n number,\n number,\n number\n];\n\ntype Transform3dName =\n | \"translateX\"\n | \"translateY\"\n | \"translateZ\"\n | \"translate\"\n | \"scale\"\n | \"scaleX\"\n | \"scaleY\"\n | \"skewX\"\n | \"skewY\"\n | \"rotateZ\"\n | \"rotate\"\n | \"perspective\"\n | \"rotateX\"\n | \"rotateY\"\n | \"matrix\";\n\ntype Transformations = {\n [Name in Transform3dName]: Name extends \"matrix\"\n ? Matrix4\n : Name extends \"translate\"\n ? Vec3 | Vec2\n : number;\n};\n\ntype Transform3d =\n | Pick<Transformations, \"translateX\">\n | Pick<Transformations, \"translateY\">\n | Pick<Transformations, \"translateZ\">\n | Pick<Transformations, \"translate\">\n | Pick<Transformations, \"scale\">\n | Pick<Transformations, \"scaleX\">\n | Pick<Transformations, \"scaleY\">\n | Pick<Transformations, \"skewX\">\n | Pick<Transformations, \"skewY\">\n | Pick<Transformations, \"perspective\">\n | Pick<Transformations, \"rotateX\">\n | Pick<Transformations, \"rotateY\">\n | Pick<Transformations, \"rotateZ\">\n | Pick<Transformations, \"rotate\">\n | Pick<Transformations, \"matrix\">;\n\nexport type Transforms3d = Transform3d[];\n\nconst exhaustiveCheck = (a: never): never => {\n \"worklet\";\n throw new Error(`Unexhaustive handling for ${a}`);\n};\n\n/**\n * @worklet\n */\nexport const Matrix4 = (): Matrix4 => {\n \"worklet\";\n return [1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1];\n};\n\n/**\n * @worklet\n */\nexport const translate = (x: number, y: number, z: number = 0): Matrix4 => {\n \"worklet\";\n return [1, 0, 0, x, 0, 1, 0, y, 0, 0, 1, z, 0, 0, 0, 1];\n};\n\n/**\n * @worklet\n */\nexport const perspective = (p: number): Matrix4 => {\n \"worklet\";\n return [1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, -1 / p, 1];\n};\n\nconst normalizeVec = (vec: Vec3): Vec3 => {\n \"worklet\";\n const [x, y, z] = vec;\n const length = Math.sqrt(x * x + y * y + z * z);\n // Check for zero length to avoid division by zero\n if (length === 0) {\n return [0, 0, 0];\n }\n return [x / length, y / length, z / length];\n};\n\nconst rotatedUnitSinCos = (\n axisVec: Vec3,\n sinAngle: number,\n cosAngle: number\n): Matrix4 => {\n \"worklet\";\n const x = axisVec[0];\n const y = axisVec[1];\n const z = axisVec[2];\n const c = cosAngle;\n const s = sinAngle;\n const t = 1 - c;\n return [\n t * x * x + c,\n t * x * y - s * z,\n t * x * z + s * y,\n 0,\n t * x * y + s * z,\n t * y * y + c,\n t * y * z - s * x,\n 0,\n t * x * z - s * y,\n t * y * z + s * x,\n t * z * z + c,\n 0,\n 0,\n 0,\n 0,\n 1,\n ];\n};\n\nconst matrixVecMul4 = (m: Matrix4, v: Vec4) => {\n \"worklet\";\n const [vx, vy, vz, vw] = v;\n return [\n vx * m[0] + vy * m[4] + vz * m[8] + vw * m[12],\n vx * m[1] + vy * m[5] + vz * m[9] + vw * m[13],\n vx * m[2] + vy * m[6] + vz * m[10] + vw * m[14],\n vx * m[3] + vy * m[7] + vz * m[11] + vw * m[15],\n ];\n};\n\n/**\n * @worklet\n */\nexport const mapPoint3d = (m: Matrix4, v: Vec3) => {\n \"worklet\";\n const r = matrixVecMul4(m, [...v, 1]);\n return [r[0] / r[3], r[1] / r[3], r[2] / r[3]] as const;\n};\n\n/**\n * @worklet\n */\nexport const multiply4 = (a: Matrix4, b: Matrix4): Matrix4 => {\n \"worklet\";\n const result = new Array(16).fill(0);\n for (let i = 0; i < 4; i++) {\n for (let j = 0; j < 4; j++) {\n result[i * 4 + j] =\n a[i * 4] * b[j] +\n a[i * 4 + 1] * b[j + 4] +\n a[i * 4 + 2] * b[j + 8] +\n a[i * 4 + 3] * b[j + 12];\n }\n }\n return result as unknown as Matrix4;\n};\n\nconst skewY = (angle: number): Matrix4 => {\n \"worklet\";\n return [1, Math.tan(angle), 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1];\n};\n\nconst skewX = (angle: number): Matrix4 => {\n \"worklet\";\n return [1, 0, 0, 0, Math.tan(angle), 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1];\n};\n\n/**\n * @worklet\n */\nexport const toMatrix3 = (m: Matrix4) => {\n \"worklet\";\n return [m[0], m[1], m[3], m[4], m[5], m[7], m[12], m[13], m[15]];\n};\n\nconst rotate = (axis: Vec3, value: number) => {\n \"worklet\";\n return rotatedUnitSinCos(\n normalizeVec(axis),\n Math.sin(value),\n Math.cos(value)\n );\n};\n\n/**\n * @worklet\n */\nexport const pivot = (m: Matrix4, p: Point) => {\n \"worklet\";\n return multiply4(translate(p.x, p.y), multiply4(m, translate(-p.x, -p.y)));\n};\n\n/**\n * @worklet\n */\nexport const scale = (\n sx: number,\n sy: number,\n sz: number = 1,\n p?: Point\n): Matrix4 => {\n \"worklet\";\n const m4: Matrix4 = [sx, 0, 0, 0, 0, sy, 0, 0, 0, 0, sz, 0, 0, 0, 0, 1];\n if (p) {\n return pivot(m4, p);\n }\n return m4;\n};\n\nconst rotateAxis = (axis: Vec3, angle: number, p?: Point) => {\n \"worklet\";\n const result = rotate(axis, angle);\n if (p) {\n return pivot(result, p);\n }\n return result;\n};\n\n/**\n * @worklet\n */\nexport const rotateZ = (value: number, p?: Point) => {\n \"worklet\";\n return rotateAxis([0, 0, 1], value, p);\n};\n\n/**\n * @worklet\n */\nexport const rotateX = (value: number, p?: Point) => {\n \"worklet\";\n return rotateAxis([1, 0, 0], value, p);\n};\n\n/**\n * @worklet\n */\nexport const rotateY = (value: number, p?: Point) => {\n \"worklet\";\n return rotateAxis([0, 1, 0], value, p);\n};\n\n/**\n * @worklet\n */\nexport const processTransform3d = (transforms: Transforms3d) => {\n \"worklet\";\n return transforms.reduce((acc, val) => {\n const key = Object.keys(val)[0] as Transform3dName;\n const transform = val as Pick<Transformations, typeof key>;\n if (key === \"translateX\") {\n const value = transform[key];\n return multiply4(acc, translate(value, 0, 0));\n }\n if (key === \"translate\") {\n const [x, y, z = 0] = transform[key];\n return multiply4(acc, translate(x, y, z));\n }\n if (key === \"translateY\") {\n const value = transform[key];\n return multiply4(acc, translate(0, value, 0));\n }\n if (key === \"translateZ\") {\n const value = transform[key];\n return multiply4(acc, translate(0, 0, value));\n }\n if (key === \"scale\") {\n const value = transform[key];\n return multiply4(acc, scale(value, value, 1));\n }\n if (key === \"scaleX\") {\n const value = transform[key];\n return multiply4(acc, scale(value, 1, 1));\n }\n if (key === \"scaleY\") {\n const value = transform[key];\n return multiply4(acc, scale(1, value, 1));\n }\n if (key === \"skewX\") {\n const value = transform[key];\n return multiply4(acc, skewX(value));\n }\n if (key === \"skewY\") {\n const value = transform[key];\n return multiply4(acc, skewY(value));\n }\n if (key === \"rotateX\") {\n const value = transform[key];\n return multiply4(acc, rotate([1, 0, 0], value));\n }\n if (key === \"rotateY\") {\n const value = transform[key];\n return multiply4(acc, rotate([0, 1, 0], value));\n }\n if (key === \"perspective\") {\n const value = transform[key];\n return multiply4(acc, perspective(value));\n }\n if (key === \"rotate\" || key === \"rotateZ\") {\n const value = transform[key];\n return multiply4(acc, rotate([0, 0, 1], value));\n }\n if (key === \"matrix\") {\n const value = transform[key];\n return multiply4(acc, value);\n }\n return exhaustiveCheck(key);\n }, Matrix4());\n};\n\n/**\n * @worklet\n */\nexport const convertToColumnMajor = (rowMajorMatrix: Matrix4) => {\n \"worklet\";\n\n const colMajorMatrix = new Array<number>(16);\n const size = 4;\n for (let row = 0; row < size; row++) {\n for (let col = 0; col < size; col++) {\n colMajorMatrix[col * size + row] = rowMajorMatrix[row * size + col];\n }\n }\n return colMajorMatrix;\n};\n\n/**\n * @worklet\n */\nexport const convertToAffineMatrix = (m4: number[]) => {\n \"worklet\";\n // Extracting the relevant components from the 4x4 matrix\n const a = m4[0]; // Scale X\n const b = m4[1]; // Skew Y\n const c = m4[4]; // Skew X\n const d = m4[5]; // Scale Y\n const tx = m4[12]; // Translate X\n const ty = m4[13]; // Translate Y\n\n // Returning the 6-element affine transformation matrix\n return [a, b, c, d, tx, ty];\n};\n"],"mappings":";;;;;;;AAgFA,MAAMA,eAAe,GAAIC,CAAD,IAAqB;EAC3C;;EACA,MAAM,IAAIC,KAAJ,CAAW,6BAA4BD,CAAE,EAAzC,CAAN;AACD,CAHD;AAKA;AACA;AACA;;;AACO,MAAME,OAAO,GAAG,MAAe;EACpC;;EACA,OAAO,CAAC,CAAD,EAAI,CAAJ,EAAO,CAAP,EAAU,CAAV,EAAa,CAAb,EAAgB,CAAhB,EAAmB,CAAnB,EAAsB,CAAtB,EAAyB,CAAzB,EAA4B,CAA5B,EAA+B,CAA/B,EAAkC,CAAlC,EAAqC,CAArC,EAAwC,CAAxC,EAA2C,CAA3C,EAA8C,CAA9C,CAAP;AACD,CAHM;AAKP;AACA;AACA;;;;;AACO,MAAMC,SAAS,GAAG,UAACC,CAAD,EAAYC,CAAZ,EAAkD;EACzE;;EADyE,IAA3BC,CAA2B,uEAAf,CAAe;EAEzE,OAAO,CAAC,CAAD,EAAI,CAAJ,EAAO,CAAP,EAAUF,CAAV,EAAa,CAAb,EAAgB,CAAhB,EAAmB,CAAnB,EAAsBC,CAAtB,EAAyB,CAAzB,EAA4B,CAA5B,EAA+B,CAA/B,EAAkCC,CAAlC,EAAqC,CAArC,EAAwC,CAAxC,EAA2C,CAA3C,EAA8C,CAA9C,CAAP;AACD,CAHM;AAKP;AACA;AACA;;;;;AACO,MAAMC,WAAW,GAAIC,CAAD,IAAwB;EACjD;;EACA,OAAO,CAAC,CAAD,EAAI,CAAJ,EAAO,CAAP,EAAU,CAAV,EAAa,CAAb,EAAgB,CAAhB,EAAmB,CAAnB,EAAsB,CAAtB,EAAyB,CAAzB,EAA4B,CAA5B,EAA+B,CAA/B,EAAkC,CAAlC,EAAqC,CAArC,EAAwC,CAAxC,EAA2C,CAAC,CAAD,GAAKA,CAAhD,EAAmD,CAAnD,CAAP;AACD,CAHM;;;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AoB,GAAIC,cAAD,IAA6B;EAC/D;;EAEA,MAAMC,cAAc,GAAG,IAAInC,KAAJ,CAAkB,EAAlB,CAAvB;EACA,MAAMoC,IAAI,GAAG,CAAb;;EACA,KAAK,IAAIC,GAAG,GAAG,CAAf,EAAkBA,GAAG,GAAGD,IAAxB,EAA8BC,GAAG,EAAjC,EAAqC;IACnC,KAAK,IAAIC,GAAG,GAAG,CAAf,EAAkBA,GAAG,GAAGF,IAAxB,EAA8BE,GAAG,EAAjC,EAAqC;MACnCH,cAAc,CAACG,GAAG,GAAGF,IAAN,GAAaC,GAAd,CAAd,GAAmCH,cAAc,CAACG,GAAG,GAAGD,IAAN,GAAaE,GAAd,CAAjD;IACD;EACF;;EACD,OAAOH,cAAP;AACD,CAXM;AAaP;AACA;AACA;;;;;AACO,MAAMI,qBAAqB,GAAIpB,EAAD,IAAkB;EACrD,UADqD,CAErD;;EACA,MAAMpD,CAAC,GAAGoD,EAAE,CAAC,CAAD,CAAZ,CAHqD,CAGpC;;EACjB,MAAMrB,CAAC,GAAGqB,EAAE,CAAC,CAAD,CAAZ,CAJqD,CAIpC;;EACjB,MAAMlC,CAAC,GAAGkC,EAAE,CAAC,CAAD,CAAZ,CALqD,CAKpC;;EACjB,MAAMqB,CAAC,GAAGrB,EAAE,CAAC,CAAD,CAAZ,CANqD,CAMpC;;EACjB,MAAMsB,EAAE,GAAGtB,EAAE,CAAC,EAAD,CAAb,CAPqD,CAOlC;;EACnB,MAAMuB,EAAE,GAAGvB,EAAE,CAAC,EAAD,CAAb,CARqD,CAQlC;EAEnB;;EACA,OAAO,CAACpD,CAAD,EAAI+B,CAAJ,EAAOb,CAAP,EAAUuD,CAAV,EAAaC,EAAb,EAAiBC,EAAjB,CAAP;AACD,CAZM"}
|
@@ -2,7 +2,7 @@ import type { SkRect } from "../Rect";
|
|
2
2
|
import type { SkPoint } from "../Point";
|
3
3
|
import type { SkRRect } from "../RRect";
|
4
4
|
import type { StrokeJoin, StrokeCap } from "../Paint";
|
5
|
-
import type { SkMatrix } from "../Matrix";
|
5
|
+
import type { InputMatrix, SkMatrix } from "../Matrix";
|
6
6
|
import type { SkJSIInstance } from "../JsiInstance";
|
7
7
|
/**
|
8
8
|
* Options used for Path.stroke(). If an option is omitted, a sensible default will be used.
|
@@ -440,7 +440,7 @@ export interface SkPath extends SkJSIInstance<"Path"> {
|
|
440
440
|
/**
|
441
441
|
* Transforms the path by the specified matrix.
|
442
442
|
*/
|
443
|
-
transform(m3:
|
443
|
+
transform(m3: InputMatrix): SkPath;
|
444
444
|
/**
|
445
445
|
* Interpolates between Path with point array of equal size.
|
446
446
|
* Copy verb array and weights to result, and set result path to a weighted
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"names":["FillType","PathOp","PathVerb","isPath","obj","__typename__"],"sources":["Path.ts"],"sourcesContent":["import type { SkRect } from \"../Rect\";\nimport type { SkPoint } from \"../Point\";\nimport type { SkRRect } from \"../RRect\";\nimport type { StrokeJoin, StrokeCap } from \"../Paint\";\nimport type { SkMatrix } from \"../Matrix\";\nimport type { SkJSIInstance } from \"../JsiInstance\";\n\n/**\n * Options used for Path.stroke(). If an option is omitted, a sensible default will be used.\n */\nexport interface StrokeOpts {\n /** The width of the stroked lines. */\n width?: number;\n miter_limit?: number;\n /**\n * if > 1, increase precision, else if (0 < resScale < 1) reduce precision to\n * favor speed and size\n */\n precision?: number;\n join?: StrokeJoin;\n cap?: StrokeCap;\n}\n\nexport enum FillType {\n Winding,\n EvenOdd,\n InverseWinding,\n InverseEvenOdd,\n}\n\nexport enum PathOp {\n Difference, //!< subtract the op path from the first path\n Intersect, //!< intersect the two paths\n Union, //!< union (inclusive-or) the two paths\n XOR, //!< exclusive-or the two paths\n ReverseDifference,\n}\n\nexport enum PathVerb {\n Move,\n Line,\n Quad,\n Conic,\n Cubic,\n Close,\n}\n\nexport type PathCommand = number[];\n\nexport const isPath = (obj: SkJSIInstance<string> | null): obj is SkPath =>\n obj !== null && obj.__typename__ === \"Path\";\n\nexport interface SkPath extends SkJSIInstance<\"Path\"> {\n /**\n * Appends arc to Path, as the start of new contour. Arc added is part of ellipse\n * bounded by oval, from startAngle through sweepAngle. Both startAngle and\n * sweepAngle are measured in degrees, where zero degrees is aligned with the\n * positive x-axis, and positive sweeps extends arc clockwise.\n * Returns the modified path for easier chaining.\n * @param oval\n * @param startAngle\n * @param sweepAngle\n */\n addArc(\n oval: SkRect,\n startAngleInDegrees: number,\n sweepAngleInDegrees: number\n ): SkPath;\n\n /**\n * Adds oval to Path, appending kMove_Verb, four kConic_Verb, and kClose_Verb.\n * Oval is upright ellipse bounded by Rect oval with radii equal to half oval width\n * and half oval height. Oval begins at start and continues clockwise by default.\n * Returns the modified path for easier chaining.\n * @param oval\n * @param isCCW - if the path should be drawn counter-clockwise or not\n * @param startIndex - index of initial point of ellipse\n */\n addOval(oval: SkRect, isCCW?: boolean, startIndex?: number): SkPath;\n\n /**\n * Returns the number of points in this path. Initially zero.\n */\n countPoints(): number;\n\n /**\n * Adds contour created from array of n points, adding (count - 1) line segments.\n * Contour added starts at pts[0], then adds a line for every additional point\n * in pts array. If close is true, appends kClose_Verb to Path, connecting\n * pts[count - 1] and pts[0].\n * Returns the modified path for easier chaining.\n * @param points\n * @param close - if true, will add a line connecting last point to the first point.\n */\n addPoly(points: SkPoint[], close: boolean): SkPath;\n\n /** Adds beginning of contour at SkPoint (x, y).\n\n @param x x-axis value of contour start\n @param y y-axis value of contour start\n @return reference to SkPath\n\n example: https://fiddle.skia.org/c/@Path_moveTo\n */\n moveTo(x: number, y: number): SkPath;\n /** Adds line from last point to (x, y). If SkPath is empty, or last SkPath::Verb is\n kClose_Verb, last point is set to (0, 0) before adding line.\n\n lineTo() appends kMove_Verb to verb array and (0, 0) to SkPoint array, if needed.\n lineTo() then appends kLine_Verb to verb array and (x, y) to SkPoint array.\n\n @param x end of added line on x-axis\n @param y end of added line on y-axis\n @return reference to SkPath\n\n example: https://fiddle.skia.org/c/@Path_lineTo\n */\n lineTo(x: number, y: number): SkPath;\n\n /**\n * Returns a new path that covers the same area as the original path, but with the\n * Winding FillType. This may re-draw some contours in the path as counter-clockwise\n * instead of clockwise to achieve that effect. If such a transformation cannot\n * be done, null is returned.\n */\n makeAsWinding(): SkPath | null;\n\n /**\n * Translates all the points in the path by dx, dy.\n * @param dx\n * @param dy\n */\n offset(dx: number, dy: number): SkPath;\n\n /**\n * Relative version of arcToRotated.\n * @param rx\n * @param ry\n * @param xAxisRotate\n * @param useSmallArc\n * @param isCCW\n * @param dx\n * @param dy\n */\n rArcTo(\n rx: number,\n ry: number,\n xAxisRotateInDegrees: number,\n useSmallArc: boolean,\n isCCW: boolean,\n dx: number,\n dy: number\n ): SkPath;\n\n /**\n * Relative version of conicTo.\n * @param dx1\n * @param dy1\n * @param dx2\n * @param dy2\n * @param w\n */\n rConicTo(\n dx1: number,\n dy1: number,\n dx2: number,\n dy2: number,\n w: number\n ): SkPath;\n\n /**\n * Relative version of cubicTo.\n * @param cpx1\n * @param cpy1\n * @param cpx2\n * @param cpy2\n * @param x\n * @param y\n */\n rCubicTo(\n cpx1: number,\n cpy1: number,\n cpx2: number,\n cpy2: number,\n x: number,\n y: number\n ): SkPath;\n\n /**\n * Relative version of moveTo.\n * @param x\n * @param y\n */\n rMoveTo(x: number, y: number): SkPath;\n\n /**\n * Relative version of lineTo.\n * @param x\n * @param y\n */\n rLineTo(x: number, y: number): SkPath;\n\n /**\n * Relative version of quadTo.\n * @param x1\n * @param y1\n * @param x2\n * @param y2\n */\n rQuadTo(x1: number, y1: number, x2: number, y2: number): SkPath;\n\n /**\n * Sets FillType, the rule used to fill Path.\n * @param fill\n */\n setFillType(fill: FillType): SkPath;\n\n /**\n * Specifies whether Path is volatile; whether it will be altered or discarded\n * by the caller after it is drawn. Path by default have volatile set false.\n *\n * Mark animating or temporary paths as volatile to improve performance.\n * Mark unchanging Path non-volatile to improve repeated rendering.\n * @param volatile\n */\n setIsVolatile(volatile: boolean): SkPath;\n\n /**\n * Turns this path into the filled equivalent of the stroked path. Returns false if the operation\n * fails (e.g. the path is a hairline).\n * @param opts - describe how stroked path should look.\n * If such a transformation cannot be done, null is returned.\n */\n stroke(opts?: StrokeOpts): null | SkPath;\n\n /**\n * Appends CLOSE_VERB to Path. A closed contour connects the first and last point\n * with a line, forming a continuous loop.\n */\n close(): SkPath;\n\n /**\n * Sets Path to its initial state.\n * Removes verb array, point array, and weights, and sets FillType to Winding.\n * Internal storage associated with Path is released\n */\n reset(): SkPath;\n\n /**\n * Sets Path to its initial state.\n * Removes verb array, point array, and weights, and sets FillType to Winding.\n * Internal storage associated with Path is *not* released.\n * Use rewind() instead of reset() if Path storage will be reused and performance\n * is critical.\n */\n rewind(): SkPath;\n\n /**\n * Returns minimum and maximum axes values of the lines and curves in Path.\n * Returns (0, 0, 0, 0) if Path contains no points.\n * Returned bounds width and height may be larger or smaller than area affected\n * when Path is drawn.\n *\n * Behaves identically to getBounds() when Path contains\n * only lines. If Path contains curves, computed bounds includes\n * the maximum extent of the quad, conic, or cubic; is slower than getBounds();\n * and unlike getBounds(), does not cache the result.\n */\n computeTightBounds(): SkRect;\n\n /**\n * Appends arc to Path. Arc added is part of ellipse\n * bounded by oval, from startAngle through sweepAngle. Both startAngle and\n * sweepAngle are measured in degrees, where zero degrees is aligned with the\n * positive x-axis, and positive sweeps extends arc clockwise.\n * Returns the modified path for easier chaining.\n * @param oval\n * @param startAngleInDegrees\n * @param sweepAngleInDegrees\n * @param forceMoveTo\n */\n arcToOval(\n oval: SkRect,\n startAngleInDegrees: number,\n sweepAngleInDegrees: number,\n forceMoveTo: boolean\n ): SkPath;\n\n /**\n * Appends arc to Path. Arc is implemented by one or more conics weighted to\n * describe part of oval with radii (rx, ry) rotated by xAxisRotate degrees. Arc\n * curves from last Path Point to (x, y), choosing one of four possible routes:\n * clockwise or counterclockwise, and smaller or larger. See SkPath.h for more details.\n * Returns the modified path for easier chaining.\n * @param rx\n * @param ry\n * @param xAxisRotate\n * @param useSmallArc\n * @param isCCW\n * @param x\n * @param y\n */\n arcToRotated(\n rx: number,\n ry: number,\n xAxisRotateInDegrees: number,\n useSmallArc: boolean,\n isCCW: boolean,\n x: number,\n y: number\n ): SkPath;\n\n /**\n * Appends arc to Path, after appending line if needed. Arc is implemented by conic\n * weighted to describe part of circle. Arc is contained by tangent from\n * last Path point to (x1, y1), and tangent from (x1, y1) to (x2, y2). Arc\n * is part of circle sized to radius, positioned so it touches both tangent lines.\n * Returns the modified path for easier chaining.\n * @param x1\n * @param y1\n * @param x2\n * @param y2\n * @param radius\n */\n arcToTangent(\n x1: number,\n y1: number,\n x2: number,\n y2: number,\n radius: number\n ): SkPath;\n\n /**\n * Adds conic from last point towards (x1, y1), to (x2, y2), weighted by w.\n * If Path is empty, or path is closed, the last point is set to (0, 0)\n * before adding conic.\n * Returns the modified path for easier chaining.\n * @param x1\n * @param y1\n * @param x2\n * @param y2\n * @param w\n */\n conicTo(x1: number, y1: number, x2: number, y2: number, w: number): SkPath;\n\n /**\n * Returns true if the point (x, y) is contained by Path, taking into\n * account FillType.\n * @param x\n * @param y\n */\n contains(x: number, y: number): boolean;\n\n /**\n * Returns a copy of this Path.\n */\n copy(): SkPath;\n\n /**\n * Adds cubic from last point towards (x1, y1), then towards (x2, y2), ending at\n * (x3, y3). If Path is empty, or path is closed, the last point is set to\n * (0, 0) before adding cubic.\n * @param cpx1\n * @param cpy1\n * @param cpx2\n * @param cpy2\n * @param x\n * @param y\n */\n cubicTo(\n cpx1: number,\n cpy1: number,\n cpx2: number,\n cpy2: number,\n x: number,\n y: number\n ): SkPath;\n\n /**\n * Changes this path to be the dashed version of itself. This is the same effect as creating\n * a DashPathEffect and calling filterPath on this path.\n * @param on\n * @param off\n * @param phase\n */\n dash(on: number, off: number, phase: number): boolean;\n\n /**\n * Returns true if other path is equal to this path.\n * @param other\n */\n equals(other: SkPath): boolean;\n\n /**\n * Returns minimum and maximum axes values of Point array.\n * Returns (0, 0, 0, 0) if Path contains no points. Returned bounds width and height may\n * be larger or smaller than area affected when Path is drawn.\n */\n getBounds(): SkRect;\n\n /**\n * Return the FillType for this path.\n */\n getFillType(): FillType;\n\n /**\n Adds quad from last point towards (x1, y1), to (x2, y2).\n\n If SkPath is empty, or last SkPath::Verb is kClose_Verb, last point is set to (0, 0) before adding quad.\n\n Appends kMove_Verb to verb array and (0, 0) to SkPoint array, if needed; then appends kQuad_Verb to verb array;\n and (x1, y1), (x2, y2) to SkPoint array.\n\n Parameters\n x1\tcontrol SkPoint of quad on x-axis\n y1\tcontrol SkPoint of quad on y-axis\n x2\tend SkPoint of quad on x-axis\n y2\tend SkPoint of quad on y-axis\n Returns\n reference to SkPath\n example: https://fiddle.skia.org/c/@Path_quadTo\n */\n quadTo(x1: number, y1: number, x2: number, y2: number): SkPath;\n\n /**\n * Adds Rect to Path, appending kMove_Verb, three kLine_Verb, and kClose_Verb,\n * starting with top-left corner of Rect; followed by top-right, bottom-right,\n * and bottom-left if isCCW is false; or followed by bottom-left,\n * bottom-right, and top-right if isCCW is true.\n * Returns the modified path for easier chaining.\n * @param rect\n * @param isCCW\n */\n addRect(rect: SkRect, isCCW?: boolean): SkPath;\n\n /**\n * Adds rrect to Path, creating a new closed contour.\n * Returns the modified path for easier chaining.\n * @param rrect\n * @param isCCW\n */\n addRRect(rrect: SkRRect, isCCW?: boolean): SkPath;\n\n /** Appends src to SkPath, transformed by matrix. Transformed curves may have\n different verbs, SkPoint, and conic weights.\n\n If mode is kAppend_AddPathMode, src verb array, SkPoint array, and conic\n weights are added unaltered. If mode is kExtend_AddPathMode, add line\n before appending verbs, SkPoint, and conic weights.\n\n @param src SkPath verbs, SkPoint, and conic weights to add\n @param matrix transform applied to src\n @param extend extends path with line if true\n @return reference to SkPath\n */\n addPath(src: SkPath, matrix?: SkMatrix, extend?: boolean): SkPath;\n\n /**\n * Returns the Point at index in Point array. Valid range for index is\n * 0 to countPoints() - 1.\n * @param index\n */\n getPoint(index: number): SkPoint;\n\n /**\n * Returns true if there are no verbs in the path.\n */\n isEmpty(): boolean;\n\n /**\n * Returns true if the path is volatile; it will not be altered or discarded\n * by the caller after it is drawn. Path by default have volatile set false, allowing\n * Surface to attach a cache of data which speeds repeated drawing. If true, Surface\n * may not speed repeated drawing.\n */\n isVolatile(): boolean;\n\n /** Adds circle centered at (x, y) of size radius to SkPath, appending kMove_Verb,\n four kConic_Verb, and kClose_Verb. Circle begins at: (x + radius, y), continuing\n clockwise if dir is kCW_Direction, and counterclockwise if dir is kCCW_Direction.\n\n Has no effect if radius is zero or negative.\n\n @param x center of circle\n @param y center of circle\n @param radius distance from center to edge \n @return reference to SkPath\n */\n addCircle(x: number, y: number, r: number): SkPath;\n\n getLastPt(): { x: number; y: number };\n\n /** Set this path to the result of applying the Op to this path and the\n specified path: this = (this op operand).\n The resulting path will be constructed from non-overlapping contours.\n The curve order is reduced where possible so that cubics may be turned\n into quadratics, and quadratics maybe turned into lines.\n\n Returns true if operation was able to produce a result;\n otherwise, result is unmodified.\n\n @param path The second path (for difference, the subtrahend)\n @param op The operator to apply.\n @param result The product of the operands. The result may be one of the\n inputs.\n @return True if the operation succeeded.\n */\n op(path: SkPath, op: PathOp): boolean;\n\n /** Set this path to a set of non-overlapping contours that describe the\n same area as the original path.\n The curve order is reduced where possible so that cubics may\n be turned into quadratics, and quadratics maybe turned into lines.\n\n Returns true if operation was able to produce a result;\n otherwise, result is unmodified.\n\n @param result The simplified path. The result may be the input.\n @return True if simplification succeeded.\n */\n simplify(): boolean;\n\n /**\n * Returns this path as an SVG string.\n */\n toSVGString(): string;\n\n /**\n * Take start and stop \"t\" values (values between 0...1), and modify this path such that\n * it is a subset of the original path.\n * The trim values apply to the entire path, so if it contains several contours, all of them\n * are including in the calculation.\n * Null is returned if either input value is NaN.\n * @param startT - a value in the range [0.0, 1.0]. 0.0 is the beginning of the path.\n * @param stopT - a value in the range [0.0, 1.0]. 1.0 is the end of the path.\n * @param isComplement\n */\n trim(startT: number, stopT: number, isComplement: boolean): null | SkPath;\n\n /**\n * Transforms the path by the specified matrix.\n */\n transform(m3: SkMatrix | number[]): SkPath;\n\n /**\n * Interpolates between Path with point array of equal size.\n * Copy verb array and weights to result, and set result path to a weighted\n * average of this path array and ending path.\n\n * weight is most useful when between zero (ending path) and\n one (this path); will work with values outside of this\n range.\n\n * interpolate() returns undefined if path is not\n * the same size as ending path. Call isInterpolatable() to check Path\n * compatibility prior to calling interpolate().\n\n * @param ending path to interpolate with\n * @param weight contribution of this path, and\n * one minus contribution of ending path\n * @param output path to be replaced with the interpolated averages\n * @return Path replaced by interpolated averages or null if \n * not interpolatable\n * */\n interpolate(end: SkPath, weight: number, output?: SkPath): SkPath | null;\n\n /** Returns true if Path contain equal verbs and equal weights.\n * @param compare path to compare\n * @return true if Path can be interpolated equivalent\n *\n * */\n isInterpolatable(compare: SkPath): boolean;\n\n /**\n * Serializes the contents of this path as a series of commands.\n */\n toCmds(): PathCommand[];\n}\n"],"mappings":";;;;;;;AAOA;AACA;AACA;IAcYA,Q;;;WAAAA,Q;EAAAA,Q,CAAAA,Q;EAAAA,Q,CAAAA,Q;EAAAA,Q,CAAAA,Q;EAAAA,Q,CAAAA,Q;GAAAA,Q,wBAAAA,Q;;IAOAC,M;;;WAAAA,M;EAAAA,M,CAAAA,M;EAAAA,M,CAAAA,M;EAAAA,M,CAAAA,M;EAAAA,M,CAAAA,M;EAAAA,M,CAAAA,M;GAAAA,M,sBAAAA,M;;IAQAC,Q;;;WAAAA,Q;EAAAA,Q,CAAAA,Q;EAAAA,Q,CAAAA,Q;EAAAA,Q,CAAAA,Q;EAAAA,Q,CAAAA,Q;EAAAA,Q,CAAAA,Q;EAAAA,Q,CAAAA,Q;GAAAA,Q,wBAAAA,Q;;AAWL,MAAMC,MAAM,GAAIC,GAAD,IACpBA,GAAG,KAAK,IAAR,IAAgBA,GAAG,CAACC,YAAJ,KAAqB,MADhC"}
|
1
|
+
{"version":3,"names":["FillType","PathOp","PathVerb","isPath","obj","__typename__"],"sources":["Path.ts"],"sourcesContent":["import type { SkRect } from \"../Rect\";\nimport type { SkPoint } from \"../Point\";\nimport type { SkRRect } from \"../RRect\";\nimport type { StrokeJoin, StrokeCap } from \"../Paint\";\nimport type { InputMatrix, SkMatrix } from \"../Matrix\";\nimport type { SkJSIInstance } from \"../JsiInstance\";\n\n/**\n * Options used for Path.stroke(). If an option is omitted, a sensible default will be used.\n */\nexport interface StrokeOpts {\n /** The width of the stroked lines. */\n width?: number;\n miter_limit?: number;\n /**\n * if > 1, increase precision, else if (0 < resScale < 1) reduce precision to\n * favor speed and size\n */\n precision?: number;\n join?: StrokeJoin;\n cap?: StrokeCap;\n}\n\nexport enum FillType {\n Winding,\n EvenOdd,\n InverseWinding,\n InverseEvenOdd,\n}\n\nexport enum PathOp {\n Difference, //!< subtract the op path from the first path\n Intersect, //!< intersect the two paths\n Union, //!< union (inclusive-or) the two paths\n XOR, //!< exclusive-or the two paths\n ReverseDifference,\n}\n\nexport enum PathVerb {\n Move,\n Line,\n Quad,\n Conic,\n Cubic,\n Close,\n}\n\nexport type PathCommand = number[];\n\nexport const isPath = (obj: SkJSIInstance<string> | null): obj is SkPath =>\n obj !== null && obj.__typename__ === \"Path\";\n\nexport interface SkPath extends SkJSIInstance<\"Path\"> {\n /**\n * Appends arc to Path, as the start of new contour. Arc added is part of ellipse\n * bounded by oval, from startAngle through sweepAngle. Both startAngle and\n * sweepAngle are measured in degrees, where zero degrees is aligned with the\n * positive x-axis, and positive sweeps extends arc clockwise.\n * Returns the modified path for easier chaining.\n * @param oval\n * @param startAngle\n * @param sweepAngle\n */\n addArc(\n oval: SkRect,\n startAngleInDegrees: number,\n sweepAngleInDegrees: number\n ): SkPath;\n\n /**\n * Adds oval to Path, appending kMove_Verb, four kConic_Verb, and kClose_Verb.\n * Oval is upright ellipse bounded by Rect oval with radii equal to half oval width\n * and half oval height. Oval begins at start and continues clockwise by default.\n * Returns the modified path for easier chaining.\n * @param oval\n * @param isCCW - if the path should be drawn counter-clockwise or not\n * @param startIndex - index of initial point of ellipse\n */\n addOval(oval: SkRect, isCCW?: boolean, startIndex?: number): SkPath;\n\n /**\n * Returns the number of points in this path. Initially zero.\n */\n countPoints(): number;\n\n /**\n * Adds contour created from array of n points, adding (count - 1) line segments.\n * Contour added starts at pts[0], then adds a line for every additional point\n * in pts array. If close is true, appends kClose_Verb to Path, connecting\n * pts[count - 1] and pts[0].\n * Returns the modified path for easier chaining.\n * @param points\n * @param close - if true, will add a line connecting last point to the first point.\n */\n addPoly(points: SkPoint[], close: boolean): SkPath;\n\n /** Adds beginning of contour at SkPoint (x, y).\n\n @param x x-axis value of contour start\n @param y y-axis value of contour start\n @return reference to SkPath\n\n example: https://fiddle.skia.org/c/@Path_moveTo\n */\n moveTo(x: number, y: number): SkPath;\n /** Adds line from last point to (x, y). If SkPath is empty, or last SkPath::Verb is\n kClose_Verb, last point is set to (0, 0) before adding line.\n\n lineTo() appends kMove_Verb to verb array and (0, 0) to SkPoint array, if needed.\n lineTo() then appends kLine_Verb to verb array and (x, y) to SkPoint array.\n\n @param x end of added line on x-axis\n @param y end of added line on y-axis\n @return reference to SkPath\n\n example: https://fiddle.skia.org/c/@Path_lineTo\n */\n lineTo(x: number, y: number): SkPath;\n\n /**\n * Returns a new path that covers the same area as the original path, but with the\n * Winding FillType. This may re-draw some contours in the path as counter-clockwise\n * instead of clockwise to achieve that effect. If such a transformation cannot\n * be done, null is returned.\n */\n makeAsWinding(): SkPath | null;\n\n /**\n * Translates all the points in the path by dx, dy.\n * @param dx\n * @param dy\n */\n offset(dx: number, dy: number): SkPath;\n\n /**\n * Relative version of arcToRotated.\n * @param rx\n * @param ry\n * @param xAxisRotate\n * @param useSmallArc\n * @param isCCW\n * @param dx\n * @param dy\n */\n rArcTo(\n rx: number,\n ry: number,\n xAxisRotateInDegrees: number,\n useSmallArc: boolean,\n isCCW: boolean,\n dx: number,\n dy: number\n ): SkPath;\n\n /**\n * Relative version of conicTo.\n * @param dx1\n * @param dy1\n * @param dx2\n * @param dy2\n * @param w\n */\n rConicTo(\n dx1: number,\n dy1: number,\n dx2: number,\n dy2: number,\n w: number\n ): SkPath;\n\n /**\n * Relative version of cubicTo.\n * @param cpx1\n * @param cpy1\n * @param cpx2\n * @param cpy2\n * @param x\n * @param y\n */\n rCubicTo(\n cpx1: number,\n cpy1: number,\n cpx2: number,\n cpy2: number,\n x: number,\n y: number\n ): SkPath;\n\n /**\n * Relative version of moveTo.\n * @param x\n * @param y\n */\n rMoveTo(x: number, y: number): SkPath;\n\n /**\n * Relative version of lineTo.\n * @param x\n * @param y\n */\n rLineTo(x: number, y: number): SkPath;\n\n /**\n * Relative version of quadTo.\n * @param x1\n * @param y1\n * @param x2\n * @param y2\n */\n rQuadTo(x1: number, y1: number, x2: number, y2: number): SkPath;\n\n /**\n * Sets FillType, the rule used to fill Path.\n * @param fill\n */\n setFillType(fill: FillType): SkPath;\n\n /**\n * Specifies whether Path is volatile; whether it will be altered or discarded\n * by the caller after it is drawn. Path by default have volatile set false.\n *\n * Mark animating or temporary paths as volatile to improve performance.\n * Mark unchanging Path non-volatile to improve repeated rendering.\n * @param volatile\n */\n setIsVolatile(volatile: boolean): SkPath;\n\n /**\n * Turns this path into the filled equivalent of the stroked path. Returns false if the operation\n * fails (e.g. the path is a hairline).\n * @param opts - describe how stroked path should look.\n * If such a transformation cannot be done, null is returned.\n */\n stroke(opts?: StrokeOpts): null | SkPath;\n\n /**\n * Appends CLOSE_VERB to Path. A closed contour connects the first and last point\n * with a line, forming a continuous loop.\n */\n close(): SkPath;\n\n /**\n * Sets Path to its initial state.\n * Removes verb array, point array, and weights, and sets FillType to Winding.\n * Internal storage associated with Path is released\n */\n reset(): SkPath;\n\n /**\n * Sets Path to its initial state.\n * Removes verb array, point array, and weights, and sets FillType to Winding.\n * Internal storage associated with Path is *not* released.\n * Use rewind() instead of reset() if Path storage will be reused and performance\n * is critical.\n */\n rewind(): SkPath;\n\n /**\n * Returns minimum and maximum axes values of the lines and curves in Path.\n * Returns (0, 0, 0, 0) if Path contains no points.\n * Returned bounds width and height may be larger or smaller than area affected\n * when Path is drawn.\n *\n * Behaves identically to getBounds() when Path contains\n * only lines. If Path contains curves, computed bounds includes\n * the maximum extent of the quad, conic, or cubic; is slower than getBounds();\n * and unlike getBounds(), does not cache the result.\n */\n computeTightBounds(): SkRect;\n\n /**\n * Appends arc to Path. Arc added is part of ellipse\n * bounded by oval, from startAngle through sweepAngle. Both startAngle and\n * sweepAngle are measured in degrees, where zero degrees is aligned with the\n * positive x-axis, and positive sweeps extends arc clockwise.\n * Returns the modified path for easier chaining.\n * @param oval\n * @param startAngleInDegrees\n * @param sweepAngleInDegrees\n * @param forceMoveTo\n */\n arcToOval(\n oval: SkRect,\n startAngleInDegrees: number,\n sweepAngleInDegrees: number,\n forceMoveTo: boolean\n ): SkPath;\n\n /**\n * Appends arc to Path. Arc is implemented by one or more conics weighted to\n * describe part of oval with radii (rx, ry) rotated by xAxisRotate degrees. Arc\n * curves from last Path Point to (x, y), choosing one of four possible routes:\n * clockwise or counterclockwise, and smaller or larger. See SkPath.h for more details.\n * Returns the modified path for easier chaining.\n * @param rx\n * @param ry\n * @param xAxisRotate\n * @param useSmallArc\n * @param isCCW\n * @param x\n * @param y\n */\n arcToRotated(\n rx: number,\n ry: number,\n xAxisRotateInDegrees: number,\n useSmallArc: boolean,\n isCCW: boolean,\n x: number,\n y: number\n ): SkPath;\n\n /**\n * Appends arc to Path, after appending line if needed. Arc is implemented by conic\n * weighted to describe part of circle. Arc is contained by tangent from\n * last Path point to (x1, y1), and tangent from (x1, y1) to (x2, y2). Arc\n * is part of circle sized to radius, positioned so it touches both tangent lines.\n * Returns the modified path for easier chaining.\n * @param x1\n * @param y1\n * @param x2\n * @param y2\n * @param radius\n */\n arcToTangent(\n x1: number,\n y1: number,\n x2: number,\n y2: number,\n radius: number\n ): SkPath;\n\n /**\n * Adds conic from last point towards (x1, y1), to (x2, y2), weighted by w.\n * If Path is empty, or path is closed, the last point is set to (0, 0)\n * before adding conic.\n * Returns the modified path for easier chaining.\n * @param x1\n * @param y1\n * @param x2\n * @param y2\n * @param w\n */\n conicTo(x1: number, y1: number, x2: number, y2: number, w: number): SkPath;\n\n /**\n * Returns true if the point (x, y) is contained by Path, taking into\n * account FillType.\n * @param x\n * @param y\n */\n contains(x: number, y: number): boolean;\n\n /**\n * Returns a copy of this Path.\n */\n copy(): SkPath;\n\n /**\n * Adds cubic from last point towards (x1, y1), then towards (x2, y2), ending at\n * (x3, y3). If Path is empty, or path is closed, the last point is set to\n * (0, 0) before adding cubic.\n * @param cpx1\n * @param cpy1\n * @param cpx2\n * @param cpy2\n * @param x\n * @param y\n */\n cubicTo(\n cpx1: number,\n cpy1: number,\n cpx2: number,\n cpy2: number,\n x: number,\n y: number\n ): SkPath;\n\n /**\n * Changes this path to be the dashed version of itself. This is the same effect as creating\n * a DashPathEffect and calling filterPath on this path.\n * @param on\n * @param off\n * @param phase\n */\n dash(on: number, off: number, phase: number): boolean;\n\n /**\n * Returns true if other path is equal to this path.\n * @param other\n */\n equals(other: SkPath): boolean;\n\n /**\n * Returns minimum and maximum axes values of Point array.\n * Returns (0, 0, 0, 0) if Path contains no points. Returned bounds width and height may\n * be larger or smaller than area affected when Path is drawn.\n */\n getBounds(): SkRect;\n\n /**\n * Return the FillType for this path.\n */\n getFillType(): FillType;\n\n /**\n Adds quad from last point towards (x1, y1), to (x2, y2).\n\n If SkPath is empty, or last SkPath::Verb is kClose_Verb, last point is set to (0, 0) before adding quad.\n\n Appends kMove_Verb to verb array and (0, 0) to SkPoint array, if needed; then appends kQuad_Verb to verb array;\n and (x1, y1), (x2, y2) to SkPoint array.\n\n Parameters\n x1\tcontrol SkPoint of quad on x-axis\n y1\tcontrol SkPoint of quad on y-axis\n x2\tend SkPoint of quad on x-axis\n y2\tend SkPoint of quad on y-axis\n Returns\n reference to SkPath\n example: https://fiddle.skia.org/c/@Path_quadTo\n */\n quadTo(x1: number, y1: number, x2: number, y2: number): SkPath;\n\n /**\n * Adds Rect to Path, appending kMove_Verb, three kLine_Verb, and kClose_Verb,\n * starting with top-left corner of Rect; followed by top-right, bottom-right,\n * and bottom-left if isCCW is false; or followed by bottom-left,\n * bottom-right, and top-right if isCCW is true.\n * Returns the modified path for easier chaining.\n * @param rect\n * @param isCCW\n */\n addRect(rect: SkRect, isCCW?: boolean): SkPath;\n\n /**\n * Adds rrect to Path, creating a new closed contour.\n * Returns the modified path for easier chaining.\n * @param rrect\n * @param isCCW\n */\n addRRect(rrect: SkRRect, isCCW?: boolean): SkPath;\n\n /** Appends src to SkPath, transformed by matrix. Transformed curves may have\n different verbs, SkPoint, and conic weights.\n\n If mode is kAppend_AddPathMode, src verb array, SkPoint array, and conic\n weights are added unaltered. If mode is kExtend_AddPathMode, add line\n before appending verbs, SkPoint, and conic weights.\n\n @param src SkPath verbs, SkPoint, and conic weights to add\n @param matrix transform applied to src\n @param extend extends path with line if true\n @return reference to SkPath\n */\n addPath(src: SkPath, matrix?: SkMatrix, extend?: boolean): SkPath;\n\n /**\n * Returns the Point at index in Point array. Valid range for index is\n * 0 to countPoints() - 1.\n * @param index\n */\n getPoint(index: number): SkPoint;\n\n /**\n * Returns true if there are no verbs in the path.\n */\n isEmpty(): boolean;\n\n /**\n * Returns true if the path is volatile; it will not be altered or discarded\n * by the caller after it is drawn. Path by default have volatile set false, allowing\n * Surface to attach a cache of data which speeds repeated drawing. If true, Surface\n * may not speed repeated drawing.\n */\n isVolatile(): boolean;\n\n /** Adds circle centered at (x, y) of size radius to SkPath, appending kMove_Verb,\n four kConic_Verb, and kClose_Verb. Circle begins at: (x + radius, y), continuing\n clockwise if dir is kCW_Direction, and counterclockwise if dir is kCCW_Direction.\n\n Has no effect if radius is zero or negative.\n\n @param x center of circle\n @param y center of circle\n @param radius distance from center to edge \n @return reference to SkPath\n */\n addCircle(x: number, y: number, r: number): SkPath;\n\n getLastPt(): { x: number; y: number };\n\n /** Set this path to the result of applying the Op to this path and the\n specified path: this = (this op operand).\n The resulting path will be constructed from non-overlapping contours.\n The curve order is reduced where possible so that cubics may be turned\n into quadratics, and quadratics maybe turned into lines.\n\n Returns true if operation was able to produce a result;\n otherwise, result is unmodified.\n\n @param path The second path (for difference, the subtrahend)\n @param op The operator to apply.\n @param result The product of the operands. The result may be one of the\n inputs.\n @return True if the operation succeeded.\n */\n op(path: SkPath, op: PathOp): boolean;\n\n /** Set this path to a set of non-overlapping contours that describe the\n same area as the original path.\n The curve order is reduced where possible so that cubics may\n be turned into quadratics, and quadratics maybe turned into lines.\n\n Returns true if operation was able to produce a result;\n otherwise, result is unmodified.\n\n @param result The simplified path. The result may be the input.\n @return True if simplification succeeded.\n */\n simplify(): boolean;\n\n /**\n * Returns this path as an SVG string.\n */\n toSVGString(): string;\n\n /**\n * Take start and stop \"t\" values (values between 0...1), and modify this path such that\n * it is a subset of the original path.\n * The trim values apply to the entire path, so if it contains several contours, all of them\n * are including in the calculation.\n * Null is returned if either input value is NaN.\n * @param startT - a value in the range [0.0, 1.0]. 0.0 is the beginning of the path.\n * @param stopT - a value in the range [0.0, 1.0]. 1.0 is the end of the path.\n * @param isComplement\n */\n trim(startT: number, stopT: number, isComplement: boolean): null | SkPath;\n\n /**\n * Transforms the path by the specified matrix.\n */\n transform(m3: InputMatrix): SkPath;\n\n /**\n * Interpolates between Path with point array of equal size.\n * Copy verb array and weights to result, and set result path to a weighted\n * average of this path array and ending path.\n\n * weight is most useful when between zero (ending path) and\n one (this path); will work with values outside of this\n range.\n\n * interpolate() returns undefined if path is not\n * the same size as ending path. Call isInterpolatable() to check Path\n * compatibility prior to calling interpolate().\n\n * @param ending path to interpolate with\n * @param weight contribution of this path, and\n * one minus contribution of ending path\n * @param output path to be replaced with the interpolated averages\n * @return Path replaced by interpolated averages or null if \n * not interpolatable\n * */\n interpolate(end: SkPath, weight: number, output?: SkPath): SkPath | null;\n\n /** Returns true if Path contain equal verbs and equal weights.\n * @param compare path to compare\n * @return true if Path can be interpolated equivalent\n *\n * */\n isInterpolatable(compare: SkPath): boolean;\n\n /**\n * Serializes the contents of this path as a series of commands.\n */\n toCmds(): PathCommand[];\n}\n"],"mappings":";;;;;;;AAOA;AACA;AACA;IAcYA,Q;;;WAAAA,Q;EAAAA,Q,CAAAA,Q;EAAAA,Q,CAAAA,Q;EAAAA,Q,CAAAA,Q;EAAAA,Q,CAAAA,Q;GAAAA,Q,wBAAAA,Q;;IAOAC,M;;;WAAAA,M;EAAAA,M,CAAAA,M;EAAAA,M,CAAAA,M;EAAAA,M,CAAAA,M;EAAAA,M,CAAAA,M;EAAAA,M,CAAAA,M;GAAAA,M,sBAAAA,M;;IAQAC,Q;;;WAAAA,Q;EAAAA,Q,CAAAA,Q;EAAAA,Q,CAAAA,Q;EAAAA,Q,CAAAA,Q;EAAAA,Q,CAAAA,Q;EAAAA,Q,CAAAA,Q;EAAAA,Q,CAAAA,Q;GAAAA,Q,wBAAAA,Q;;AAWL,MAAMC,MAAM,GAAIC,GAAD,IACpBA,GAAG,KAAK,IAAR,IAAgBA,GAAG,CAACC,YAAJ,KAAqB,MADhC"}
|
@@ -16,6 +16,5 @@ export declare abstract class BaseHostObject<T, N extends string> extends Host i
|
|
16
16
|
export declare abstract class HostObject<T, N extends string> extends BaseHostObject<T, N> {
|
17
17
|
static fromValue<T>(value: SkJSIInstance<string>): T;
|
18
18
|
}
|
19
|
-
export declare const
|
20
|
-
export declare const
|
21
|
-
export declare const optEnum: (value: number | undefined) => EmbindEnumEntity | undefined;
|
19
|
+
export declare const getEnum: (e: EmbindEnum, v: number) => EmbindEnumEntity;
|
20
|
+
export declare const optEnum: (e: EmbindEnum, value: number | undefined) => EmbindEnumEntity | undefined;
|
@@ -3,7 +3,7 @@
|
|
3
3
|
Object.defineProperty(exports, "__esModule", {
|
4
4
|
value: true
|
5
5
|
});
|
6
|
-
exports.optEnum = exports.
|
6
|
+
exports.optEnum = exports.getEnum = exports.NotImplementedOnRNWeb = exports.HostObject = exports.Host = exports.BaseHostObject = void 0;
|
7
7
|
|
8
8
|
function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
|
9
9
|
|
@@ -52,24 +52,16 @@ class HostObject extends BaseHostObject {
|
|
52
52
|
|
53
53
|
exports.HostObject = HostObject;
|
54
54
|
|
55
|
-
const
|
55
|
+
const getEnum = (e, v) => Object.values(e).find(_ref => {
|
56
56
|
let {
|
57
57
|
value
|
58
58
|
} = _ref;
|
59
59
|
return value === v;
|
60
60
|
});
|
61
61
|
|
62
|
-
exports.
|
62
|
+
exports.getEnum = getEnum;
|
63
63
|
|
64
|
-
const
|
65
|
-
value
|
66
|
-
});
|
67
|
-
|
68
|
-
exports.ckEnum = ckEnum;
|
69
|
-
|
70
|
-
const optEnum = value => value === undefined ? undefined : {
|
71
|
-
value
|
72
|
-
};
|
64
|
+
const optEnum = (e, value) => value === undefined ? undefined : getEnum(e, value);
|
73
65
|
|
74
66
|
exports.optEnum = optEnum;
|
75
67
|
//# sourceMappingURL=Host.js.map
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"names":["NotImplementedOnRNWeb","Error","constructor","msg","Host","CanvasKit","BaseHostObject","ref","typename","__typename__","HostObject","fromValue","value","
|
1
|
+
{"version":3,"names":["NotImplementedOnRNWeb","Error","constructor","msg","Host","CanvasKit","BaseHostObject","ref","typename","__typename__","HostObject","fromValue","value","getEnum","e","v","Object","values","find","optEnum","undefined"],"sources":["Host.ts"],"sourcesContent":["import type { CanvasKit, EmbindEnumEntity, EmbindEnum } from \"canvaskit-wasm\";\n\nimport type { SkJSIInstance } from \"../types\";\n\nexport class NotImplementedOnRNWeb extends Error {\n constructor(msg?: string) {\n super(msg ?? \"Not implemented on React Native Web\");\n }\n}\n\nexport abstract class Host {\n readonly CanvasKit: CanvasKit;\n\n constructor(CanvasKit: CanvasKit) {\n this.CanvasKit = CanvasKit;\n }\n}\n\nexport abstract class BaseHostObject<T, N extends string>\n extends Host\n implements SkJSIInstance<N>\n{\n readonly __typename__: N;\n ref: T;\n\n constructor(CanvasKit: CanvasKit, ref: T, typename: N) {\n super(CanvasKit);\n this.ref = ref;\n this.__typename__ = typename;\n }\n\n abstract dispose(): void;\n}\n\nexport abstract class HostObject<T, N extends string> extends BaseHostObject<\n T,\n N\n> {\n static fromValue<T>(value: SkJSIInstance<string>) {\n return (value as HostObject<T, string>).ref;\n }\n}\n\nexport const getEnum = (e: EmbindEnum, v: number): EmbindEnumEntity =>\n Object.values(e).find(({ value }) => value === v);\n\nexport const optEnum = (\n e: EmbindEnum,\n value: number | undefined\n): EmbindEnumEntity | undefined =>\n value === undefined ? undefined : getEnum(e, value);\n"],"mappings":";;;;;;;;;AAIO,MAAMA,qBAAN,SAAoCC,KAApC,CAA0C;EAC/CC,WAAW,CAACC,GAAD,EAAe;IACxB,MAAMA,GAAG,IAAI,qCAAb;EACD;;AAH8C;;;;AAM1C,MAAeC,IAAf,CAAoB;EAGzBF,WAAW,CAACG,SAAD,EAAuB;IAAA;;IAChC,KAAKA,SAAL,GAAiBA,SAAjB;EACD;;AALwB;;;;AAQpB,MAAeC,cAAf,SACGF,IADH,CAGP;EAIEF,WAAW,CAACG,SAAD,EAAuBE,GAAvB,EAA+BC,QAA/B,EAA4C;IACrD,MAAMH,SAAN;;IADqD;;IAAA;;IAErD,KAAKE,GAAL,GAAWA,GAAX;IACA,KAAKE,YAAL,GAAoBD,QAApB;EACD;;AARH;;;;AAaO,MAAeE,UAAf,SAAuDJ,cAAvD,CAGL;EACgB,OAATK,SAAS,CAAIC,KAAJ,EAAkC;IAChD,OAAQA,KAAD,CAAiCL,GAAxC;EACD;;AAHD;;;;AAMK,MAAMM,OAAO,GAAG,CAACC,CAAD,EAAgBC,CAAhB,KACrBC,MAAM,CAACC,MAAP,CAAcH,CAAd,EAAiBI,IAAjB,CAAsB;EAAA,IAAC;IAAEN;EAAF,CAAD;EAAA,OAAeA,KAAK,KAAKG,CAAzB;AAAA,CAAtB,CADK;;;;AAGA,MAAMI,OAAO,GAAG,CACrBL,CADqB,EAErBF,KAFqB,KAIrBA,KAAK,KAAKQ,SAAV,GAAsBA,SAAtB,GAAkCP,OAAO,CAACC,CAAD,EAAIF,KAAJ,CAJpC"}
|