@shopify/react-native-skia 0.1.182 → 0.1.184
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/ios/RNSkia-iOS/RNSkMetalCanvasProvider.mm +23 -8
- package/lib/commonjs/animation/functions/interpolate.js +10 -1
- package/lib/commonjs/animation/functions/interpolate.js.map +1 -1
- package/lib/commonjs/animation/functions/interpolateColors.js +6 -0
- package/lib/commonjs/animation/functions/interpolateColors.js.map +1 -1
- package/lib/commonjs/animation/functions/interpolatePaths.js +4 -0
- package/lib/commonjs/animation/functions/interpolatePaths.js.map +1 -1
- package/lib/commonjs/animation/functions/interpolateVector.js +13 -5
- package/lib/commonjs/animation/functions/interpolateVector.js.map +1 -1
- package/lib/commonjs/external/reanimated/useSharedValueEffect.js +5 -2
- package/lib/commonjs/external/reanimated/useSharedValueEffect.js.map +1 -1
- package/lib/commonjs/renderer/processors/math/Coordinates.js +42 -18
- package/lib/commonjs/renderer/processors/math/Coordinates.js.map +1 -1
- package/lib/commonjs/renderer/processors/math/Math.js +10 -2
- package/lib/commonjs/renderer/processors/math/Math.js.map +1 -1
- package/lib/commonjs/renderer/processors/math/Transforms.js +2 -0
- package/lib/commonjs/renderer/processors/math/Transforms.js.map +1 -1
- package/lib/commonjs/renderer/typeddash.js +2 -0
- package/lib/commonjs/renderer/typeddash.js.map +1 -1
- package/lib/commonjs/skia/core/Vector.js +24 -4
- package/lib/commonjs/skia/core/Vector.js.map +1 -1
- package/lib/module/animation/functions/interpolate.js +10 -1
- package/lib/module/animation/functions/interpolate.js.map +1 -1
- package/lib/module/animation/functions/interpolateColors.js +6 -0
- package/lib/module/animation/functions/interpolateColors.js.map +1 -1
- package/lib/module/animation/functions/interpolatePaths.js +4 -0
- package/lib/module/animation/functions/interpolatePaths.js.map +1 -1
- package/lib/module/animation/functions/interpolateVector.js +13 -5
- package/lib/module/animation/functions/interpolateVector.js.map +1 -1
- package/lib/module/external/reanimated/useSharedValueEffect.js +6 -3
- package/lib/module/external/reanimated/useSharedValueEffect.js.map +1 -1
- package/lib/module/renderer/processors/math/Coordinates.js +42 -18
- package/lib/module/renderer/processors/math/Coordinates.js.map +1 -1
- package/lib/module/renderer/processors/math/Math.js +10 -2
- package/lib/module/renderer/processors/math/Math.js.map +1 -1
- package/lib/module/renderer/processors/math/Transforms.js +2 -0
- package/lib/module/renderer/processors/math/Transforms.js.map +1 -1
- package/lib/module/renderer/typeddash.js +2 -0
- package/lib/module/renderer/typeddash.js.map +1 -1
- package/lib/module/skia/core/Vector.js +24 -4
- package/lib/module/skia/core/Vector.js.map +1 -1
- package/package.json +1 -1
- package/react-native-skia.podspec +2 -6
- package/src/animation/functions/interpolate.ts +5 -0
- package/src/animation/functions/interpolateColors.ts +3 -0
- package/src/animation/functions/interpolatePaths.ts +2 -0
- package/src/animation/functions/interpolateVector.ts +21 -16
- package/src/external/reanimated/useSharedValueEffect.ts +7 -4
- package/src/renderer/processors/math/Coordinates.ts +36 -20
- package/src/renderer/processors/math/Math.ts +12 -4
- package/src/renderer/processors/math/Transforms.ts +1 -0
- package/src/renderer/typeddash.ts +1 -0
- package/src/skia/core/Vector.ts +24 -7
@@ -5,28 +5,44 @@ export interface PolarPoint {
|
|
5
5
|
radius: number;
|
6
6
|
}
|
7
7
|
|
8
|
-
export const canvas2Cartesian = (v: Vector, center: Vector) =>
|
9
|
-
|
10
|
-
|
11
|
-
|
8
|
+
export const canvas2Cartesian = (v: Vector, center: Vector) => {
|
9
|
+
"worklet";
|
10
|
+
return {
|
11
|
+
x: v.x - center.x,
|
12
|
+
y: -1 * (v.y - center.y),
|
13
|
+
};
|
14
|
+
};
|
12
15
|
|
13
|
-
export const cartesian2Canvas = (v: Vector, center: Vector) =>
|
14
|
-
|
15
|
-
|
16
|
-
|
16
|
+
export const cartesian2Canvas = (v: Vector, center: Vector) => {
|
17
|
+
"worklet";
|
18
|
+
return {
|
19
|
+
x: v.x + center.x,
|
20
|
+
y: -1 * v.y + center.y,
|
21
|
+
};
|
22
|
+
};
|
17
23
|
|
18
|
-
export const cartesian2Polar = (v: Vector) =>
|
19
|
-
|
20
|
-
|
21
|
-
|
24
|
+
export const cartesian2Polar = (v: Vector) => {
|
25
|
+
"worklet";
|
26
|
+
return {
|
27
|
+
theta: Math.atan2(v.y, v.x),
|
28
|
+
radius: Math.sqrt(v.x ** 2 + v.y ** 2),
|
29
|
+
};
|
30
|
+
};
|
22
31
|
|
23
|
-
export const polar2Cartesian = (p: PolarPoint) =>
|
24
|
-
|
25
|
-
|
26
|
-
|
32
|
+
export const polar2Cartesian = (p: PolarPoint) => {
|
33
|
+
"worklet";
|
34
|
+
return {
|
35
|
+
x: p.radius * Math.cos(p.theta),
|
36
|
+
y: p.radius * Math.sin(p.theta),
|
37
|
+
};
|
38
|
+
};
|
27
39
|
|
28
|
-
export const polar2Canvas = (p: PolarPoint, center: Vector) =>
|
29
|
-
|
40
|
+
export const polar2Canvas = (p: PolarPoint, center: Vector) => {
|
41
|
+
"worklet";
|
42
|
+
return cartesian2Canvas(polar2Cartesian(p), center);
|
43
|
+
};
|
30
44
|
|
31
|
-
export const canvas2Polar = (v: Vector, center: Vector) =>
|
32
|
-
|
45
|
+
export const canvas2Polar = (v: Vector, center: Vector) => {
|
46
|
+
"worklet";
|
47
|
+
return cartesian2Polar(canvas2Cartesian(v, center));
|
48
|
+
};
|
@@ -4,8 +4,10 @@
|
|
4
4
|
* @param x
|
5
5
|
* @param y
|
6
6
|
*/
|
7
|
-
export const mix = (value: number, x: number, y: number) =>
|
8
|
-
|
7
|
+
export const mix = (value: number, x: number, y: number) => {
|
8
|
+
"worklet";
|
9
|
+
return x * (1 - value) + y * value;
|
10
|
+
};
|
9
11
|
|
10
12
|
/**
|
11
13
|
* @summary Clamps a node with a lower and upper bound.
|
@@ -14,5 +16,11 @@ export const mix = (value: number, x: number, y: number) =>
|
|
14
16
|
clamp(1, 0, 100); // 1
|
15
17
|
clamp(101, 0, 100); // 100
|
16
18
|
*/
|
17
|
-
export const clamp = (
|
18
|
-
|
19
|
+
export const clamp = (
|
20
|
+
value: number,
|
21
|
+
lowerBound: number,
|
22
|
+
upperBound: number
|
23
|
+
) => {
|
24
|
+
"worklet";
|
25
|
+
return Math.min(Math.max(lowerBound, value), upperBound);
|
26
|
+
};
|
@@ -3,6 +3,7 @@ import type { Vector } from "../../../skia/types";
|
|
3
3
|
import { canvas2Polar, polar2Canvas } from "./Coordinates";
|
4
4
|
|
5
5
|
export const rotate = (tr: Vector, origin: Vector, rotation: number) => {
|
6
|
+
"worklet";
|
6
7
|
const { radius, theta } = canvas2Polar(tr, origin);
|
7
8
|
return polar2Canvas({ radius, theta: theta + rotation }, origin);
|
8
9
|
};
|
package/src/skia/core/Vector.ts
CHANGED
@@ -1,11 +1,28 @@
|
|
1
1
|
import { Skia } from "../Skia";
|
2
2
|
import type { Vector } from "../types";
|
3
3
|
|
4
|
-
export const vec = (x = 0, y?: number) =>
|
4
|
+
export const vec = (x = 0, y?: number) => {
|
5
|
+
"worklet";
|
6
|
+
return Skia.Point(x, y ?? x);
|
7
|
+
};
|
5
8
|
export const point = vec;
|
6
|
-
export const neg = (a: Vector) =>
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
export const
|
11
|
-
|
9
|
+
export const neg = (a: Vector) => {
|
10
|
+
"worklet";
|
11
|
+
return vec(-a.x, -a.y);
|
12
|
+
};
|
13
|
+
export const add = (a: Vector, b: Vector) => {
|
14
|
+
"worklet";
|
15
|
+
return vec(a.x + b.x, a.y + b.y);
|
16
|
+
};
|
17
|
+
export const sub = (a: Vector, b: Vector) => {
|
18
|
+
"worklet";
|
19
|
+
return vec(a.x - b.x, a.y - b.y);
|
20
|
+
};
|
21
|
+
export const dist = (a: Vector, b: Vector) => {
|
22
|
+
"worklet";
|
23
|
+
return Math.hypot(a.x - b.x, a.y - b.y);
|
24
|
+
};
|
25
|
+
export const translate = ({ x, y }: Vector) => {
|
26
|
+
"worklet";
|
27
|
+
return [{ translateX: x }, { translateY: y }] as const;
|
28
|
+
};
|