@shopify/react-native-skia 0.1.224 → 0.1.227
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/android/cpp/rnskia-android/SkiaOpenGLSurfaceFactory.h +3 -3
- package/cpp/api/JsiSkMatrix.h +8 -2
- package/cpp/api/JsiSkParagraphStyle.h +3 -2
- package/cpp/api/JsiSkPictureRecorder.h +10 -3
- package/cpp/api/JsiSkStrutStyle.h +10 -3
- package/cpp/rnskia/dom/props/MatrixProp.h +8 -0
- package/cpp/rnskia/dom/props/TransformProp.h +76 -9
- package/lib/commonjs/animation/spring/runSpring.d.ts +3 -0
- package/lib/commonjs/animation/spring/runSpring.js +3 -0
- package/lib/commonjs/animation/spring/runSpring.js.map +1 -1
- package/lib/commonjs/animation/spring/useSpring.d.ts +3 -0
- package/lib/commonjs/animation/spring/useSpring.js +3 -0
- package/lib/commonjs/animation/spring/useSpring.js.map +1 -1
- package/lib/commonjs/animation/timing/runTiming.d.ts +3 -0
- package/lib/commonjs/animation/timing/runTiming.js +3 -0
- package/lib/commonjs/animation/timing/runTiming.js.map +1 -1
- package/lib/commonjs/animation/timing/useLoop.d.ts +3 -0
- package/lib/commonjs/animation/timing/useLoop.js +3 -0
- package/lib/commonjs/animation/timing/useLoop.js.map +1 -1
- package/lib/commonjs/animation/timing/useTiming.d.ts +3 -0
- package/lib/commonjs/animation/timing/useTiming.js +3 -0
- package/lib/commonjs/animation/timing/useTiming.js.map +1 -1
- package/lib/commonjs/dom/nodes/JsiSkDOM.js +2 -0
- package/lib/commonjs/dom/nodes/JsiSkDOM.js.map +1 -1
- package/lib/commonjs/dom/nodes/datatypes/Fitting.d.ts +5 -5
- package/lib/commonjs/dom/nodes/datatypes/Fitting.js.map +1 -1
- package/lib/commonjs/dom/nodes/datatypes/Gradient.d.ts +235 -75
- package/lib/commonjs/dom/nodes/datatypes/Gradient.js.map +1 -1
- package/lib/commonjs/dom/types/Common.d.ts +3 -3
- package/lib/commonjs/dom/types/Common.js.map +1 -1
- package/lib/commonjs/external/reanimated/interpolators.js +10 -4
- package/lib/commonjs/external/reanimated/interpolators.js.map +1 -1
- package/lib/commonjs/renderer/Canvas.js +34 -28
- package/lib/commonjs/renderer/Canvas.js.map +1 -1
- package/lib/commonjs/renderer/components/Drawing.d.ts +5 -0
- package/lib/commonjs/renderer/components/Drawing.js +5 -0
- package/lib/commonjs/renderer/components/Drawing.js.map +1 -1
- package/lib/commonjs/renderer/components/shapes/FitBox.d.ts +5 -5
- package/lib/commonjs/skia/core/Matrix.d.ts +2 -2
- package/lib/commonjs/skia/core/Matrix.js.map +1 -1
- package/lib/commonjs/skia/core/Picture.d.ts +2 -2
- package/lib/commonjs/skia/core/Picture.js +12 -2
- package/lib/commonjs/skia/core/Picture.js.map +1 -1
- package/lib/commonjs/skia/core/Vector.d.ts +3 -3
- package/lib/commonjs/skia/core/Vector.js.map +1 -1
- package/lib/commonjs/skia/types/Canvas.d.ts +1 -1
- package/lib/commonjs/skia/types/Canvas.js.map +1 -1
- package/lib/commonjs/skia/types/Matrix.d.ts +4 -9
- package/lib/commonjs/skia/types/Matrix.js +5 -56
- package/lib/commonjs/skia/types/Matrix.js.map +1 -1
- package/lib/commonjs/skia/types/Matrix4.d.ts +39 -0
- package/lib/commonjs/skia/types/Matrix4.js +213 -0
- package/lib/commonjs/skia/types/Matrix4.js.map +1 -0
- package/lib/commonjs/skia/types/Path/Path.d.ts +1 -1
- package/lib/commonjs/skia/types/Path/Path.js.map +1 -1
- package/lib/commonjs/skia/types/Picture/PictureRecorder.d.ts +1 -1
- package/lib/commonjs/skia/types/Picture/PictureRecorder.js.map +1 -1
- package/lib/commonjs/skia/types/Rect.d.ts +1 -0
- package/lib/commonjs/skia/types/Rect.js +18 -0
- package/lib/commonjs/skia/types/Rect.js.map +1 -1
- package/lib/commonjs/skia/types/index.d.ts +1 -0
- package/lib/commonjs/skia/types/index.js +13 -0
- package/lib/commonjs/skia/types/index.js.map +1 -1
- package/lib/commonjs/skia/web/JsiSkCanvas.d.ts +1 -1
- package/lib/commonjs/skia/web/JsiSkCanvas.js +1 -1
- package/lib/commonjs/skia/web/JsiSkCanvas.js.map +1 -1
- package/lib/commonjs/skia/web/JsiSkMatrix.d.ts +1 -1
- package/lib/commonjs/skia/web/JsiSkMatrix.js +1 -1
- package/lib/commonjs/skia/web/JsiSkMatrix.js.map +1 -1
- package/lib/commonjs/skia/web/JsiSkPath.js +1 -1
- package/lib/commonjs/skia/web/JsiSkPath.js.map +1 -1
- package/lib/commonjs/skia/web/JsiSkPictureRecorder.d.ts +1 -1
- package/lib/commonjs/skia/web/JsiSkPictureRecorder.js +1 -1
- package/lib/commonjs/skia/web/JsiSkPictureRecorder.js.map +1 -1
- package/lib/commonjs/values/api.d.ts +23 -2
- package/lib/commonjs/values/api.js +44 -1
- package/lib/commonjs/values/api.js.map +1 -1
- package/lib/commonjs/values/hooks/useClockValue.d.ts +3 -0
- package/lib/commonjs/values/hooks/useClockValue.js +3 -0
- package/lib/commonjs/values/hooks/useClockValue.js.map +1 -1
- package/lib/commonjs/values/hooks/useComputedValue.d.ts +3 -0
- package/lib/commonjs/values/hooks/useComputedValue.js +3 -0
- package/lib/commonjs/values/hooks/useComputedValue.js.map +1 -1
- package/lib/commonjs/values/hooks/useValue.d.ts +3 -0
- package/lib/commonjs/values/hooks/useValue.js +3 -0
- package/lib/commonjs/values/hooks/useValue.js.map +1 -1
- package/lib/commonjs/values/hooks/useValueEffect.d.ts +3 -0
- package/lib/commonjs/values/hooks/useValueEffect.js +3 -0
- package/lib/commonjs/values/hooks/useValueEffect.js.map +1 -1
- package/lib/commonjs/values/types.d.ts +4 -4
- package/lib/commonjs/values/types.js.map +1 -1
- package/lib/commonjs/views/SkiaView.d.ts +5 -0
- package/lib/commonjs/views/SkiaView.js +9 -0
- package/lib/commonjs/views/SkiaView.js.map +1 -1
- package/lib/module/animation/spring/runSpring.d.ts +3 -0
- package/lib/module/animation/spring/runSpring.js +3 -0
- package/lib/module/animation/spring/runSpring.js.map +1 -1
- package/lib/module/animation/spring/useSpring.d.ts +3 -0
- package/lib/module/animation/spring/useSpring.js +3 -0
- package/lib/module/animation/spring/useSpring.js.map +1 -1
- package/lib/module/animation/timing/runTiming.d.ts +3 -0
- package/lib/module/animation/timing/runTiming.js +3 -0
- package/lib/module/animation/timing/runTiming.js.map +1 -1
- package/lib/module/animation/timing/useLoop.d.ts +3 -0
- package/lib/module/animation/timing/useLoop.js +3 -0
- package/lib/module/animation/timing/useLoop.js.map +1 -1
- package/lib/module/animation/timing/useTiming.d.ts +3 -0
- package/lib/module/animation/timing/useTiming.js +3 -0
- package/lib/module/animation/timing/useTiming.js.map +1 -1
- package/lib/module/dom/nodes/JsiSkDOM.js +2 -0
- package/lib/module/dom/nodes/JsiSkDOM.js.map +1 -1
- package/lib/module/dom/nodes/datatypes/Fitting.d.ts +5 -5
- package/lib/module/dom/nodes/datatypes/Fitting.js.map +1 -1
- package/lib/module/dom/nodes/datatypes/Gradient.d.ts +235 -75
- package/lib/module/dom/nodes/datatypes/Gradient.js.map +1 -1
- package/lib/module/dom/types/Common.d.ts +3 -3
- package/lib/module/dom/types/Common.js.map +1 -1
- package/lib/module/external/reanimated/interpolators.js +11 -5
- package/lib/module/external/reanimated/interpolators.js.map +1 -1
- package/lib/module/renderer/Canvas.js +35 -29
- package/lib/module/renderer/Canvas.js.map +1 -1
- package/lib/module/renderer/components/Drawing.d.ts +5 -0
- package/lib/module/renderer/components/Drawing.js +6 -0
- package/lib/module/renderer/components/Drawing.js.map +1 -1
- package/lib/module/renderer/components/shapes/FitBox.d.ts +5 -5
- package/lib/module/skia/core/Matrix.d.ts +2 -2
- package/lib/module/skia/core/Matrix.js.map +1 -1
- package/lib/module/skia/core/Picture.d.ts +2 -2
- package/lib/module/skia/core/Picture.js +12 -3
- package/lib/module/skia/core/Picture.js.map +1 -1
- package/lib/module/skia/core/Vector.d.ts +3 -3
- package/lib/module/skia/core/Vector.js.map +1 -1
- package/lib/module/skia/types/Canvas.d.ts +1 -1
- package/lib/module/skia/types/Canvas.js.map +1 -1
- package/lib/module/skia/types/Matrix.d.ts +4 -9
- package/lib/module/skia/types/Matrix.js +3 -57
- package/lib/module/skia/types/Matrix.js.map +1 -1
- package/lib/module/skia/types/Matrix4.d.ts +39 -0
- package/lib/module/skia/types/Matrix4.js +200 -0
- package/lib/module/skia/types/Matrix4.js.map +1 -0
- package/lib/module/skia/types/Path/Path.d.ts +1 -1
- package/lib/module/skia/types/Path/Path.js.map +1 -1
- package/lib/module/skia/types/Picture/PictureRecorder.d.ts +1 -1
- package/lib/module/skia/types/Picture/PictureRecorder.js.map +1 -1
- package/lib/module/skia/types/Rect.d.ts +1 -0
- package/lib/module/skia/types/Rect.js +9 -0
- package/lib/module/skia/types/Rect.js.map +1 -1
- package/lib/module/skia/types/index.d.ts +1 -0
- package/lib/module/skia/types/index.js +1 -0
- package/lib/module/skia/types/index.js.map +1 -1
- package/lib/module/skia/web/JsiSkCanvas.d.ts +1 -1
- package/lib/module/skia/web/JsiSkCanvas.js +1 -1
- package/lib/module/skia/web/JsiSkCanvas.js.map +1 -1
- package/lib/module/skia/web/JsiSkMatrix.d.ts +1 -1
- package/lib/module/skia/web/JsiSkMatrix.js +1 -1
- package/lib/module/skia/web/JsiSkMatrix.js.map +1 -1
- package/lib/module/skia/web/JsiSkPath.js +1 -1
- package/lib/module/skia/web/JsiSkPath.js.map +1 -1
- package/lib/module/skia/web/JsiSkPictureRecorder.d.ts +1 -1
- package/lib/module/skia/web/JsiSkPictureRecorder.js +1 -1
- package/lib/module/skia/web/JsiSkPictureRecorder.js.map +1 -1
- package/lib/module/values/api.d.ts +23 -2
- package/lib/module/values/api.js +44 -1
- package/lib/module/values/api.js.map +1 -1
- package/lib/module/values/hooks/useClockValue.d.ts +3 -0
- package/lib/module/values/hooks/useClockValue.js +3 -0
- package/lib/module/values/hooks/useClockValue.js.map +1 -1
- package/lib/module/values/hooks/useComputedValue.d.ts +3 -0
- package/lib/module/values/hooks/useComputedValue.js +3 -0
- package/lib/module/values/hooks/useComputedValue.js.map +1 -1
- package/lib/module/values/hooks/useValue.d.ts +3 -0
- package/lib/module/values/hooks/useValue.js +3 -0
- package/lib/module/values/hooks/useValue.js.map +1 -1
- package/lib/module/values/hooks/useValueEffect.d.ts +3 -0
- package/lib/module/values/hooks/useValueEffect.js +3 -0
- package/lib/module/values/hooks/useValueEffect.js.map +1 -1
- package/lib/module/values/types.d.ts +4 -4
- package/lib/module/values/types.js.map +1 -1
- package/lib/module/views/SkiaView.d.ts +5 -0
- package/lib/module/views/SkiaView.js +10 -0
- package/lib/module/views/SkiaView.js.map +1 -1
- package/lib/typescript/src/animation/spring/runSpring.d.ts +3 -0
- package/lib/typescript/src/animation/spring/useSpring.d.ts +3 -0
- package/lib/typescript/src/animation/timing/runTiming.d.ts +3 -0
- package/lib/typescript/src/animation/timing/useLoop.d.ts +3 -0
- package/lib/typescript/src/animation/timing/useTiming.d.ts +3 -0
- package/lib/typescript/src/dom/nodes/datatypes/Fitting.d.ts +5 -5
- package/lib/typescript/src/dom/nodes/datatypes/Gradient.d.ts +235 -75
- package/lib/typescript/src/dom/types/Common.d.ts +3 -3
- package/lib/typescript/src/renderer/components/Drawing.d.ts +5 -0
- package/lib/typescript/src/renderer/components/shapes/FitBox.d.ts +5 -5
- package/lib/typescript/src/skia/core/Matrix.d.ts +2 -2
- package/lib/typescript/src/skia/core/Picture.d.ts +2 -2
- package/lib/typescript/src/skia/core/Vector.d.ts +3 -3
- package/lib/typescript/src/skia/types/Canvas.d.ts +1 -1
- package/lib/typescript/src/skia/types/Matrix.d.ts +4 -9
- package/lib/typescript/src/skia/types/Matrix4.d.ts +39 -0
- package/lib/typescript/src/skia/types/Path/Path.d.ts +1 -1
- package/lib/typescript/src/skia/types/Picture/PictureRecorder.d.ts +1 -1
- package/lib/typescript/src/skia/types/Rect.d.ts +1 -0
- package/lib/typescript/src/skia/types/index.d.ts +1 -0
- package/lib/typescript/src/skia/web/JsiSkCanvas.d.ts +1 -1
- package/lib/typescript/src/skia/web/JsiSkMatrix.d.ts +1 -1
- package/lib/typescript/src/skia/web/JsiSkPictureRecorder.d.ts +1 -1
- package/lib/typescript/src/values/api.d.ts +23 -2
- package/lib/typescript/src/values/hooks/useClockValue.d.ts +3 -0
- package/lib/typescript/src/values/hooks/useComputedValue.d.ts +3 -0
- package/lib/typescript/src/values/hooks/useValue.d.ts +3 -0
- package/lib/typescript/src/values/hooks/useValueEffect.d.ts +3 -0
- package/lib/typescript/src/values/types.d.ts +4 -4
- package/lib/typescript/src/views/SkiaView.d.ts +5 -0
- package/package.json +1 -1
- package/src/animation/spring/runSpring.ts +3 -0
- package/src/animation/spring/useSpring.ts +3 -0
- package/src/animation/timing/runTiming.ts +3 -0
- package/src/animation/timing/useLoop.ts +3 -0
- package/src/animation/timing/useTiming.ts +3 -0
- package/src/dom/nodes/JsiSkDOM.ts +4 -0
- package/src/dom/nodes/datatypes/Fitting.ts +10 -2
- package/src/dom/nodes/datatypes/Gradient.ts +2 -2
- package/src/dom/types/Common.ts +3 -3
- package/src/external/reanimated/interpolators.ts +14 -6
- package/src/renderer/Canvas.tsx +41 -30
- package/src/renderer/components/Drawing.tsx +5 -0
- package/src/skia/core/Matrix.ts +2 -2
- package/src/skia/core/Picture.ts +11 -3
- package/src/skia/core/Vector.ts +5 -2
- package/src/skia/types/Canvas.ts +1 -1
- package/src/skia/types/Matrix.ts +7 -74
- package/src/skia/types/Matrix4.ts +266 -0
- package/src/skia/types/Path/Path.ts +1 -1
- package/src/skia/types/Picture/PictureRecorder.ts +1 -1
- package/src/skia/types/Rect.ts +14 -0
- package/src/skia/types/index.ts +1 -0
- package/src/skia/web/JsiSkCanvas.ts +2 -2
- package/src/skia/web/JsiSkMatrix.ts +4 -2
- package/src/skia/web/JsiSkPath.ts +1 -1
- package/src/skia/web/JsiSkPictureRecorder.ts +6 -2
- package/src/values/api.ts +55 -2
- package/src/values/hooks/useClockValue.ts +3 -0
- package/src/values/hooks/useComputedValue.ts +3 -0
- package/src/values/hooks/useValue.ts +3 -0
- package/src/values/hooks/useValueEffect.ts +3 -0
- package/src/values/types.ts +6 -6
- package/src/views/SkiaView.tsx +11 -0
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import type {
|
|
2
|
-
export declare const processTransform2d: (transforms:
|
|
1
|
+
import type { Transforms3d } from "../types";
|
|
2
|
+
export declare const processTransform2d: (transforms: Transforms3d) => import("../types").SkMatrix;
|
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import type
|
|
1
|
+
import { type SkCanvas, type SkRect, type SkSize } from "../types";
|
|
2
2
|
/**
|
|
3
3
|
* Memoizes and returns an SkPicture that can be drawn to another canvas.
|
|
4
4
|
* @param rect Picture bounds
|
|
5
5
|
* @param cb Callback for drawing to the canvas
|
|
6
6
|
* @returns SkPicture
|
|
7
7
|
*/
|
|
8
|
-
export declare const createPicture: (
|
|
8
|
+
export declare const createPicture: (cb: (canvas: SkCanvas) => void, rect?: SkRect | SkSize) => import("../types").SkPicture;
|
|
@@ -5,8 +5,8 @@ export declare const neg: (a: Vector) => import("../types").SkPoint;
|
|
|
5
5
|
export declare const add: (a: Vector, b: Vector) => import("../types").SkPoint;
|
|
6
6
|
export declare const sub: (a: Vector, b: Vector) => import("../types").SkPoint;
|
|
7
7
|
export declare const dist: (a: Vector, b: Vector) => number;
|
|
8
|
-
export declare const translate: ({ x, y }: Vector) =>
|
|
9
|
-
|
|
8
|
+
export declare const translate: ({ x, y, }: Vector) => [{
|
|
9
|
+
translateX: number;
|
|
10
10
|
}, {
|
|
11
|
-
|
|
11
|
+
translateY: number;
|
|
12
12
|
}];
|
|
@@ -372,7 +372,7 @@ export interface SkCanvas {
|
|
|
372
372
|
* Replaces current matrix with m premultiplied with the existing matrix.
|
|
373
373
|
* @param m
|
|
374
374
|
*/
|
|
375
|
-
concat(m: SkMatrix): void;
|
|
375
|
+
concat(m: SkMatrix | number[]): void;
|
|
376
376
|
/**
|
|
377
377
|
* Draws the given picture using the current clip, current matrix, and the provided paint.
|
|
378
378
|
* @param skp
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import type { SkJSIInstance } from "./JsiInstance";
|
|
2
2
|
import type { SkCanvas } from "./Canvas";
|
|
3
|
+
import type { Transforms3d } from "./Matrix4";
|
|
3
4
|
export declare enum MatrixIndex {
|
|
4
5
|
ScaleX = 0,
|
|
5
6
|
SkewX = 1,
|
|
@@ -13,7 +14,7 @@ export declare enum MatrixIndex {
|
|
|
13
14
|
}
|
|
14
15
|
export declare const isMatrix: (obj: unknown) => obj is SkMatrix;
|
|
15
16
|
export interface SkMatrix extends SkJSIInstance<"Matrix"> {
|
|
16
|
-
concat: (matrix: SkMatrix) => SkMatrix;
|
|
17
|
+
concat: (matrix: SkMatrix | number[]) => SkMatrix;
|
|
17
18
|
translate: (x: number, y: number) => SkMatrix;
|
|
18
19
|
scale: (x: number, y?: number) => SkMatrix;
|
|
19
20
|
skew: (x: number, y: number) => SkMatrix;
|
|
@@ -25,14 +26,8 @@ export interface SkMatrix extends SkJSIInstance<"Matrix"> {
|
|
|
25
26
|
identity: () => SkMatrix;
|
|
26
27
|
get: () => number[];
|
|
27
28
|
}
|
|
28
|
-
type Transform2dName = "translateX" | "translateY" | "scale" | "skewX" | "skewY" | "scaleX" | "scaleY" | "rotateZ" | "rotate";
|
|
29
|
-
type Transformations = {
|
|
30
|
-
readonly [Name in Transform2dName]: number;
|
|
31
|
-
};
|
|
32
|
-
export type Transforms2d = readonly (Pick<Transformations, "translateX"> | Pick<Transformations, "translateY"> | Pick<Transformations, "scale"> | Pick<Transformations, "scaleX"> | Pick<Transformations, "scaleY"> | Pick<Transformations, "skewX"> | Pick<Transformations, "skewY"> | Pick<Transformations, "rotate">)[];
|
|
33
29
|
export interface TransformProp {
|
|
34
|
-
transform?:
|
|
30
|
+
transform?: Transforms3d;
|
|
35
31
|
}
|
|
36
|
-
export declare const processTransform: <T extends SkMatrix | SkCanvas>(m: T, transforms:
|
|
32
|
+
export declare const processTransform: <T extends SkMatrix | SkCanvas>(m: T, transforms: Transforms3d) => T;
|
|
37
33
|
export declare const toDegrees: (rad: number) => number;
|
|
38
|
-
export {};
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
type Vec2 = readonly [number, number];
|
|
2
|
+
type Vec3 = readonly [number, number, number];
|
|
3
|
+
export type Matrix4 = readonly [
|
|
4
|
+
number,
|
|
5
|
+
number,
|
|
6
|
+
number,
|
|
7
|
+
number,
|
|
8
|
+
number,
|
|
9
|
+
number,
|
|
10
|
+
number,
|
|
11
|
+
number,
|
|
12
|
+
number,
|
|
13
|
+
number,
|
|
14
|
+
number,
|
|
15
|
+
number,
|
|
16
|
+
number,
|
|
17
|
+
number,
|
|
18
|
+
number,
|
|
19
|
+
number
|
|
20
|
+
];
|
|
21
|
+
type Transform3dName = "translateX" | "translateY" | "translateZ" | "translate" | "scale" | "scaleX" | "scaleY" | "skewX" | "skewY" | "rotateZ" | "rotate" | "perspective" | "rotateX" | "rotateY" | "matrix";
|
|
22
|
+
type Transformations = {
|
|
23
|
+
[Name in Transform3dName]: Name extends "matrix" ? Matrix4 : Name extends "translate" ? Vec3 | Vec2 : number;
|
|
24
|
+
};
|
|
25
|
+
type Transform3d = Pick<Transformations, "translateX"> | Pick<Transformations, "translateY"> | Pick<Transformations, "translateZ"> | Pick<Transformations, "translate"> | Pick<Transformations, "scale"> | Pick<Transformations, "scaleX"> | Pick<Transformations, "scaleY"> | Pick<Transformations, "skewX"> | Pick<Transformations, "skewY"> | Pick<Transformations, "perspective"> | Pick<Transformations, "rotateX"> | Pick<Transformations, "rotateY"> | Pick<Transformations, "rotateZ"> | Pick<Transformations, "rotate"> | Pick<Transformations, "matrix">;
|
|
26
|
+
export type Transforms3d = Transform3d[];
|
|
27
|
+
/**
|
|
28
|
+
* @worklet
|
|
29
|
+
*/
|
|
30
|
+
export declare const Matrix4: () => Matrix4;
|
|
31
|
+
/**
|
|
32
|
+
* @worklet
|
|
33
|
+
*/
|
|
34
|
+
export declare const mapPoint3d: (m: Matrix4, v: Vec3) => readonly [number, number, number];
|
|
35
|
+
/**
|
|
36
|
+
* @worklet
|
|
37
|
+
*/
|
|
38
|
+
export declare const processTransform3d: (transforms: Transforms3d) => number[];
|
|
39
|
+
export {};
|
|
@@ -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: SkMatrix): SkPath;
|
|
443
|
+
transform(m3: SkMatrix | number[]): 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
|
|
@@ -7,7 +7,7 @@ export interface SkPictureRecorder {
|
|
|
7
7
|
*
|
|
8
8
|
* @param bounds - a rect to cull the results.
|
|
9
9
|
*/
|
|
10
|
-
beginRecording(bounds
|
|
10
|
+
beginRecording(bounds?: SkRect): SkCanvas;
|
|
11
11
|
/**
|
|
12
12
|
* Returns the captured draw commands as a picture and invalidates the canvas returned earlier.
|
|
13
13
|
*/
|
|
@@ -40,7 +40,7 @@ export declare class JsiSkCanvas extends HostObject<Canvas, "Canvas"> implements
|
|
|
40
40
|
clipPath(path: SkPath, op: ClipOp, doAntiAlias: boolean): void;
|
|
41
41
|
clipRect(rect: SkRect, op: ClipOp, doAntiAlias: boolean): void;
|
|
42
42
|
clipRRect(rrect: SkRRect, op: ClipOp, doAntiAlias: boolean): void;
|
|
43
|
-
concat(m: SkMatrix): void;
|
|
43
|
+
concat(m: SkMatrix | number[]): void;
|
|
44
44
|
drawPicture(skp: SkPicture): void;
|
|
45
45
|
readPixels(srcX: number, srcY: number, imageInfo: ImageInfo): Float32Array | Uint8Array | null;
|
|
46
46
|
}
|
|
@@ -6,7 +6,7 @@ export declare class JsiSkMatrix extends HostObject<Matrix3x3, "Matrix"> impleme
|
|
|
6
6
|
private preMultiply;
|
|
7
7
|
private postMultiply;
|
|
8
8
|
dispose: () => void;
|
|
9
|
-
concat(matrix: SkMatrix): this;
|
|
9
|
+
concat(matrix: SkMatrix | number[]): this;
|
|
10
10
|
translate(x: number, y: number): this;
|
|
11
11
|
postTranslate(x: number, y: number): this;
|
|
12
12
|
scale(x: number, y?: number): this;
|
|
@@ -7,6 +7,6 @@ import { JsiSkPicture } from "./JsiSkPicture";
|
|
|
7
7
|
export declare class JsiSkPictureRecorder extends HostObject<PictureRecorder, "PictureRecorder"> implements SkPictureRecorder {
|
|
8
8
|
constructor(CanvasKit: CanvasKit, ref: PictureRecorder);
|
|
9
9
|
dispose: () => void;
|
|
10
|
-
beginRecording(bounds
|
|
10
|
+
beginRecording(bounds?: SkRect): JsiSkCanvas;
|
|
11
11
|
finishRecordingAsPicture(): JsiSkPicture;
|
|
12
12
|
}
|
|
@@ -1,5 +1,26 @@
|
|
|
1
|
-
import type { ISkiaValueApi } from "./types";
|
|
1
|
+
import type { AnimationState, ISkiaValueApi, SkiaAnimation, SkiaClockValue, SkiaMutableValue, SkiaValue } from "./types";
|
|
2
2
|
declare global {
|
|
3
3
|
var SkiaValueApi: ISkiaValueApi;
|
|
4
4
|
}
|
|
5
|
-
export declare const ValueApi:
|
|
5
|
+
export declare const ValueApi: {
|
|
6
|
+
/**
|
|
7
|
+
* @deprecated Use Reanimated 3
|
|
8
|
+
* for animating Skia: https://shopify.github.io/react-native-skia/docs/animations/animations
|
|
9
|
+
*/
|
|
10
|
+
createValue<T>(initialValue: T): SkiaMutableValue<T>;
|
|
11
|
+
/**
|
|
12
|
+
* @deprecated Use Reanimated 3
|
|
13
|
+
* for animating Skia: https://shopify.github.io/react-native-skia/docs/animations/animations
|
|
14
|
+
*/
|
|
15
|
+
createComputedValue<R>(cb: () => R, values: SkiaValue<unknown>[]): SkiaValue<R>;
|
|
16
|
+
/**
|
|
17
|
+
* @deprecated Use Reanimated 3
|
|
18
|
+
* for animating Skia: https://shopify.github.io/react-native-skia/docs/animations/animations
|
|
19
|
+
*/
|
|
20
|
+
createClockValue(): SkiaClockValue;
|
|
21
|
+
/**
|
|
22
|
+
* @deprecated Use Reanimated 3
|
|
23
|
+
* for animating Skia: https://shopify.github.io/react-native-skia/docs/animations/animations
|
|
24
|
+
*/
|
|
25
|
+
createAnimation<S extends AnimationState = AnimationState>(cb: (t: number, state: S | undefined) => S): SkiaAnimation;
|
|
26
|
+
};
|
|
@@ -1,4 +1,7 @@
|
|
|
1
1
|
/**
|
|
2
|
+
* @deprecated Use Reanimated 3
|
|
3
|
+
* for animating Skia: https://shopify.github.io/react-native-skia/docs/animations/animations
|
|
4
|
+
*
|
|
2
5
|
* @returns A new value that will be updated on every frame redraw with the
|
|
3
6
|
* number of milliseconds elapsed since the value was started.
|
|
4
7
|
* The clock is created in the stopped state.
|
|
@@ -1,4 +1,7 @@
|
|
|
1
1
|
/**
|
|
2
|
+
* @deprecated Use Reanimated 3
|
|
3
|
+
* for animating Skia: https://shopify.github.io/react-native-skia/docs/animations/animations
|
|
4
|
+
*
|
|
2
5
|
* Creates a new computed value - a value that will calculate its value depending
|
|
3
6
|
* on other values.
|
|
4
7
|
* @param cb Callback to calculate new value
|
|
@@ -1,5 +1,8 @@
|
|
|
1
1
|
import type { SkiaMutableValue } from "../types";
|
|
2
2
|
/**
|
|
3
|
+
* @deprecated Use Reanimated 3
|
|
4
|
+
* for animating Skia: https://shopify.github.io/react-native-skia/docs/animations/animations
|
|
5
|
+
*
|
|
3
6
|
* Creates a new value that holds some data.
|
|
4
7
|
* @param v Value to hold
|
|
5
8
|
* @returns A Value of type of v
|
|
@@ -1,5 +1,8 @@
|
|
|
1
1
|
import type { SkiaValue } from "../types";
|
|
2
2
|
/**
|
|
3
|
+
* @deprecated Use Reanimated 3
|
|
4
|
+
* for animating Skia: https://shopify.github.io/react-native-skia/docs/animations/animations
|
|
5
|
+
*
|
|
3
6
|
* Sets up an effect that will be run whenever the value changes
|
|
4
7
|
* @param value Value to subscribe to changes on
|
|
5
8
|
* @param cb Callback to run when value changes
|
|
@@ -43,21 +43,21 @@ export interface ISkiaValueApi {
|
|
|
43
43
|
* Creates a new value that holds the initial value and that
|
|
44
44
|
* can be changed.
|
|
45
45
|
*/
|
|
46
|
-
createValue
|
|
46
|
+
createValue<T>(initialValue: T): SkiaMutableValue<T>;
|
|
47
47
|
/**
|
|
48
48
|
* Creates a computed value. This is a calculated value that returns the result of
|
|
49
49
|
* a function that is called with the values of the dependencies.
|
|
50
50
|
*/
|
|
51
|
-
createComputedValue
|
|
51
|
+
createComputedValue<R>(cb: () => R, values: Array<SkiaValue<unknown>>): SkiaValue<R>;
|
|
52
52
|
/**
|
|
53
53
|
* Creates a clock value where the value is the number of milliseconds elapsed
|
|
54
54
|
* since the clock was created
|
|
55
55
|
*/
|
|
56
|
-
createClockValue
|
|
56
|
+
createClockValue(): SkiaClockValue;
|
|
57
57
|
/**
|
|
58
58
|
* Creates an animation that is driven from a clock and updated every frame.
|
|
59
59
|
* @param cb Callback to calculate next value from time.
|
|
60
60
|
* @returns An animation object that can control a value.
|
|
61
61
|
*/
|
|
62
|
-
createAnimation
|
|
62
|
+
createAnimation<S extends AnimationState = AnimationState>(cb: (t: number, state: S | undefined) => S): SkiaAnimation;
|
|
63
63
|
}
|
|
@@ -5,6 +5,11 @@ import type { SkiaDrawViewProps } from "./types";
|
|
|
5
5
|
export declare const SkiaViewNativeId: {
|
|
6
6
|
current: number;
|
|
7
7
|
};
|
|
8
|
+
/**
|
|
9
|
+
* @deprecated If you are looking to use the Skia imperative API, you can use:
|
|
10
|
+
* The picture API: https://shopify.github.io/react-native-skia/docs/shapes/pictures/
|
|
11
|
+
* The offscreen API: https://shopify.github.io/react-native-skia/docs/animations/textures
|
|
12
|
+
*/
|
|
8
13
|
export declare class SkiaView extends React.Component<SkiaDrawViewProps> {
|
|
9
14
|
constructor(props: SkiaDrawViewProps);
|
|
10
15
|
private _nativeId;
|
package/package.json
CHANGED
|
@@ -10,6 +10,9 @@ import { Spring } from "./Spring";
|
|
|
10
10
|
import { createSpringEasing } from "./functions/spring";
|
|
11
11
|
|
|
12
12
|
/**
|
|
13
|
+
* @deprecated Use Reanimated 3 for animations:
|
|
14
|
+
* https://shopify.github.io/react-native-skia/docs/animations/animations
|
|
15
|
+
*
|
|
13
16
|
* Creates a new animation on an existing value that will be driven by
|
|
14
17
|
* an animation value. The value will be run from / to the value in
|
|
15
18
|
* params and modified by the provided easing curve for the length of
|
|
@@ -10,6 +10,9 @@ import { Spring } from "./Spring";
|
|
|
10
10
|
import { createSpringEasing } from "./functions/spring";
|
|
11
11
|
|
|
12
12
|
/**
|
|
13
|
+
* @deprecated Use Reanimated 3 for animations:
|
|
14
|
+
* https://shopify.github.io/react-native-skia/docs/animations/animations
|
|
15
|
+
*
|
|
13
16
|
* Creats a spring based animation value that will run whenever
|
|
14
17
|
* the animation parameters change.
|
|
15
18
|
* @param toOrParams
|
|
@@ -8,6 +8,9 @@ import type {
|
|
|
8
8
|
import { getResolvedParams } from "./functions";
|
|
9
9
|
import { createTiming } from "./createTiming";
|
|
10
10
|
/**
|
|
11
|
+
* @deprecated Use Reanimated 3 for animations:
|
|
12
|
+
* https://shopify.github.io/react-native-skia/docs/animations/animations
|
|
13
|
+
*
|
|
11
14
|
* Creates a new animation on an existing value that will be driven by
|
|
12
15
|
* an animation value. The value will be run from / to the value in
|
|
13
16
|
* params and modified by the provided easing curve for the length of
|
|
@@ -3,6 +3,9 @@ import type { TimingConfig } from "../types";
|
|
|
3
3
|
import { useTiming } from "./useTiming";
|
|
4
4
|
|
|
5
5
|
/**
|
|
6
|
+
* @deprecated Use Reanimated 3 for animations:
|
|
7
|
+
* https://shopify.github.io/react-native-skia/docs/animations/animations
|
|
8
|
+
*
|
|
6
9
|
* Configures a looped timing value. The value will go back and forth
|
|
7
10
|
* between 0 and 1 and back.
|
|
8
11
|
* @param config Timing configuration for easing and duration
|
|
@@ -12,6 +12,9 @@ import { getResolvedParams } from "./functions";
|
|
|
12
12
|
import { createTiming } from "./createTiming";
|
|
13
13
|
|
|
14
14
|
/**
|
|
15
|
+
* @deprecated Use Reanimated 3 for animations:
|
|
16
|
+
* https://shopify.github.io/react-native-skia/docs/animations/animations
|
|
17
|
+
*
|
|
15
18
|
* Creats an animation value that will run whenever
|
|
16
19
|
* the animation parameters change. The animation start immediately.
|
|
17
20
|
* @param toOrParams
|
|
@@ -173,6 +173,10 @@ export class JsiSkDOM implements SkDOM {
|
|
|
173
173
|
}
|
|
174
174
|
|
|
175
175
|
CustomDrawing(props: CustomDrawingNodeProps) {
|
|
176
|
+
console.warn(
|
|
177
|
+
// eslint-disable-next-line max-len
|
|
178
|
+
"The <Drawing /> component is deprecated and will be removed in the next release. For custom drawings, please sure the <Picture /> component: https://shopify.github.io/react-native-skia/docs/shapes/pictures/"
|
|
179
|
+
);
|
|
176
180
|
return NATIVE_DOM
|
|
177
181
|
? global.SkiaDomApi.CustomDrawingNode(props ?? {})
|
|
178
182
|
: new CustomDrawingNode(this.ctx, props);
|
|
@@ -9,12 +9,20 @@ export interface Size {
|
|
|
9
9
|
|
|
10
10
|
export const size = (width = 0, height = 0) => ({ width, height });
|
|
11
11
|
|
|
12
|
-
export const rect2rect = (
|
|
12
|
+
export const rect2rect = (
|
|
13
|
+
src: SkRect,
|
|
14
|
+
dst: SkRect
|
|
15
|
+
): [
|
|
16
|
+
{ translateX: number },
|
|
17
|
+
{ translateY: number },
|
|
18
|
+
{ scaleX: number },
|
|
19
|
+
{ scaleY: number }
|
|
20
|
+
] => {
|
|
13
21
|
const scaleX = dst.width / src.width;
|
|
14
22
|
const scaleY = dst.height / src.height;
|
|
15
23
|
const translateX = dst.x - src.x * scaleX;
|
|
16
24
|
const translateY = dst.y - src.y * scaleY;
|
|
17
|
-
return [{ translateX }, { translateY }, { scaleX }, { scaleY }]
|
|
25
|
+
return [{ translateX }, { translateY }, { scaleX }, { scaleY }];
|
|
18
26
|
};
|
|
19
27
|
|
|
20
28
|
export const fitRects = (
|
|
@@ -1,11 +1,11 @@
|
|
|
1
|
-
import type { Skia, SkRect,
|
|
1
|
+
import type { Skia, SkRect, Transforms3d, Vector } from "../../../skia/types";
|
|
2
2
|
import { TileMode } from "../../../skia/types";
|
|
3
3
|
import type { GradientProps, ImageShaderProps } from "../../types";
|
|
4
4
|
|
|
5
5
|
import { enumKey } from "./Enum";
|
|
6
6
|
import { processTransformProps } from "./Transform";
|
|
7
7
|
|
|
8
|
-
export const transformOrigin = (origin: Vector, transform:
|
|
8
|
+
export const transformOrigin = (origin: Vector, transform: Transforms3d) => [
|
|
9
9
|
{ translateX: origin.x },
|
|
10
10
|
{ translateY: origin.y },
|
|
11
11
|
...transform,
|
package/src/dom/types/Common.ts
CHANGED
|
@@ -11,7 +11,7 @@ import type {
|
|
|
11
11
|
SkRRect,
|
|
12
12
|
StrokeCap,
|
|
13
13
|
StrokeJoin,
|
|
14
|
-
|
|
14
|
+
Transforms3d,
|
|
15
15
|
Vector,
|
|
16
16
|
} from "../../skia/types";
|
|
17
17
|
|
|
@@ -64,9 +64,9 @@ export interface ScalarCircleDef {
|
|
|
64
64
|
export type CircleDef = PointCircleDef | ScalarCircleDef;
|
|
65
65
|
|
|
66
66
|
export interface TransformProps {
|
|
67
|
-
transform?:
|
|
67
|
+
transform?: Transforms3d;
|
|
68
68
|
origin?: Vector;
|
|
69
|
-
matrix?: SkMatrix;
|
|
69
|
+
matrix?: SkMatrix | number[];
|
|
70
70
|
}
|
|
71
71
|
|
|
72
72
|
export interface PaintProps extends ChildrenProps {
|
|
@@ -1,5 +1,9 @@
|
|
|
1
|
-
import type {
|
|
2
|
-
|
|
1
|
+
import type {
|
|
2
|
+
ExtrapolationType,
|
|
3
|
+
FrameInfo,
|
|
4
|
+
SharedValue,
|
|
5
|
+
} from "react-native-reanimated";
|
|
6
|
+
import { useMemo, useRef } from "react";
|
|
3
7
|
|
|
4
8
|
import type { SkPath, SkPoint } from "../../skia/types";
|
|
5
9
|
import { interpolatePaths, interpolateVector } from "../../animation";
|
|
@@ -13,15 +17,19 @@ import {
|
|
|
13
17
|
|
|
14
18
|
export const notifyChange = (value: SharedValue<unknown>) => {
|
|
15
19
|
"worklet";
|
|
16
|
-
|
|
17
|
-
|
|
20
|
+
if (_WORKLET) {
|
|
21
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
22
|
+
(value as any)._value = value.value;
|
|
23
|
+
}
|
|
18
24
|
};
|
|
19
25
|
|
|
20
26
|
export const useClock = () => {
|
|
21
27
|
const clock = useSharedValue(0);
|
|
22
|
-
|
|
28
|
+
const callback = useRef((info: FrameInfo) => {
|
|
29
|
+
"worklet";
|
|
23
30
|
clock.value = info.timeSinceFirstFrame;
|
|
24
|
-
});
|
|
31
|
+
}).current;
|
|
32
|
+
useFrameCallback(callback);
|
|
25
33
|
return clock;
|
|
26
34
|
};
|
|
27
35
|
|
package/src/renderer/Canvas.tsx
CHANGED
|
@@ -4,7 +4,6 @@ import React, {
|
|
|
4
4
|
useMemo,
|
|
5
5
|
forwardRef,
|
|
6
6
|
useRef,
|
|
7
|
-
useLayoutEffect,
|
|
8
7
|
} from "react";
|
|
9
8
|
import type {
|
|
10
9
|
RefObject,
|
|
@@ -13,13 +12,13 @@ import type {
|
|
|
13
12
|
ForwardedRef,
|
|
14
13
|
FunctionComponent,
|
|
15
14
|
} from "react";
|
|
15
|
+
import type { LayoutChangeEvent } from "react-native";
|
|
16
16
|
|
|
17
|
-
import { SkiaDomView,
|
|
17
|
+
import { SkiaDomView, SkiaPictureView } from "../views";
|
|
18
18
|
import { Skia } from "../skia/Skia";
|
|
19
19
|
import type { TouchHandler, SkiaBaseViewProps } from "../views";
|
|
20
20
|
import type { SkiaValue } from "../values/types";
|
|
21
21
|
import { JsiDrawingContext } from "../dom/types";
|
|
22
|
-
import { useValue } from "../values";
|
|
23
22
|
|
|
24
23
|
import { SkiaRoot } from "./Reconciler";
|
|
25
24
|
import { NATIVE_DOM } from "./HostComponents";
|
|
@@ -33,34 +32,42 @@ export interface CanvasProps extends SkiaBaseViewProps {
|
|
|
33
32
|
onTouch?: TouchHandler;
|
|
34
33
|
}
|
|
35
34
|
|
|
36
|
-
const useOnSizeEvent = (
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
35
|
+
const useOnSizeEvent = (
|
|
36
|
+
resultValue: SkiaBaseViewProps["onSize"],
|
|
37
|
+
onLayout?: (event: LayoutChangeEvent) => void
|
|
38
|
+
) => {
|
|
39
|
+
return useCallback(
|
|
40
|
+
(event: LayoutChangeEvent) => {
|
|
41
|
+
if (onLayout) {
|
|
42
|
+
onLayout(event);
|
|
43
|
+
}
|
|
44
|
+
const { width, height } = event.nativeEvent.layout;
|
|
41
45
|
|
|
42
|
-
useLayoutEffect(() => {
|
|
43
|
-
if (!resultValue) {
|
|
44
|
-
return;
|
|
45
|
-
}
|
|
46
|
-
return onSize.addListener((newValue) => {
|
|
47
46
|
if (isValue(resultValue)) {
|
|
48
|
-
resultValue.current =
|
|
49
|
-
} else {
|
|
50
|
-
resultValue.value =
|
|
47
|
+
resultValue.current = { width, height };
|
|
48
|
+
} else if (resultValue) {
|
|
49
|
+
resultValue.value = { width, height };
|
|
51
50
|
}
|
|
52
|
-
}
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
return onSize;
|
|
51
|
+
},
|
|
52
|
+
[onLayout, resultValue]
|
|
53
|
+
);
|
|
56
54
|
};
|
|
57
55
|
|
|
58
56
|
export const Canvas = forwardRef<SkiaDomView, CanvasProps>(
|
|
59
57
|
(
|
|
60
|
-
{
|
|
58
|
+
{
|
|
59
|
+
children,
|
|
60
|
+
style,
|
|
61
|
+
debug,
|
|
62
|
+
mode,
|
|
63
|
+
onTouch,
|
|
64
|
+
onSize: _onSize,
|
|
65
|
+
onLayout: _onLayout,
|
|
66
|
+
...props
|
|
67
|
+
},
|
|
61
68
|
forwardedRef
|
|
62
69
|
) => {
|
|
63
|
-
const
|
|
70
|
+
const onLayout = useOnSizeEvent(_onSize, _onLayout);
|
|
64
71
|
const innerRef = useCanvasRef();
|
|
65
72
|
const ref = useCombinedRefs(forwardedRef, innerRef);
|
|
66
73
|
const redraw = useCallback(() => {
|
|
@@ -102,26 +109,30 @@ export const Canvas = forwardRef<SkiaDomView, CanvasProps>(
|
|
|
102
109
|
style={style}
|
|
103
110
|
root={root.dom}
|
|
104
111
|
onTouch={onTouch}
|
|
105
|
-
|
|
112
|
+
onLayout={onLayout}
|
|
106
113
|
mode={mode}
|
|
107
114
|
debug={debug}
|
|
108
115
|
{...props}
|
|
109
116
|
/>
|
|
110
117
|
);
|
|
111
118
|
} else {
|
|
119
|
+
// This is for debugging
|
|
120
|
+
const recorder = Skia.PictureRecorder();
|
|
121
|
+
const canvas = recorder.beginRecording(
|
|
122
|
+
Skia.XYWHRect(0, 0, 2_000_000, 2_000_000)
|
|
123
|
+
);
|
|
124
|
+
const ctx = new JsiDrawingContext(Skia, canvas);
|
|
125
|
+
root.dom.render(ctx);
|
|
126
|
+
const picture = recorder.finishRecordingAsPicture();
|
|
112
127
|
return (
|
|
113
|
-
<
|
|
128
|
+
<SkiaPictureView
|
|
114
129
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
115
130
|
ref={ref as any}
|
|
116
131
|
style={style}
|
|
117
132
|
mode={mode}
|
|
118
133
|
debug={debug}
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
onTouch && onTouch(info.touches);
|
|
122
|
-
const ctx = new JsiDrawingContext(Skia, canvas);
|
|
123
|
-
root.dom.render(ctx);
|
|
124
|
-
}}
|
|
134
|
+
picture={picture}
|
|
135
|
+
onLayout={onLayout}
|
|
125
136
|
{...props}
|
|
126
137
|
/>
|
|
127
138
|
);
|
|
@@ -2,6 +2,11 @@ import React from "react";
|
|
|
2
2
|
|
|
3
3
|
import type { CustomDrawingNodeProps } from "../../dom/types";
|
|
4
4
|
|
|
5
|
+
/**
|
|
6
|
+
* @deprecated If you are looking to use the Skia imperative API, you can use:
|
|
7
|
+
* The picture API: https://shopify.github.io/react-native-skia/docs/shapes/pictures/
|
|
8
|
+
* The offscreen API: https://shopify.github.io/react-native-skia/docs/animations/textures
|
|
9
|
+
*/
|
|
5
10
|
export const Drawing = (props: CustomDrawingNodeProps) => {
|
|
6
11
|
return <skDrawing {...props} />;
|
|
7
12
|
};
|
package/src/skia/core/Matrix.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { Skia } from "../Skia";
|
|
2
|
-
import type {
|
|
2
|
+
import type { Transforms3d } from "../types";
|
|
3
3
|
import { processTransform } from "../types";
|
|
4
4
|
|
|
5
|
-
export const processTransform2d = (transforms:
|
|
5
|
+
export const processTransform2d = (transforms: Transforms3d) =>
|
|
6
6
|
processTransform(Skia.Matrix(), transforms);
|
package/src/skia/core/Picture.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { Skia } from "../Skia";
|
|
2
|
-
import type
|
|
2
|
+
import { isRect, type SkCanvas, type SkRect, type SkSize } from "../types";
|
|
3
3
|
|
|
4
4
|
/**
|
|
5
5
|
* Memoizes and returns an SkPicture that can be drawn to another canvas.
|
|
@@ -7,9 +7,17 @@ import type { SkCanvas, SkRect } from "../types";
|
|
|
7
7
|
* @param cb Callback for drawing to the canvas
|
|
8
8
|
* @returns SkPicture
|
|
9
9
|
*/
|
|
10
|
-
export const createPicture = (
|
|
10
|
+
export const createPicture = (
|
|
11
|
+
cb: (canvas: SkCanvas) => void,
|
|
12
|
+
rect?: SkRect | SkSize
|
|
13
|
+
) => {
|
|
14
|
+
"worklet";
|
|
11
15
|
const recorder = Skia.PictureRecorder();
|
|
12
|
-
|
|
16
|
+
let bounds: undefined | SkRect;
|
|
17
|
+
if (rect) {
|
|
18
|
+
bounds = isRect(rect) ? rect : Skia.XYWHRect(0, 0, rect.width, rect.height);
|
|
19
|
+
}
|
|
20
|
+
const canvas = recorder.beginRecording(bounds);
|
|
13
21
|
cb(canvas);
|
|
14
22
|
return recorder.finishRecordingAsPicture();
|
|
15
23
|
};
|
package/src/skia/core/Vector.ts
CHANGED
|
@@ -22,7 +22,10 @@ export const dist = (a: Vector, b: Vector) => {
|
|
|
22
22
|
"worklet";
|
|
23
23
|
return Math.hypot(a.x - b.x, a.y - b.y);
|
|
24
24
|
};
|
|
25
|
-
export const translate = ({
|
|
25
|
+
export const translate = ({
|
|
26
|
+
x,
|
|
27
|
+
y,
|
|
28
|
+
}: Vector): [{ translateX: number }, { translateY: number }] => {
|
|
26
29
|
"worklet";
|
|
27
|
-
return [{ translateX: x }, { translateY: y }]
|
|
30
|
+
return [{ translateX: x }, { translateY: y }];
|
|
28
31
|
};
|