@shopify/react-native-skia 0.1.182 → 0.1.184

Sign up to get free protection for your applications and to get access to all the features.
Files changed (53) hide show
  1. package/ios/RNSkia-iOS/RNSkMetalCanvasProvider.mm +23 -8
  2. package/lib/commonjs/animation/functions/interpolate.js +10 -1
  3. package/lib/commonjs/animation/functions/interpolate.js.map +1 -1
  4. package/lib/commonjs/animation/functions/interpolateColors.js +6 -0
  5. package/lib/commonjs/animation/functions/interpolateColors.js.map +1 -1
  6. package/lib/commonjs/animation/functions/interpolatePaths.js +4 -0
  7. package/lib/commonjs/animation/functions/interpolatePaths.js.map +1 -1
  8. package/lib/commonjs/animation/functions/interpolateVector.js +13 -5
  9. package/lib/commonjs/animation/functions/interpolateVector.js.map +1 -1
  10. package/lib/commonjs/external/reanimated/useSharedValueEffect.js +5 -2
  11. package/lib/commonjs/external/reanimated/useSharedValueEffect.js.map +1 -1
  12. package/lib/commonjs/renderer/processors/math/Coordinates.js +42 -18
  13. package/lib/commonjs/renderer/processors/math/Coordinates.js.map +1 -1
  14. package/lib/commonjs/renderer/processors/math/Math.js +10 -2
  15. package/lib/commonjs/renderer/processors/math/Math.js.map +1 -1
  16. package/lib/commonjs/renderer/processors/math/Transforms.js +2 -0
  17. package/lib/commonjs/renderer/processors/math/Transforms.js.map +1 -1
  18. package/lib/commonjs/renderer/typeddash.js +2 -0
  19. package/lib/commonjs/renderer/typeddash.js.map +1 -1
  20. package/lib/commonjs/skia/core/Vector.js +24 -4
  21. package/lib/commonjs/skia/core/Vector.js.map +1 -1
  22. package/lib/module/animation/functions/interpolate.js +10 -1
  23. package/lib/module/animation/functions/interpolate.js.map +1 -1
  24. package/lib/module/animation/functions/interpolateColors.js +6 -0
  25. package/lib/module/animation/functions/interpolateColors.js.map +1 -1
  26. package/lib/module/animation/functions/interpolatePaths.js +4 -0
  27. package/lib/module/animation/functions/interpolatePaths.js.map +1 -1
  28. package/lib/module/animation/functions/interpolateVector.js +13 -5
  29. package/lib/module/animation/functions/interpolateVector.js.map +1 -1
  30. package/lib/module/external/reanimated/useSharedValueEffect.js +6 -3
  31. package/lib/module/external/reanimated/useSharedValueEffect.js.map +1 -1
  32. package/lib/module/renderer/processors/math/Coordinates.js +42 -18
  33. package/lib/module/renderer/processors/math/Coordinates.js.map +1 -1
  34. package/lib/module/renderer/processors/math/Math.js +10 -2
  35. package/lib/module/renderer/processors/math/Math.js.map +1 -1
  36. package/lib/module/renderer/processors/math/Transforms.js +2 -0
  37. package/lib/module/renderer/processors/math/Transforms.js.map +1 -1
  38. package/lib/module/renderer/typeddash.js +2 -0
  39. package/lib/module/renderer/typeddash.js.map +1 -1
  40. package/lib/module/skia/core/Vector.js +24 -4
  41. package/lib/module/skia/core/Vector.js.map +1 -1
  42. package/package.json +1 -1
  43. package/react-native-skia.podspec +2 -6
  44. package/src/animation/functions/interpolate.ts +5 -0
  45. package/src/animation/functions/interpolateColors.ts +3 -0
  46. package/src/animation/functions/interpolatePaths.ts +2 -0
  47. package/src/animation/functions/interpolateVector.ts +21 -16
  48. package/src/external/reanimated/useSharedValueEffect.ts +7 -4
  49. package/src/renderer/processors/math/Coordinates.ts +36 -20
  50. package/src/renderer/processors/math/Math.ts +12 -4
  51. package/src/renderer/processors/math/Transforms.ts +1 -0
  52. package/src/renderer/typeddash.ts +1 -0
  53. 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
- x: v.x - center.x,
10
- y: -1 * (v.y - center.y),
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
- x: v.x + center.x,
15
- y: -1 * v.y + center.y,
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
- theta: Math.atan2(v.y, v.x),
20
- radius: Math.sqrt(v.x ** 2 + v.y ** 2),
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
- x: p.radius * Math.cos(p.theta),
25
- y: p.radius * Math.sin(p.theta),
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
- cartesian2Canvas(polar2Cartesian(p), center);
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
- cartesian2Polar(canvas2Cartesian(v, center));
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
- x * (1 - value) + y * value;
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 = (value: number, lowerBound: number, upperBound: number) =>
18
- Math.min(Math.max(lowerBound, value), upperBound);
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
  };
@@ -2,6 +2,7 @@ export const mapKeys = <T extends object>(obj: T) =>
2
2
  Object.keys(obj) as (keyof T)[];
3
3
 
4
4
  export const exhaustiveCheck = (a: never): never => {
5
+ "worklet";
5
6
  throw new Error(`Unexhaustive handling for ${a}`);
6
7
  };
7
8
 
@@ -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) => Skia.Point(x, y ?? x);
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) => vec(-a.x, -a.y);
7
- export const add = (a: Vector, b: Vector) => vec(a.x + b.x, a.y + b.y);
8
- export const sub = (a: Vector, b: Vector) => vec(a.x - b.x, a.y - b.y);
9
- export const dist = (a: Vector, b: Vector) => Math.hypot(a.x - b.x, a.y - b.y);
10
- export const translate = ({ x, y }: Vector) =>
11
- [{ translateX: x }, { translateY: y }] as const;
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
+ };