@shopify/react-native-skia 2.5.5 → 2.6.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/cpp/api/CustomBlendModes.h +1 -0
- package/cpp/api/JsiSkApi.h +4 -0
- package/cpp/api/JsiSkCanvas.h +2 -2
- package/cpp/api/JsiSkContourMeasureIter.h +1 -1
- package/cpp/api/JsiSkPath.h +483 -355
- package/cpp/api/JsiSkPathBuilder.h +415 -0
- package/cpp/api/JsiSkPathBuilderFactory.h +53 -0
- package/cpp/api/JsiSkPathEffectFactory.h +2 -2
- package/cpp/api/JsiSkPathFactory.h +274 -3
- package/cpp/api/recorder/DataTypes.h +1 -1
- package/cpp/api/recorder/Drawings.h +6 -2
- package/cpp/rnskia/RNDawnContext.h +21 -0
- package/cpp/rnskia/RNDawnUtils.h +115 -113
- package/lib/commonjs/animation/functions/interpolatePaths.d.ts +1 -1
- package/lib/commonjs/animation/functions/interpolatePaths.js +5 -4
- package/lib/commonjs/animation/functions/interpolatePaths.js.map +1 -1
- package/lib/commonjs/external/reanimated/interpolators.d.ts +11 -2
- package/lib/commonjs/external/reanimated/interpolators.js +21 -4
- package/lib/commonjs/external/reanimated/interpolators.js.map +1 -1
- package/lib/commonjs/skia/types/Path/PathBuilder.d.ts +201 -0
- package/lib/commonjs/skia/types/Path/PathBuilder.js +6 -0
- package/lib/commonjs/skia/types/Path/PathBuilder.js.map +1 -0
- package/lib/commonjs/skia/types/Path/PathBuilderFactory.d.ts +13 -0
- package/lib/commonjs/skia/types/Path/PathBuilderFactory.js +6 -0
- package/lib/commonjs/skia/types/Path/PathBuilderFactory.js.map +1 -0
- package/lib/commonjs/skia/types/Path/PathFactory.d.ts +87 -1
- package/lib/commonjs/skia/types/Path/PathFactory.js.map +1 -1
- package/lib/commonjs/skia/types/Path/index.d.ts +2 -0
- package/lib/commonjs/skia/types/Path/index.js +22 -0
- package/lib/commonjs/skia/types/Path/index.js.map +1 -1
- package/lib/commonjs/skia/types/Skia.d.ts +2 -1
- package/lib/commonjs/skia/types/Skia.js.map +1 -1
- package/lib/commonjs/skia/web/Host.js +1 -3
- package/lib/commonjs/skia/web/Host.js.map +1 -1
- package/lib/commonjs/skia/web/JsiSkCanvas.js +6 -2
- package/lib/commonjs/skia/web/JsiSkCanvas.js.map +1 -1
- package/lib/commonjs/skia/web/JsiSkContourMeasure.js +4 -1
- package/lib/commonjs/skia/web/JsiSkContourMeasure.js.map +1 -1
- package/lib/commonjs/skia/web/JsiSkPath.d.ts +42 -30
- package/lib/commonjs/skia/web/JsiSkPath.js +302 -111
- package/lib/commonjs/skia/web/JsiSkPath.js.map +1 -1
- package/lib/commonjs/skia/web/JsiSkPathBuilder.d.ts +45 -0
- package/lib/commonjs/skia/web/JsiSkPathBuilder.js +192 -0
- package/lib/commonjs/skia/web/JsiSkPathBuilder.js.map +1 -0
- package/lib/commonjs/skia/web/JsiSkPathBuilderFactory.d.ts +9 -0
- package/lib/commonjs/skia/web/JsiSkPathBuilderFactory.js +26 -0
- package/lib/commonjs/skia/web/JsiSkPathBuilderFactory.js.map +1 -0
- package/lib/commonjs/skia/web/JsiSkPathEffectFactory.js +6 -2
- package/lib/commonjs/skia/web/JsiSkPathEffectFactory.js.map +1 -1
- package/lib/commonjs/skia/web/JsiSkPathFactory.d.ts +13 -1
- package/lib/commonjs/skia/web/JsiSkPathFactory.js +140 -5
- package/lib/commonjs/skia/web/JsiSkPathFactory.js.map +1 -1
- package/lib/commonjs/skia/web/JsiSkia.js +8 -1
- package/lib/commonjs/skia/web/JsiSkia.js.map +1 -1
- package/lib/commonjs/sksg/Recorder/commands/Drawing.js +18 -6
- package/lib/commonjs/sksg/Recorder/commands/Drawing.js.map +1 -1
- package/lib/commonjs/specs/SkiaPictureViewNativeComponent.d.ts +2 -2
- package/lib/commonjs/specs/SkiaPictureViewNativeComponent.js +2 -3
- package/lib/commonjs/specs/SkiaPictureViewNativeComponent.js.map +1 -1
- package/lib/commonjs/specs/WebGPUViewNativeComponent.d.ts +2 -2
- package/lib/commonjs/specs/WebGPUViewNativeComponent.js +2 -3
- package/lib/commonjs/specs/WebGPUViewNativeComponent.js.map +1 -1
- package/lib/commonjs/specs/WebGPUViewNativeComponent.web.js +2 -0
- package/lib/commonjs/specs/WebGPUViewNativeComponent.web.js.map +1 -1
- package/lib/module/animation/functions/interpolatePaths.d.ts +1 -1
- package/lib/module/animation/functions/interpolatePaths.js +5 -4
- package/lib/module/animation/functions/interpolatePaths.js.map +1 -1
- package/lib/module/external/reanimated/interpolators.d.ts +11 -2
- package/lib/module/external/reanimated/interpolators.js +21 -4
- package/lib/module/external/reanimated/interpolators.js.map +1 -1
- package/lib/module/skia/types/Path/PathBuilder.d.ts +201 -0
- package/lib/module/skia/types/Path/PathBuilder.js +2 -0
- package/lib/module/skia/types/Path/PathBuilder.js.map +1 -0
- package/lib/module/skia/types/Path/PathBuilderFactory.d.ts +13 -0
- package/lib/module/skia/types/Path/PathBuilderFactory.js +2 -0
- package/lib/module/skia/types/Path/PathBuilderFactory.js.map +1 -0
- package/lib/module/skia/types/Path/PathFactory.d.ts +87 -1
- package/lib/module/skia/types/Path/PathFactory.js.map +1 -1
- package/lib/module/skia/types/Path/index.d.ts +2 -0
- package/lib/module/skia/types/Path/index.js +2 -0
- package/lib/module/skia/types/Path/index.js.map +1 -1
- package/lib/module/skia/types/Skia.d.ts +2 -1
- package/lib/module/skia/types/Skia.js.map +1 -1
- package/lib/module/skia/web/Host.js +1 -3
- package/lib/module/skia/web/Host.js.map +1 -1
- package/lib/module/skia/web/JsiSkCanvas.js +6 -2
- package/lib/module/skia/web/JsiSkCanvas.js.map +1 -1
- package/lib/module/skia/web/JsiSkContourMeasure.js +4 -1
- package/lib/module/skia/web/JsiSkContourMeasure.js.map +1 -1
- package/lib/module/skia/web/JsiSkPath.d.ts +42 -30
- package/lib/module/skia/web/JsiSkPath.js +300 -110
- package/lib/module/skia/web/JsiSkPath.js.map +1 -1
- package/lib/module/skia/web/JsiSkPathBuilder.d.ts +45 -0
- package/lib/module/skia/web/JsiSkPathBuilder.js +186 -0
- package/lib/module/skia/web/JsiSkPathBuilder.js.map +1 -0
- package/lib/module/skia/web/JsiSkPathBuilderFactory.d.ts +9 -0
- package/lib/module/skia/web/JsiSkPathBuilderFactory.js +19 -0
- package/lib/module/skia/web/JsiSkPathBuilderFactory.js.map +1 -0
- package/lib/module/skia/web/JsiSkPathEffectFactory.js +6 -2
- package/lib/module/skia/web/JsiSkPathEffectFactory.js.map +1 -1
- package/lib/module/skia/web/JsiSkPathFactory.d.ts +13 -1
- package/lib/module/skia/web/JsiSkPathFactory.js +141 -6
- package/lib/module/skia/web/JsiSkPathFactory.js.map +1 -1
- package/lib/module/skia/web/JsiSkia.js +8 -1
- package/lib/module/skia/web/JsiSkia.js.map +1 -1
- package/lib/module/sksg/Recorder/commands/Drawing.js +18 -6
- package/lib/module/sksg/Recorder/commands/Drawing.js.map +1 -1
- package/lib/module/specs/SkiaPictureViewNativeComponent.d.ts +2 -2
- package/lib/module/specs/SkiaPictureViewNativeComponent.js +1 -1
- package/lib/module/specs/SkiaPictureViewNativeComponent.js.map +1 -1
- package/lib/module/specs/WebGPUViewNativeComponent.d.ts +2 -2
- package/lib/module/specs/WebGPUViewNativeComponent.js +1 -1
- package/lib/module/specs/WebGPUViewNativeComponent.js.map +1 -1
- package/lib/module/specs/WebGPUViewNativeComponent.web.js +2 -0
- package/lib/module/specs/WebGPUViewNativeComponent.web.js.map +1 -1
- package/lib/typescript/lib/commonjs/animation/functions/interpolatePaths.d.ts +1 -1
- package/lib/typescript/lib/commonjs/external/reanimated/interpolators.d.ts +1 -1
- package/lib/typescript/lib/commonjs/skia/types/Path/PathBuilder.d.ts +1 -0
- package/lib/typescript/lib/commonjs/skia/types/Path/PathBuilderFactory.d.ts +1 -0
- package/lib/typescript/lib/commonjs/skia/web/JsiSkPath.d.ts +33 -25
- package/lib/typescript/lib/commonjs/skia/web/JsiSkPathBuilder.d.ts +46 -0
- package/lib/typescript/lib/commonjs/skia/web/JsiSkPathBuilderFactory.d.ts +7 -0
- package/lib/typescript/lib/commonjs/skia/web/JsiSkPathFactory.d.ts +12 -0
- package/lib/typescript/lib/commonjs/skia/web/JsiSkia.d.ts +2 -0
- package/lib/typescript/lib/commonjs/specs/SkiaPictureViewNativeComponent.d.ts +2 -1
- package/lib/typescript/lib/commonjs/specs/WebGPUViewNativeComponent.d.ts +2 -1
- package/lib/typescript/lib/module/animation/functions/interpolatePaths.d.ts +1 -1
- package/lib/typescript/lib/module/external/reanimated/interpolators.d.ts +1 -1
- package/lib/typescript/lib/module/mock/index.d.ts +1 -1
- package/lib/typescript/lib/module/skia/Skia.web.d.ts +1 -0
- package/lib/typescript/lib/module/skia/types/Path/PathBuilder.d.ts +1 -0
- package/lib/typescript/lib/module/skia/types/Path/PathBuilderFactory.d.ts +1 -0
- package/lib/typescript/lib/module/skia/types/Path/index.d.ts +2 -0
- package/lib/typescript/lib/module/skia/web/JsiSkPath.d.ts +38 -25
- package/lib/typescript/lib/module/skia/web/JsiSkPathBuilder.d.ts +45 -0
- package/lib/typescript/lib/module/skia/web/JsiSkPathBuilderFactory.d.ts +6 -0
- package/lib/typescript/lib/module/skia/web/JsiSkPathFactory.d.ts +12 -0
- package/lib/typescript/lib/module/skia/web/JsiSkia.d.ts +2 -0
- package/lib/typescript/lib/module/specs/SkiaPictureViewNativeComponent.d.ts +1 -1
- package/lib/typescript/lib/module/specs/WebGPUViewNativeComponent.d.ts +1 -1
- package/lib/typescript/src/animation/functions/interpolatePaths.d.ts +1 -1
- package/lib/typescript/src/external/reanimated/interpolators.d.ts +11 -2
- package/lib/typescript/src/skia/types/Path/PathBuilder.d.ts +201 -0
- package/lib/typescript/src/skia/types/Path/PathBuilderFactory.d.ts +13 -0
- package/lib/typescript/src/skia/types/Path/PathFactory.d.ts +87 -1
- package/lib/typescript/src/skia/types/Path/index.d.ts +2 -0
- package/lib/typescript/src/skia/types/Skia.d.ts +2 -1
- package/lib/typescript/src/skia/web/JsiSkPath.d.ts +42 -30
- package/lib/typescript/src/skia/web/JsiSkPathBuilder.d.ts +45 -0
- package/lib/typescript/src/skia/web/JsiSkPathBuilderFactory.d.ts +9 -0
- package/lib/typescript/src/skia/web/JsiSkPathFactory.d.ts +13 -1
- package/lib/typescript/src/specs/SkiaPictureViewNativeComponent.d.ts +2 -2
- package/lib/typescript/src/specs/WebGPUViewNativeComponent.d.ts +2 -2
- package/package.json +3 -2
- package/scripts/install-libs.js +16 -6
- package/src/animation/functions/interpolatePaths.ts +5 -6
- package/src/external/reanimated/interpolators.ts +25 -5
- package/src/skia/types/Path/PathBuilder.ts +303 -0
- package/src/skia/types/Path/PathBuilderFactory.ts +15 -0
- package/src/skia/types/Path/PathFactory.ts +108 -1
- package/src/skia/types/Path/index.ts +2 -0
- package/src/skia/types/Skia.ts +2 -1
- package/src/skia/web/Host.ts +7 -1
- package/src/skia/web/JsiSkCanvas.ts +6 -6
- package/src/skia/web/JsiSkContourMeasure.ts +4 -4
- package/src/skia/web/JsiSkPath.ts +451 -168
- package/src/skia/web/JsiSkPathBuilder.ts +293 -0
- package/src/skia/web/JsiSkPathBuilderFactory.ts +32 -0
- package/src/skia/web/JsiSkPathEffectFactory.ts +6 -2
- package/src/skia/web/JsiSkPathFactory.ts +231 -8
- package/src/skia/web/JsiSkia.ts +11 -8
- package/src/sksg/Recorder/commands/Drawing.ts +20 -7
- package/src/specs/SkiaPictureViewNativeComponent.ts +1 -2
- package/src/specs/WebGPUViewNativeComponent.ts +2 -2
- package/src/specs/WebGPUViewNativeComponent.web.ts +2 -0
|
@@ -1,10 +1,11 @@
|
|
|
1
1
|
import { exhaustiveCheck } from "../../renderer/typeddash";
|
|
2
2
|
import { validateInterpolationOptions, Extrapolate } from "./interpolate";
|
|
3
|
-
const lerp = (value, from, to, p1, p2
|
|
3
|
+
const lerp = (value, from, to, p1, p2) => {
|
|
4
4
|
"worklet";
|
|
5
5
|
|
|
6
6
|
const t = (value - from) / (to - from);
|
|
7
|
-
|
|
7
|
+
// interpolate returns a new path (immutable operation)
|
|
8
|
+
return p2.interpolate(p1, t);
|
|
8
9
|
};
|
|
9
10
|
|
|
10
11
|
/**
|
|
@@ -23,7 +24,7 @@ const lerp = (value, from, to, p1, p2, output) => {
|
|
|
23
24
|
* path2.lineTo(0, 100);
|
|
24
25
|
* const path = interpolatePath(0.5, [0, 1], [path1, path2]);
|
|
25
26
|
*/
|
|
26
|
-
export const interpolatePaths = (value, input, outputRange, options,
|
|
27
|
+
export const interpolatePaths = (value, input, outputRange, options, _output) => {
|
|
27
28
|
"worklet";
|
|
28
29
|
|
|
29
30
|
const extrapolation = validateInterpolationOptions(options);
|
|
@@ -56,6 +57,6 @@ export const interpolatePaths = (value, input, outputRange, options, output) =>
|
|
|
56
57
|
break;
|
|
57
58
|
}
|
|
58
59
|
}
|
|
59
|
-
return lerp(value, input[i], input[i + 1], outputRange[i], outputRange[i + 1]
|
|
60
|
+
return lerp(value, input[i], input[i + 1], outputRange[i], outputRange[i + 1]);
|
|
60
61
|
};
|
|
61
62
|
//# sourceMappingURL=interpolatePaths.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["exhaustiveCheck","validateInterpolationOptions","Extrapolate","lerp","value","from","to","p1","p2","
|
|
1
|
+
{"version":3,"names":["exhaustiveCheck","validateInterpolationOptions","Extrapolate","lerp","value","from","to","p1","p2","t","interpolate","interpolatePaths","input","outputRange","options","_output","extrapolation","extrapolateLeft","CLAMP","EXTEND","IDENTITY","Error","length","extrapolateRight","i"],"sources":["interpolatePaths.ts"],"sourcesContent":["import type { SkPath } from \"../../skia/types\";\nimport { exhaustiveCheck } from \"../../renderer/typeddash\";\n\nimport type { ExtrapolationType } from \"./interpolate\";\nimport { validateInterpolationOptions, Extrapolate } from \"./interpolate\";\n\nconst lerp = (\n value: number,\n from: number,\n to: number,\n p1: SkPath,\n p2: SkPath\n) => {\n \"worklet\";\n const t = (value - from) / (to - from);\n // interpolate returns a new path (immutable operation)\n return p2.interpolate(p1, t)!;\n};\n\n/**\n * Maps an input value within a range to an output path within a path range.\n * @param value - The input value.\n * @param inputRange - The range of the input value.\n * @param outputRange - The range of the output path.\n * @param options - Extrapolation options\n * @returns The output path.\n * @example <caption>Map a value between 0 and 1 to a path between two paths.</caption>\n * const path1 = new Path();\n * path1.moveTo(0, 0);\n * path1.lineTo(100, 0);\n * const path2 = new Path();\n * path2.moveTo(0, 0);\n * path2.lineTo(0, 100);\n * const path = interpolatePath(0.5, [0, 1], [path1, path2]);\n */\nexport const interpolatePaths = (\n value: number,\n input: number[],\n outputRange: SkPath[],\n options?: ExtrapolationType,\n _output?: SkPath\n) => {\n \"worklet\";\n const extrapolation = validateInterpolationOptions(options);\n if (value < input[0]) {\n switch (extrapolation.extrapolateLeft) {\n case Extrapolate.CLAMP:\n return outputRange[0];\n case Extrapolate.EXTEND:\n return lerp(value, input[0], input[1], outputRange[0], outputRange[1]);\n case Extrapolate.IDENTITY:\n throw new Error(\n \"Identity is not a supported extrapolation type for interpolatePaths()\"\n );\n default:\n exhaustiveCheck(extrapolation.extrapolateLeft);\n }\n } else if (value > input[input.length - 1]) {\n switch (extrapolation.extrapolateRight) {\n case Extrapolate.CLAMP:\n return outputRange[outputRange.length - 1];\n case Extrapolate.EXTEND:\n return lerp(\n value,\n input[input.length - 2],\n input[input.length - 1],\n outputRange[input.length - 2],\n outputRange[input.length - 1]\n );\n case Extrapolate.IDENTITY:\n throw new Error(\n \"Identity is not a supported extrapolation type for interpolatePaths()\"\n );\n default:\n exhaustiveCheck(extrapolation.extrapolateRight);\n }\n }\n let i = 0;\n for (; i <= input.length - 1; i++) {\n if (value >= input[i] && value <= input[i + 1]) {\n break;\n }\n }\n return lerp(\n value,\n input[i],\n input[i + 1],\n outputRange[i],\n outputRange[i + 1]\n );\n};\n"],"mappings":"AACA,SAASA,eAAe,QAAQ,0BAA0B;AAG1D,SAASC,4BAA4B,EAAEC,WAAW,QAAQ,eAAe;AAEzE,MAAMC,IAAI,GAAGA,CACXC,KAAa,EACbC,IAAY,EACZC,EAAU,EACVC,EAAU,EACVC,EAAU,KACP;EACH,SAAS;;EACT,MAAMC,CAAC,GAAG,CAACL,KAAK,GAAGC,IAAI,KAAKC,EAAE,GAAGD,IAAI,CAAC;EACtC;EACA,OAAOG,EAAE,CAACE,WAAW,CAACH,EAAE,EAAEE,CAAC,CAAC;AAC9B,CAAC;;AAED;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,OAAO,MAAME,gBAAgB,GAAGA,CAC9BP,KAAa,EACbQ,KAAe,EACfC,WAAqB,EACrBC,OAA2B,EAC3BC,OAAgB,KACb;EACH,SAAS;;EACT,MAAMC,aAAa,GAAGf,4BAA4B,CAACa,OAAO,CAAC;EAC3D,IAAIV,KAAK,GAAGQ,KAAK,CAAC,CAAC,CAAC,EAAE;IACpB,QAAQI,aAAa,CAACC,eAAe;MACnC,KAAKf,WAAW,CAACgB,KAAK;QACpB,OAAOL,WAAW,CAAC,CAAC,CAAC;MACvB,KAAKX,WAAW,CAACiB,MAAM;QACrB,OAAOhB,IAAI,CAACC,KAAK,EAAEQ,KAAK,CAAC,CAAC,CAAC,EAAEA,KAAK,CAAC,CAAC,CAAC,EAAEC,WAAW,CAAC,CAAC,CAAC,EAAEA,WAAW,CAAC,CAAC,CAAC,CAAC;MACxE,KAAKX,WAAW,CAACkB,QAAQ;QACvB,MAAM,IAAIC,KAAK,CACb,uEACF,CAAC;MACH;QACErB,eAAe,CAACgB,aAAa,CAACC,eAAe,CAAC;IAClD;EACF,CAAC,MAAM,IAAIb,KAAK,GAAGQ,KAAK,CAACA,KAAK,CAACU,MAAM,GAAG,CAAC,CAAC,EAAE;IAC1C,QAAQN,aAAa,CAACO,gBAAgB;MACpC,KAAKrB,WAAW,CAACgB,KAAK;QACpB,OAAOL,WAAW,CAACA,WAAW,CAACS,MAAM,GAAG,CAAC,CAAC;MAC5C,KAAKpB,WAAW,CAACiB,MAAM;QACrB,OAAOhB,IAAI,CACTC,KAAK,EACLQ,KAAK,CAACA,KAAK,CAACU,MAAM,GAAG,CAAC,CAAC,EACvBV,KAAK,CAACA,KAAK,CAACU,MAAM,GAAG,CAAC,CAAC,EACvBT,WAAW,CAACD,KAAK,CAACU,MAAM,GAAG,CAAC,CAAC,EAC7BT,WAAW,CAACD,KAAK,CAACU,MAAM,GAAG,CAAC,CAC9B,CAAC;MACH,KAAKpB,WAAW,CAACkB,QAAQ;QACvB,MAAM,IAAIC,KAAK,CACb,uEACF,CAAC;MACH;QACErB,eAAe,CAACgB,aAAa,CAACO,gBAAgB,CAAC;IACnD;EACF;EACA,IAAIC,CAAC,GAAG,CAAC;EACT,OAAOA,CAAC,IAAIZ,KAAK,CAACU,MAAM,GAAG,CAAC,EAAEE,CAAC,EAAE,EAAE;IACjC,IAAIpB,KAAK,IAAIQ,KAAK,CAACY,CAAC,CAAC,IAAIpB,KAAK,IAAIQ,KAAK,CAACY,CAAC,GAAG,CAAC,CAAC,EAAE;MAC9C;IACF;EACF;EACA,OAAOrB,IAAI,CACTC,KAAK,EACLQ,KAAK,CAACY,CAAC,CAAC,EACRZ,KAAK,CAACY,CAAC,GAAG,CAAC,CAAC,EACZX,WAAW,CAACW,CAAC,CAAC,EACdX,WAAW,CAACW,CAAC,GAAG,CAAC,CACnB,CAAC;AACH,CAAC","ignoreList":[]}
|
|
@@ -1,7 +1,16 @@
|
|
|
1
1
|
import type { ExtrapolationType, SharedValue } from "react-native-reanimated";
|
|
2
|
-
import type { SkPath, SkPoint } from "../../skia/types";
|
|
2
|
+
import type { SkPath, SkPathBuilder, SkPoint } from "../../skia/types";
|
|
3
3
|
export declare const notifyChange: <T>(value: SharedValue<T>) => void;
|
|
4
|
-
|
|
4
|
+
/**
|
|
5
|
+
* Hook for creating animated paths using PathBuilder.
|
|
6
|
+
* The callback receives a mutable PathBuilder that can be used to construct the path.
|
|
7
|
+
* The resulting immutable SkPath is stored in a shared value.
|
|
8
|
+
*
|
|
9
|
+
* @param cb - Callback that receives the PathBuilder to construct the path
|
|
10
|
+
* @param init - Optional initial path to add to the builder
|
|
11
|
+
* @param transform - Optional transform function applied to the built path
|
|
12
|
+
*/
|
|
13
|
+
export declare const usePathValue: (cb: (builder: SkPathBuilder) => void, init?: SkPath, transform?: (path: SkPath) => SkPath) => SharedValue<SkPath>;
|
|
5
14
|
export declare const useClock: () => SharedValue<number>;
|
|
6
15
|
export declare const usePathInterpolation: (value: SharedValue<number>, input: number[], outputRange: SkPath[], options?: ExtrapolationType) => SharedValue<SkPath>;
|
|
7
16
|
export declare const useVectorInterpolation: (value: SharedValue<number>, input: number[], outputRange: SkPoint[], options?: ExtrapolationType) => SharedValue<SkPoint>;
|
|
@@ -11,15 +11,32 @@ export const notifyChange = value => {
|
|
|
11
11
|
value._value = value.value;
|
|
12
12
|
}
|
|
13
13
|
};
|
|
14
|
-
|
|
14
|
+
|
|
15
|
+
/**
|
|
16
|
+
* Hook for creating animated paths using PathBuilder.
|
|
17
|
+
* The callback receives a mutable PathBuilder that can be used to construct the path.
|
|
18
|
+
* The resulting immutable SkPath is stored in a shared value.
|
|
19
|
+
*
|
|
20
|
+
* @param cb - Callback that receives the PathBuilder to construct the path
|
|
21
|
+
* @param init - Optional initial path to add to the builder
|
|
22
|
+
* @param transform - Optional transform function applied to the built path
|
|
23
|
+
*/
|
|
24
|
+
export const usePathValue = (cb, init, transform) => {
|
|
25
|
+
const builderInit = useMemo(() => Skia.PathBuilder.Make(), []);
|
|
15
26
|
const pathInit = useMemo(() => Skia.Path.Make(), []);
|
|
27
|
+
const builder = Rea.useSharedValue(builderInit);
|
|
16
28
|
const path = Rea.useSharedValue(pathInit);
|
|
17
29
|
Rea.useDerivedValue(() => {
|
|
18
|
-
|
|
30
|
+
builder.value.reset();
|
|
19
31
|
if (init !== undefined) {
|
|
20
|
-
|
|
32
|
+
builder.value.addPath(init);
|
|
33
|
+
}
|
|
34
|
+
cb(builder.value);
|
|
35
|
+
let result = builder.value.build();
|
|
36
|
+
if (transform !== undefined) {
|
|
37
|
+
result = transform(result);
|
|
21
38
|
}
|
|
22
|
-
|
|
39
|
+
path.value = result;
|
|
23
40
|
notifyChange(path);
|
|
24
41
|
});
|
|
25
42
|
return path;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["useCallback","useMemo","interpolatePaths","interpolateVector","Skia","isOnMainThread","Rea","notifyChange","value","_value","usePathValue","cb","init","
|
|
1
|
+
{"version":3,"names":["useCallback","useMemo","interpolatePaths","interpolateVector","Skia","isOnMainThread","Rea","notifyChange","value","_value","usePathValue","cb","init","transform","builderInit","PathBuilder","Make","pathInit","Path","builder","useSharedValue","path","useDerivedValue","reset","undefined","addPath","result","build","useClock","clock","callback","info","timeSinceFirstFrame","useFrameCallback","useInterpolator","factory","interpolator","input","output","options","useAnimatedReaction","val","usePathInterpolation","outputRange","allPathsInterpolable","slice","every","isInterpolatable","Error","useVectorInterpolation","Point"],"sources":["interpolators.ts"],"sourcesContent":["import type {\n ExtrapolationType,\n FrameInfo,\n SharedValue,\n} from \"react-native-reanimated\";\nimport { useCallback, useMemo } from \"react\";\n\nimport type { SkPath, SkPathBuilder, SkPoint } from \"../../skia/types\";\nimport { interpolatePaths, interpolateVector } from \"../../animation\";\nimport { Skia } from \"../../skia\";\nimport { isOnMainThread } from \"../../renderer/Offscreen\";\n\nimport Rea from \"./ReanimatedProxy\";\n\nexport const notifyChange = <T>(value: SharedValue<T>) => {\n \"worklet\";\n if (isOnMainThread()) {\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n (value as any)._value = value.value;\n }\n};\n\n/**\n * Hook for creating animated paths using PathBuilder.\n * The callback receives a mutable PathBuilder that can be used to construct the path.\n * The resulting immutable SkPath is stored in a shared value.\n *\n * @param cb - Callback that receives the PathBuilder to construct the path\n * @param init - Optional initial path to add to the builder\n * @param transform - Optional transform function applied to the built path\n */\nexport const usePathValue = (\n cb: (builder: SkPathBuilder) => void,\n init?: SkPath,\n transform?: (path: SkPath) => SkPath\n) => {\n const builderInit = useMemo(() => Skia.PathBuilder.Make(), []);\n const pathInit = useMemo(() => Skia.Path.Make(), []);\n const builder = Rea.useSharedValue(builderInit);\n const path = Rea.useSharedValue(pathInit);\n Rea.useDerivedValue(() => {\n builder.value.reset();\n if (init !== undefined) {\n builder.value.addPath(init);\n }\n cb(builder.value);\n let result = builder.value.build();\n if (transform !== undefined) {\n result = transform(result);\n }\n path.value = result;\n notifyChange(path);\n });\n return path;\n};\n\nexport const useClock = () => {\n const clock = Rea.useSharedValue(0);\n const callback = useCallback(\n (info: FrameInfo) => {\n \"worklet\";\n clock.value = info.timeSinceFirstFrame;\n },\n [clock]\n );\n Rea.useFrameCallback(callback);\n return clock;\n};\n\n/**\n * @worklet\n */\ntype Interpolator<T> = (\n value: number,\n input: number[],\n output: T[],\n options: ExtrapolationType,\n result: T\n) => T;\n\nconst useInterpolator = <T>(\n factory: () => T,\n value: SharedValue<number>,\n interpolator: Interpolator<T>,\n input: number[],\n output: T[],\n options?: ExtrapolationType\n) => {\n // eslint-disable-next-line react-hooks/exhaustive-deps\n const init = useMemo(() => factory(), []);\n const result = Rea.useSharedValue(init);\n Rea.useAnimatedReaction(\n () => value.value,\n (val) => {\n result.value = interpolator(val, input, output, options, result.value);\n notifyChange(result);\n },\n [input, output, options]\n );\n return result;\n};\n\nexport const usePathInterpolation = (\n value: SharedValue<number>,\n input: number[],\n outputRange: SkPath[],\n options?: ExtrapolationType\n) => {\n // Check if all paths in outputRange are interpolable\n const allPathsInterpolable = outputRange\n .slice(1)\n .every((path) => outputRange[0].isInterpolatable(path));\n if (!allPathsInterpolable) {\n // Handle the case where not all paths are interpolable\n // For example, throw an error or return early\n throw new Error(\n `Not all paths in the output range are interpolable.\nSee: https://shopify.github.io/react-native-skia/docs/animations/hooks#usepathinterpolation`\n );\n }\n return useInterpolator(\n () => Skia.Path.Make(),\n value,\n interpolatePaths,\n input,\n outputRange,\n options\n );\n};\n\nexport const useVectorInterpolation = (\n value: SharedValue<number>,\n input: number[],\n outputRange: SkPoint[],\n options?: ExtrapolationType\n) =>\n useInterpolator(\n () => Skia.Point(0, 0),\n value,\n interpolateVector,\n input,\n outputRange,\n options\n );\n"],"mappings":"AAKA,SAASA,WAAW,EAAEC,OAAO,QAAQ,OAAO;AAG5C,SAASC,gBAAgB,EAAEC,iBAAiB,QAAQ,iBAAiB;AACrE,SAASC,IAAI,QAAQ,YAAY;AACjC,SAASC,cAAc,QAAQ,0BAA0B;AAEzD,OAAOC,GAAG,MAAM,mBAAmB;AAEnC,OAAO,MAAMC,YAAY,GAAOC,KAAqB,IAAK;EACxD,SAAS;;EACT,IAAIH,cAAc,CAAC,CAAC,EAAE;IACpB;IACCG,KAAK,CAASC,MAAM,GAAGD,KAAK,CAACA,KAAK;EACrC;AACF,CAAC;;AAED;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,OAAO,MAAME,YAAY,GAAGA,CAC1BC,EAAoC,EACpCC,IAAa,EACbC,SAAoC,KACjC;EACH,MAAMC,WAAW,GAAGb,OAAO,CAAC,MAAMG,IAAI,CAACW,WAAW,CAACC,IAAI,CAAC,CAAC,EAAE,EAAE,CAAC;EAC9D,MAAMC,QAAQ,GAAGhB,OAAO,CAAC,MAAMG,IAAI,CAACc,IAAI,CAACF,IAAI,CAAC,CAAC,EAAE,EAAE,CAAC;EACpD,MAAMG,OAAO,GAAGb,GAAG,CAACc,cAAc,CAACN,WAAW,CAAC;EAC/C,MAAMO,IAAI,GAAGf,GAAG,CAACc,cAAc,CAACH,QAAQ,CAAC;EACzCX,GAAG,CAACgB,eAAe,CAAC,MAAM;IACxBH,OAAO,CAACX,KAAK,CAACe,KAAK,CAAC,CAAC;IACrB,IAAIX,IAAI,KAAKY,SAAS,EAAE;MACtBL,OAAO,CAACX,KAAK,CAACiB,OAAO,CAACb,IAAI,CAAC;IAC7B;IACAD,EAAE,CAACQ,OAAO,CAACX,KAAK,CAAC;IACjB,IAAIkB,MAAM,GAAGP,OAAO,CAACX,KAAK,CAACmB,KAAK,CAAC,CAAC;IAClC,IAAId,SAAS,KAAKW,SAAS,EAAE;MAC3BE,MAAM,GAAGb,SAAS,CAACa,MAAM,CAAC;IAC5B;IACAL,IAAI,CAACb,KAAK,GAAGkB,MAAM;IACnBnB,YAAY,CAACc,IAAI,CAAC;EACpB,CAAC,CAAC;EACF,OAAOA,IAAI;AACb,CAAC;AAED,OAAO,MAAMO,QAAQ,GAAGA,CAAA,KAAM;EAC5B,MAAMC,KAAK,GAAGvB,GAAG,CAACc,cAAc,CAAC,CAAC,CAAC;EACnC,MAAMU,QAAQ,GAAG9B,WAAW,CACzB+B,IAAe,IAAK;IACnB,SAAS;;IACTF,KAAK,CAACrB,KAAK,GAAGuB,IAAI,CAACC,mBAAmB;EACxC,CAAC,EACD,CAACH,KAAK,CACR,CAAC;EACDvB,GAAG,CAAC2B,gBAAgB,CAACH,QAAQ,CAAC;EAC9B,OAAOD,KAAK;AACd,CAAC;;AAED;AACA;AACA;;AASA,MAAMK,eAAe,GAAGA,CACtBC,OAAgB,EAChB3B,KAA0B,EAC1B4B,YAA6B,EAC7BC,KAAe,EACfC,MAAW,EACXC,OAA2B,KACxB;EACH;EACA,MAAM3B,IAAI,GAAGX,OAAO,CAAC,MAAMkC,OAAO,CAAC,CAAC,EAAE,EAAE,CAAC;EACzC,MAAMT,MAAM,GAAGpB,GAAG,CAACc,cAAc,CAACR,IAAI,CAAC;EACvCN,GAAG,CAACkC,mBAAmB,CACrB,MAAMhC,KAAK,CAACA,KAAK,EAChBiC,GAAG,IAAK;IACPf,MAAM,CAAClB,KAAK,GAAG4B,YAAY,CAACK,GAAG,EAAEJ,KAAK,EAAEC,MAAM,EAAEC,OAAO,EAAEb,MAAM,CAAClB,KAAK,CAAC;IACtED,YAAY,CAACmB,MAAM,CAAC;EACtB,CAAC,EACD,CAACW,KAAK,EAAEC,MAAM,EAAEC,OAAO,CACzB,CAAC;EACD,OAAOb,MAAM;AACf,CAAC;AAED,OAAO,MAAMgB,oBAAoB,GAAGA,CAClClC,KAA0B,EAC1B6B,KAAe,EACfM,WAAqB,EACrBJ,OAA2B,KACxB;EACH;EACA,MAAMK,oBAAoB,GAAGD,WAAW,CACrCE,KAAK,CAAC,CAAC,CAAC,CACRC,KAAK,CAAEzB,IAAI,IAAKsB,WAAW,CAAC,CAAC,CAAC,CAACI,gBAAgB,CAAC1B,IAAI,CAAC,CAAC;EACzD,IAAI,CAACuB,oBAAoB,EAAE;IACzB;IACA;IACA,MAAM,IAAII,KAAK,CACb;AACN,4FACI,CAAC;EACH;EACA,OAAOd,eAAe,CACpB,MAAM9B,IAAI,CAACc,IAAI,CAACF,IAAI,CAAC,CAAC,EACtBR,KAAK,EACLN,gBAAgB,EAChBmC,KAAK,EACLM,WAAW,EACXJ,OACF,CAAC;AACH,CAAC;AAED,OAAO,MAAMU,sBAAsB,GAAGA,CACpCzC,KAA0B,EAC1B6B,KAAe,EACfM,WAAsB,EACtBJ,OAA2B,KAE3BL,eAAe,CACb,MAAM9B,IAAI,CAAC8C,KAAK,CAAC,CAAC,EAAE,CAAC,CAAC,EACtB1C,KAAK,EACLL,iBAAiB,EACjBkC,KAAK,EACLM,WAAW,EACXJ,OACF,CAAC","ignoreList":[]}
|
|
@@ -0,0 +1,201 @@
|
|
|
1
|
+
import type { SkRect } from "../Rect";
|
|
2
|
+
import type { SkPoint } from "../Point";
|
|
3
|
+
import type { InputRRect } from "../RRect";
|
|
4
|
+
import type { InputMatrix, SkMatrix } from "../Matrix";
|
|
5
|
+
import type { SkJSIInstance } from "../JsiInstance";
|
|
6
|
+
import type { FillType, SkPath } from "./Path";
|
|
7
|
+
/**
|
|
8
|
+
* SkPathBuilder is a mutable builder for constructing SkPath objects.
|
|
9
|
+
* Once construction is complete, call build() or detach() to get the immutable SkPath.
|
|
10
|
+
*/
|
|
11
|
+
export interface SkPathBuilder extends SkJSIInstance<"PathBuilder"> {
|
|
12
|
+
/**
|
|
13
|
+
* Adds beginning of contour at point (x, y).
|
|
14
|
+
* @param x - x-axis value of contour start
|
|
15
|
+
* @param y - y-axis value of contour start
|
|
16
|
+
* @returns reference to this PathBuilder for chaining
|
|
17
|
+
*/
|
|
18
|
+
moveTo(x: number, y: number): SkPathBuilder;
|
|
19
|
+
/**
|
|
20
|
+
* Adds beginning of contour relative to the last point.
|
|
21
|
+
* @param x - offset from last point on x-axis
|
|
22
|
+
* @param y - offset from last point on y-axis
|
|
23
|
+
* @returns reference to this PathBuilder for chaining
|
|
24
|
+
*/
|
|
25
|
+
rMoveTo(x: number, y: number): SkPathBuilder;
|
|
26
|
+
/**
|
|
27
|
+
* Adds line from last point to (x, y).
|
|
28
|
+
* @param x - end of line on x-axis
|
|
29
|
+
* @param y - end of line on y-axis
|
|
30
|
+
* @returns reference to this PathBuilder for chaining
|
|
31
|
+
*/
|
|
32
|
+
lineTo(x: number, y: number): SkPathBuilder;
|
|
33
|
+
/**
|
|
34
|
+
* Adds line from last point, relative to last point.
|
|
35
|
+
* @param x - offset from last point on x-axis
|
|
36
|
+
* @param y - offset from last point on y-axis
|
|
37
|
+
* @returns reference to this PathBuilder for chaining
|
|
38
|
+
*/
|
|
39
|
+
rLineTo(x: number, y: number): SkPathBuilder;
|
|
40
|
+
/**
|
|
41
|
+
* Adds quad from last point towards (x1, y1), to (x2, y2).
|
|
42
|
+
*/
|
|
43
|
+
quadTo(x1: number, y1: number, x2: number, y2: number): SkPathBuilder;
|
|
44
|
+
/**
|
|
45
|
+
* Relative version of quadTo.
|
|
46
|
+
*/
|
|
47
|
+
rQuadTo(x1: number, y1: number, x2: number, y2: number): SkPathBuilder;
|
|
48
|
+
/**
|
|
49
|
+
* Adds conic from last point towards (x1, y1), to (x2, y2), weighted by w.
|
|
50
|
+
*/
|
|
51
|
+
conicTo(x1: number, y1: number, x2: number, y2: number, w: number): SkPathBuilder;
|
|
52
|
+
/**
|
|
53
|
+
* Relative version of conicTo.
|
|
54
|
+
*/
|
|
55
|
+
rConicTo(x1: number, y1: number, x2: number, y2: number, w: number): SkPathBuilder;
|
|
56
|
+
/**
|
|
57
|
+
* Adds cubic from last point towards (x1, y1), then towards (x2, y2), ending at (x3, y3).
|
|
58
|
+
*/
|
|
59
|
+
cubicTo(x1: number, y1: number, x2: number, y2: number, x3: number, y3: number): SkPathBuilder;
|
|
60
|
+
/**
|
|
61
|
+
* Relative version of cubicTo.
|
|
62
|
+
*/
|
|
63
|
+
rCubicTo(x1: number, y1: number, x2: number, y2: number, x3: number, y3: number): SkPathBuilder;
|
|
64
|
+
/**
|
|
65
|
+
* Appends CLOSE_VERB to the builder, connecting first and last points.
|
|
66
|
+
*/
|
|
67
|
+
close(): SkPathBuilder;
|
|
68
|
+
/**
|
|
69
|
+
* Appends arc to the builder. Arc is part of ellipse bounded by oval.
|
|
70
|
+
* @param oval - bounds of ellipse containing arc
|
|
71
|
+
* @param startAngleInDegrees - starting angle of arc in degrees
|
|
72
|
+
* @param sweepAngleInDegrees - sweep, in degrees. Positive is clockwise
|
|
73
|
+
* @param forceMoveTo - true to start a new contour with arc
|
|
74
|
+
*/
|
|
75
|
+
arcToOval(oval: SkRect, startAngleInDegrees: number, sweepAngleInDegrees: number, forceMoveTo: boolean): SkPathBuilder;
|
|
76
|
+
/**
|
|
77
|
+
* Appends arc to the builder with SVG-style parameters.
|
|
78
|
+
* @param rx - x-radius of ellipse
|
|
79
|
+
* @param ry - y-radius of ellipse
|
|
80
|
+
* @param xAxisRotateInDegrees - rotation of ellipse
|
|
81
|
+
* @param useSmallArc - if true, use smaller of two arcs
|
|
82
|
+
* @param isCCW - if true, arc sweeps counter-clockwise
|
|
83
|
+
* @param x - end point x
|
|
84
|
+
* @param y - end point y
|
|
85
|
+
*/
|
|
86
|
+
arcToRotated(rx: number, ry: number, xAxisRotateInDegrees: number, useSmallArc: boolean, isCCW: boolean, x: number, y: number): SkPathBuilder;
|
|
87
|
+
/**
|
|
88
|
+
* Relative version of arcToRotated.
|
|
89
|
+
*/
|
|
90
|
+
rArcTo(rx: number, ry: number, xAxisRotateInDegrees: number, useSmallArc: boolean, isCCW: boolean, dx: number, dy: number): SkPathBuilder;
|
|
91
|
+
/**
|
|
92
|
+
* Appends arc to the builder, tangent to two lines.
|
|
93
|
+
* @param x1 - x of first tangent point
|
|
94
|
+
* @param y1 - y of first tangent point
|
|
95
|
+
* @param x2 - x of second tangent point
|
|
96
|
+
* @param y2 - y of second tangent point
|
|
97
|
+
* @param radius - arc radius
|
|
98
|
+
*/
|
|
99
|
+
arcToTangent(x1: number, y1: number, x2: number, y2: number, radius: number): SkPathBuilder;
|
|
100
|
+
/**
|
|
101
|
+
* Adds Rect to the builder.
|
|
102
|
+
* @param rect - rectangle to add
|
|
103
|
+
* @param isCCW - if true, draws counter-clockwise
|
|
104
|
+
*/
|
|
105
|
+
addRect(rect: SkRect, isCCW?: boolean): SkPathBuilder;
|
|
106
|
+
/**
|
|
107
|
+
* Adds oval to the builder.
|
|
108
|
+
* @param oval - bounds of ellipse
|
|
109
|
+
* @param isCCW - if true, draws counter-clockwise
|
|
110
|
+
* @param startIndex - index of initial point
|
|
111
|
+
*/
|
|
112
|
+
addOval(oval: SkRect, isCCW?: boolean, startIndex?: number): SkPathBuilder;
|
|
113
|
+
/**
|
|
114
|
+
* Appends arc to the builder as a new contour.
|
|
115
|
+
* @param oval - bounds of ellipse
|
|
116
|
+
* @param startAngleInDegrees - starting angle
|
|
117
|
+
* @param sweepAngleInDegrees - sweep angle
|
|
118
|
+
*/
|
|
119
|
+
addArc(oval: SkRect, startAngleInDegrees: number, sweepAngleInDegrees: number): SkPathBuilder;
|
|
120
|
+
/**
|
|
121
|
+
* Adds rounded rectangle to the builder.
|
|
122
|
+
* @param rrect - rounded rectangle to add
|
|
123
|
+
* @param isCCW - if true, draws counter-clockwise
|
|
124
|
+
*/
|
|
125
|
+
addRRect(rrect: InputRRect, isCCW?: boolean): SkPathBuilder;
|
|
126
|
+
/**
|
|
127
|
+
* Adds circle to the builder.
|
|
128
|
+
* @param x - center x
|
|
129
|
+
* @param y - center y
|
|
130
|
+
* @param r - radius
|
|
131
|
+
* @param isCCW - if true, draws counter-clockwise
|
|
132
|
+
*/
|
|
133
|
+
addCircle(x: number, y: number, r: number, isCCW?: boolean): SkPathBuilder;
|
|
134
|
+
/**
|
|
135
|
+
* Adds polygon to the builder from array of points.
|
|
136
|
+
* @param points - array of points
|
|
137
|
+
* @param close - if true, close the polygon
|
|
138
|
+
*/
|
|
139
|
+
addPoly(points: SkPoint[], close: boolean): SkPathBuilder;
|
|
140
|
+
/**
|
|
141
|
+
* Adds the path to the builder.
|
|
142
|
+
* @param src - path to add
|
|
143
|
+
* @param matrix - optional transform matrix
|
|
144
|
+
* @param extend - if true, extend rather than append
|
|
145
|
+
*/
|
|
146
|
+
addPath(src: SkPath, matrix?: SkMatrix, extend?: boolean): SkPathBuilder;
|
|
147
|
+
/**
|
|
148
|
+
* Sets the fill type for the path.
|
|
149
|
+
* @param fill - fill type to set
|
|
150
|
+
*/
|
|
151
|
+
setFillType(fill: FillType): SkPathBuilder;
|
|
152
|
+
/**
|
|
153
|
+
* Sets whether the path is volatile (temporary/animating).
|
|
154
|
+
* @param isVolatile - true if path will be altered frequently
|
|
155
|
+
*/
|
|
156
|
+
setIsVolatile(isVolatile: boolean): SkPathBuilder;
|
|
157
|
+
/**
|
|
158
|
+
* Resets the builder to empty state.
|
|
159
|
+
*/
|
|
160
|
+
reset(): SkPathBuilder;
|
|
161
|
+
/**
|
|
162
|
+
* Translates all points in the builder.
|
|
163
|
+
* @param dx - translation in x
|
|
164
|
+
* @param dy - translation in y
|
|
165
|
+
*/
|
|
166
|
+
offset(dx: number, dy: number): SkPathBuilder;
|
|
167
|
+
/**
|
|
168
|
+
* Transforms all points in the builder by the matrix.
|
|
169
|
+
* @param m - transformation matrix
|
|
170
|
+
*/
|
|
171
|
+
transform(m: InputMatrix): SkPathBuilder;
|
|
172
|
+
/**
|
|
173
|
+
* Returns the bounds of the path being built.
|
|
174
|
+
*/
|
|
175
|
+
computeBounds(): SkRect;
|
|
176
|
+
/**
|
|
177
|
+
* Returns true if the builder has no verbs.
|
|
178
|
+
*/
|
|
179
|
+
isEmpty(): boolean;
|
|
180
|
+
/**
|
|
181
|
+
* Returns the last point added to the builder.
|
|
182
|
+
*/
|
|
183
|
+
getLastPt(): {
|
|
184
|
+
x: number;
|
|
185
|
+
y: number;
|
|
186
|
+
};
|
|
187
|
+
/**
|
|
188
|
+
* Returns the number of points in the builder.
|
|
189
|
+
*/
|
|
190
|
+
countPoints(): number;
|
|
191
|
+
/**
|
|
192
|
+
* Returns a new SkPath with the current builder state.
|
|
193
|
+
* The builder is NOT reset and can continue to be used.
|
|
194
|
+
*/
|
|
195
|
+
build(): SkPath;
|
|
196
|
+
/**
|
|
197
|
+
* Returns a new SkPath with the current builder state and resets the builder.
|
|
198
|
+
* More efficient than build() when you're done with this builder.
|
|
199
|
+
*/
|
|
200
|
+
detach(): SkPath;
|
|
201
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":[],"sources":["PathBuilder.ts"],"sourcesContent":["import type { SkRect } from \"../Rect\";\nimport type { SkPoint } from \"../Point\";\nimport type { InputRRect } from \"../RRect\";\nimport type { InputMatrix, SkMatrix } from \"../Matrix\";\nimport type { SkJSIInstance } from \"../JsiInstance\";\n\nimport type { FillType, SkPath } from \"./Path\";\n\n/**\n * SkPathBuilder is a mutable builder for constructing SkPath objects.\n * Once construction is complete, call build() or detach() to get the immutable SkPath.\n */\nexport interface SkPathBuilder extends SkJSIInstance<\"PathBuilder\"> {\n // Movement methods\n\n /**\n * Adds beginning of contour at point (x, y).\n * @param x - x-axis value of contour start\n * @param y - y-axis value of contour start\n * @returns reference to this PathBuilder for chaining\n */\n moveTo(x: number, y: number): SkPathBuilder;\n\n /**\n * Adds beginning of contour relative to the last point.\n * @param x - offset from last point on x-axis\n * @param y - offset from last point on y-axis\n * @returns reference to this PathBuilder for chaining\n */\n rMoveTo(x: number, y: number): SkPathBuilder;\n\n /**\n * Adds line from last point to (x, y).\n * @param x - end of line on x-axis\n * @param y - end of line on y-axis\n * @returns reference to this PathBuilder for chaining\n */\n lineTo(x: number, y: number): SkPathBuilder;\n\n /**\n * Adds line from last point, relative to last point.\n * @param x - offset from last point on x-axis\n * @param y - offset from last point on y-axis\n * @returns reference to this PathBuilder for chaining\n */\n rLineTo(x: number, y: number): SkPathBuilder;\n\n // Curve methods\n\n /**\n * Adds quad from last point towards (x1, y1), to (x2, y2).\n */\n quadTo(x1: number, y1: number, x2: number, y2: number): SkPathBuilder;\n\n /**\n * Relative version of quadTo.\n */\n rQuadTo(x1: number, y1: number, x2: number, y2: number): SkPathBuilder;\n\n /**\n * Adds conic from last point towards (x1, y1), to (x2, y2), weighted by w.\n */\n conicTo(\n x1: number,\n y1: number,\n x2: number,\n y2: number,\n w: number\n ): SkPathBuilder;\n\n /**\n * Relative version of conicTo.\n */\n rConicTo(\n x1: number,\n y1: number,\n x2: number,\n y2: number,\n w: number\n ): SkPathBuilder;\n\n /**\n * Adds cubic from last point towards (x1, y1), then towards (x2, y2), ending at (x3, y3).\n */\n cubicTo(\n x1: number,\n y1: number,\n x2: number,\n y2: number,\n x3: number,\n y3: number\n ): SkPathBuilder;\n\n /**\n * Relative version of cubicTo.\n */\n rCubicTo(\n x1: number,\n y1: number,\n x2: number,\n y2: number,\n x3: number,\n y3: number\n ): SkPathBuilder;\n\n /**\n * Appends CLOSE_VERB to the builder, connecting first and last points.\n */\n close(): SkPathBuilder;\n\n // Arc methods\n\n /**\n * Appends arc to the builder. Arc is part of ellipse bounded by oval.\n * @param oval - bounds of ellipse containing arc\n * @param startAngleInDegrees - starting angle of arc in degrees\n * @param sweepAngleInDegrees - sweep, in degrees. Positive is clockwise\n * @param forceMoveTo - true to start a new contour with arc\n */\n arcToOval(\n oval: SkRect,\n startAngleInDegrees: number,\n sweepAngleInDegrees: number,\n forceMoveTo: boolean\n ): SkPathBuilder;\n\n /**\n * Appends arc to the builder with SVG-style parameters.\n * @param rx - x-radius of ellipse\n * @param ry - y-radius of ellipse\n * @param xAxisRotateInDegrees - rotation of ellipse\n * @param useSmallArc - if true, use smaller of two arcs\n * @param isCCW - if true, arc sweeps counter-clockwise\n * @param x - end point x\n * @param y - end point 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 ): SkPathBuilder;\n\n /**\n * Relative version of arcToRotated.\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 ): SkPathBuilder;\n\n /**\n * Appends arc to the builder, tangent to two lines.\n * @param x1 - x of first tangent point\n * @param y1 - y of first tangent point\n * @param x2 - x of second tangent point\n * @param y2 - y of second tangent point\n * @param radius - arc radius\n */\n arcToTangent(\n x1: number,\n y1: number,\n x2: number,\n y2: number,\n radius: number\n ): SkPathBuilder;\n\n // Shape methods\n\n /**\n * Adds Rect to the builder.\n * @param rect - rectangle to add\n * @param isCCW - if true, draws counter-clockwise\n */\n addRect(rect: SkRect, isCCW?: boolean): SkPathBuilder;\n\n /**\n * Adds oval to the builder.\n * @param oval - bounds of ellipse\n * @param isCCW - if true, draws counter-clockwise\n * @param startIndex - index of initial point\n */\n addOval(oval: SkRect, isCCW?: boolean, startIndex?: number): SkPathBuilder;\n\n /**\n * Appends arc to the builder as a new contour.\n * @param oval - bounds of ellipse\n * @param startAngleInDegrees - starting angle\n * @param sweepAngleInDegrees - sweep angle\n */\n addArc(\n oval: SkRect,\n startAngleInDegrees: number,\n sweepAngleInDegrees: number\n ): SkPathBuilder;\n\n /**\n * Adds rounded rectangle to the builder.\n * @param rrect - rounded rectangle to add\n * @param isCCW - if true, draws counter-clockwise\n */\n addRRect(rrect: InputRRect, isCCW?: boolean): SkPathBuilder;\n\n /**\n * Adds circle to the builder.\n * @param x - center x\n * @param y - center y\n * @param r - radius\n * @param isCCW - if true, draws counter-clockwise\n */\n addCircle(x: number, y: number, r: number, isCCW?: boolean): SkPathBuilder;\n\n /**\n * Adds polygon to the builder from array of points.\n * @param points - array of points\n * @param close - if true, close the polygon\n */\n addPoly(points: SkPoint[], close: boolean): SkPathBuilder;\n\n /**\n * Adds the path to the builder.\n * @param src - path to add\n * @param matrix - optional transform matrix\n * @param extend - if true, extend rather than append\n */\n addPath(src: SkPath, matrix?: SkMatrix, extend?: boolean): SkPathBuilder;\n\n // Configuration methods\n\n /**\n * Sets the fill type for the path.\n * @param fill - fill type to set\n */\n setFillType(fill: FillType): SkPathBuilder;\n\n /**\n * Sets whether the path is volatile (temporary/animating).\n * @param isVolatile - true if path will be altered frequently\n */\n setIsVolatile(isVolatile: boolean): SkPathBuilder;\n\n /**\n * Resets the builder to empty state.\n */\n reset(): SkPathBuilder;\n\n /**\n * Translates all points in the builder.\n * @param dx - translation in x\n * @param dy - translation in y\n */\n offset(dx: number, dy: number): SkPathBuilder;\n\n /**\n * Transforms all points in the builder by the matrix.\n * @param m - transformation matrix\n */\n transform(m: InputMatrix): SkPathBuilder;\n\n // Query methods\n\n /**\n * Returns the bounds of the path being built.\n */\n computeBounds(): SkRect;\n\n /**\n * Returns true if the builder has no verbs.\n */\n isEmpty(): boolean;\n\n /**\n * Returns the last point added to the builder.\n */\n getLastPt(): { x: number; y: number };\n\n /**\n * Returns the number of points in the builder.\n */\n countPoints(): number;\n\n // Build methods\n\n /**\n * Returns a new SkPath with the current builder state.\n * The builder is NOT reset and can continue to be used.\n */\n build(): SkPath;\n\n /**\n * Returns a new SkPath with the current builder state and resets the builder.\n * More efficient than build() when you're done with this builder.\n */\n detach(): SkPath;\n}\n"],"mappings":"","ignoreList":[]}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import type { SkPath } from "./Path";
|
|
2
|
+
import type { SkPathBuilder } from "./PathBuilder";
|
|
3
|
+
export interface PathBuilderFactory {
|
|
4
|
+
/**
|
|
5
|
+
* Creates a new empty PathBuilder.
|
|
6
|
+
*/
|
|
7
|
+
Make(): SkPathBuilder;
|
|
8
|
+
/**
|
|
9
|
+
* Creates a new PathBuilder initialized with the given path's contents.
|
|
10
|
+
* @param path - path to copy into the builder
|
|
11
|
+
*/
|
|
12
|
+
MakeFromPath(path: SkPath): SkPathBuilder;
|
|
13
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":[],"sources":["PathBuilderFactory.ts"],"sourcesContent":["import type { SkPath } from \"./Path\";\nimport type { SkPathBuilder } from \"./PathBuilder\";\n\nexport interface PathBuilderFactory {\n /**\n * Creates a new empty PathBuilder.\n */\n Make(): SkPathBuilder;\n\n /**\n * Creates a new PathBuilder initialized with the given path's contents.\n * @param path - path to copy into the builder\n */\n MakeFromPath(path: SkPath): SkPathBuilder;\n}\n"],"mappings":"","ignoreList":[]}
|
|
@@ -1,5 +1,8 @@
|
|
|
1
1
|
import type { SkFont } from "../Font";
|
|
2
|
-
import type {
|
|
2
|
+
import type { SkRect } from "../Rect";
|
|
3
|
+
import type { SkPoint } from "../Point";
|
|
4
|
+
import type { InputRRect } from "../RRect";
|
|
5
|
+
import type { SkPath, PathOp, PathCommand, StrokeOpts } from "./Path";
|
|
3
6
|
export interface PathFactory {
|
|
4
7
|
Make(): SkPath;
|
|
5
8
|
/**
|
|
@@ -26,4 +29,87 @@ export interface PathFactory {
|
|
|
26
29
|
* Converts the text to a path with the given font at location x / y.
|
|
27
30
|
*/
|
|
28
31
|
MakeFromText(text: string, x: number, y: number, font: SkFont): SkPath | null;
|
|
32
|
+
/**
|
|
33
|
+
* Creates a path containing a rectangle.
|
|
34
|
+
* @param rect - the rectangle
|
|
35
|
+
* @param isCCW - if true, draws counter-clockwise
|
|
36
|
+
*/
|
|
37
|
+
Rect(rect: SkRect, isCCW?: boolean): SkPath;
|
|
38
|
+
/**
|
|
39
|
+
* Creates a path containing an oval (ellipse).
|
|
40
|
+
* @param rect - bounds of the oval
|
|
41
|
+
* @param isCCW - if true, draws counter-clockwise
|
|
42
|
+
* @param startIndex - index of initial point
|
|
43
|
+
*/
|
|
44
|
+
Oval(rect: SkRect, isCCW?: boolean, startIndex?: number): SkPath;
|
|
45
|
+
/**
|
|
46
|
+
* Creates a path containing a circle.
|
|
47
|
+
* @param x - center x
|
|
48
|
+
* @param y - center y
|
|
49
|
+
* @param r - radius
|
|
50
|
+
*/
|
|
51
|
+
Circle(x: number, y: number, r: number): SkPath;
|
|
52
|
+
/**
|
|
53
|
+
* Creates a path containing a rounded rectangle.
|
|
54
|
+
* @param rrect - the rounded rectangle
|
|
55
|
+
* @param isCCW - if true, draws counter-clockwise
|
|
56
|
+
*/
|
|
57
|
+
RRect(rrect: InputRRect, isCCW?: boolean): SkPath;
|
|
58
|
+
/**
|
|
59
|
+
* Creates a path containing a line segment.
|
|
60
|
+
* @param p1 - start point
|
|
61
|
+
* @param p2 - end point
|
|
62
|
+
*/
|
|
63
|
+
Line(p1: SkPoint, p2: SkPoint): SkPath;
|
|
64
|
+
/**
|
|
65
|
+
* Creates a path containing a polygon from the given points.
|
|
66
|
+
* @param points - array of points
|
|
67
|
+
* @param close - if true, close the polygon
|
|
68
|
+
*/
|
|
69
|
+
Polygon(points: SkPoint[], close: boolean): SkPath;
|
|
70
|
+
/**
|
|
71
|
+
* Creates a new stroked path from the input path.
|
|
72
|
+
* @param path - source path to stroke
|
|
73
|
+
* @param opts - stroke options (width, cap, join, miter_limit, precision)
|
|
74
|
+
* @returns stroked path or null if operation fails
|
|
75
|
+
*/
|
|
76
|
+
Stroke(path: SkPath, opts?: StrokeOpts): SkPath | null;
|
|
77
|
+
/**
|
|
78
|
+
* Creates a trimmed path from the input path.
|
|
79
|
+
* @param path - source path
|
|
80
|
+
* @param start - start of trim (0-1)
|
|
81
|
+
* @param end - end of trim (0-1)
|
|
82
|
+
* @param isComplement - if true, returns the complement
|
|
83
|
+
* @returns trimmed path or null if operation fails
|
|
84
|
+
*/
|
|
85
|
+
Trim(path: SkPath, start: number, end: number, isComplement: boolean): SkPath | null;
|
|
86
|
+
/**
|
|
87
|
+
* Simplifies the path to non-overlapping contours.
|
|
88
|
+
* @param path - source path
|
|
89
|
+
* @returns simplified path or null if operation fails
|
|
90
|
+
*/
|
|
91
|
+
Simplify(path: SkPath): SkPath | null;
|
|
92
|
+
/**
|
|
93
|
+
* Creates a dashed version of the path.
|
|
94
|
+
* @param path - source path
|
|
95
|
+
* @param on - length of dash
|
|
96
|
+
* @param off - length of gap
|
|
97
|
+
* @param phase - offset into dash pattern
|
|
98
|
+
* @returns dashed path or null if operation fails
|
|
99
|
+
*/
|
|
100
|
+
Dash(path: SkPath, on: number, off: number, phase: number): SkPath | null;
|
|
101
|
+
/**
|
|
102
|
+
* Creates a path with Winding fill type.
|
|
103
|
+
* @param path - source path
|
|
104
|
+
* @returns path with winding fill or null if operation fails
|
|
105
|
+
*/
|
|
106
|
+
AsWinding(path: SkPath): SkPath | null;
|
|
107
|
+
/**
|
|
108
|
+
* Interpolates between two paths.
|
|
109
|
+
* @param start - starting path
|
|
110
|
+
* @param end - ending path
|
|
111
|
+
* @param weight - interpolation weight (0 = start, 1 = end)
|
|
112
|
+
* @returns interpolated path or null if paths are not interpolatable
|
|
113
|
+
*/
|
|
114
|
+
Interpolate(start: SkPath, end: SkPath, weight: number): SkPath | null;
|
|
29
115
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":[],"sources":["PathFactory.ts"],"sourcesContent":["import type { SkFont } from \"../Font\";\n\nimport type { SkPath, PathOp, PathCommand } from \"./Path\";\n\nexport interface PathFactory {\n Make(): SkPath;\n /**\n * Creates a new path from the provided SVG string. If this fails, null will be\n * returned instead.\n * @param str\n */\n MakeFromSVGString(str: string): SkPath | null;\n\n /**\n * Creates a new path by combining the given paths according to op. If this fails, null will\n * be returned instead.\n * @param one\n * @param two\n * @param op\n */\n MakeFromOp(one: SkPath, two: SkPath, op: PathOp): SkPath | null;\n\n /**\n * Creates a new path from the given list of path commands. If this fails, null will be\n * returned instead.\n * @param cmds\n */\n MakeFromCmds(cmds: PathCommand[]): SkPath | null;\n\n /**\n * Converts the text to a path with the given font at location x / y.\n */\n MakeFromText(text: string, x: number, y: number, font: SkFont): SkPath | null;\n}\n"],"mappings":"","ignoreList":[]}
|
|
1
|
+
{"version":3,"names":[],"sources":["PathFactory.ts"],"sourcesContent":["import type { SkFont } from \"../Font\";\nimport type { SkRect } from \"../Rect\";\nimport type { SkPoint } from \"../Point\";\nimport type { InputRRect } from \"../RRect\";\n\nimport type { SkPath, PathOp, PathCommand, StrokeOpts } from \"./Path\";\n\nexport interface PathFactory {\n Make(): SkPath;\n /**\n * Creates a new path from the provided SVG string. If this fails, null will be\n * returned instead.\n * @param str\n */\n MakeFromSVGString(str: string): SkPath | null;\n\n /**\n * Creates a new path by combining the given paths according to op. If this fails, null will\n * be returned instead.\n * @param one\n * @param two\n * @param op\n */\n MakeFromOp(one: SkPath, two: SkPath, op: PathOp): SkPath | null;\n\n /**\n * Creates a new path from the given list of path commands. If this fails, null will be\n * returned instead.\n * @param cmds\n */\n MakeFromCmds(cmds: PathCommand[]): SkPath | null;\n\n /**\n * Converts the text to a path with the given font at location x / y.\n */\n MakeFromText(text: string, x: number, y: number, font: SkFont): SkPath | null;\n\n // Static shape factories\n\n /**\n * Creates a path containing a rectangle.\n * @param rect - the rectangle\n * @param isCCW - if true, draws counter-clockwise\n */\n Rect(rect: SkRect, isCCW?: boolean): SkPath;\n\n /**\n * Creates a path containing an oval (ellipse).\n * @param rect - bounds of the oval\n * @param isCCW - if true, draws counter-clockwise\n * @param startIndex - index of initial point\n */\n Oval(rect: SkRect, isCCW?: boolean, startIndex?: number): SkPath;\n\n /**\n * Creates a path containing a circle.\n * @param x - center x\n * @param y - center y\n * @param r - radius\n */\n Circle(x: number, y: number, r: number): SkPath;\n\n /**\n * Creates a path containing a rounded rectangle.\n * @param rrect - the rounded rectangle\n * @param isCCW - if true, draws counter-clockwise\n */\n RRect(rrect: InputRRect, isCCW?: boolean): SkPath;\n\n /**\n * Creates a path containing a line segment.\n * @param p1 - start point\n * @param p2 - end point\n */\n Line(p1: SkPoint, p2: SkPoint): SkPath;\n\n /**\n * Creates a path containing a polygon from the given points.\n * @param points - array of points\n * @param close - if true, close the polygon\n */\n Polygon(points: SkPoint[], close: boolean): SkPath;\n\n // Static path operations\n\n /**\n * Creates a new stroked path from the input path.\n * @param path - source path to stroke\n * @param opts - stroke options (width, cap, join, miter_limit, precision)\n * @returns stroked path or null if operation fails\n */\n Stroke(path: SkPath, opts?: StrokeOpts): SkPath | null;\n\n /**\n * Creates a trimmed path from the input path.\n * @param path - source path\n * @param start - start of trim (0-1)\n * @param end - end of trim (0-1)\n * @param isComplement - if true, returns the complement\n * @returns trimmed path or null if operation fails\n */\n Trim(\n path: SkPath,\n start: number,\n end: number,\n isComplement: boolean\n ): SkPath | null;\n\n /**\n * Simplifies the path to non-overlapping contours.\n * @param path - source path\n * @returns simplified path or null if operation fails\n */\n Simplify(path: SkPath): SkPath | null;\n\n /**\n * Creates a dashed version of the path.\n * @param path - source path\n * @param on - length of dash\n * @param off - length of gap\n * @param phase - offset into dash pattern\n * @returns dashed path or null if operation fails\n */\n Dash(path: SkPath, on: number, off: number, phase: number): SkPath | null;\n\n /**\n * Creates a path with Winding fill type.\n * @param path - source path\n * @returns path with winding fill or null if operation fails\n */\n AsWinding(path: SkPath): SkPath | null;\n\n /**\n * Interpolates between two paths.\n * @param start - starting path\n * @param end - ending path\n * @param weight - interpolation weight (0 = start, 1 = end)\n * @returns interpolated path or null if paths are not interpolatable\n */\n Interpolate(start: SkPath, end: SkPath, weight: number): SkPath | null;\n}\n"],"mappings":"","ignoreList":[]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":[],"sources":["index.ts"],"sourcesContent":["export * from \"./Path\";\nexport * from \"./PathFactory\";\n"],"mappings":"AAAA,cAAc,QAAQ;AACtB,cAAc,eAAe","ignoreList":[]}
|
|
1
|
+
{"version":3,"names":[],"sources":["index.ts"],"sourcesContent":["export * from \"./Path\";\nexport * from \"./PathBuilder\";\nexport * from \"./PathBuilderFactory\";\nexport * from \"./PathFactory\";\n"],"mappings":"AAAA,cAAc,QAAQ;AACtB,cAAc,eAAe;AAC7B,cAAc,sBAAsB;AACpC,cAAc,eAAe","ignoreList":[]}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type { ImageFilterFactory } from "./ImageFilter";
|
|
2
|
-
import type { PathFactory } from "./Path";
|
|
2
|
+
import type { PathFactory, PathBuilderFactory } from "./Path";
|
|
3
3
|
import type { ColorFilterFactory } from "./ColorFilter";
|
|
4
4
|
import type { SkFont, FontMgrFactory } from "./Font";
|
|
5
5
|
import type { SkTypeface, TypefaceFactory } from "./Typeface";
|
|
@@ -50,6 +50,7 @@ export interface Skia {
|
|
|
50
50
|
PictureRecorder: () => SkPictureRecorder;
|
|
51
51
|
Picture: PictureFactory;
|
|
52
52
|
Path: PathFactory;
|
|
53
|
+
PathBuilder: PathBuilderFactory;
|
|
53
54
|
Matrix: (matrix?: readonly number[]) => SkMatrix;
|
|
54
55
|
ColorFilter: ColorFilterFactory;
|
|
55
56
|
Font: (typeface?: SkTypeface, size?: number) => SkFont;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":[],"sources":["Skia.ts"],"sourcesContent":["import type { ImageFilterFactory } from \"./ImageFilter\";\nimport type { PathFactory } from \"./Path\";\nimport type { ColorFilterFactory } from \"./ColorFilter\";\nimport type { SkFont, FontMgrFactory } from \"./Font\";\nimport type { SkTypeface, TypefaceFactory } from \"./Typeface\";\nimport type { ImageFactory } from \"./Image\";\nimport type { MaskFilterFactory } from \"./MaskFilter\";\nimport type { SkPaint } from \"./Paint\";\nimport type { SkHostRect, SkRect } from \"./Rect\";\nimport type { SkRRect } from \"./RRect\";\nimport type {\n RuntimeEffectFactory,\n SkRuntimeEffect,\n SkRuntimeShaderBuilder,\n} from \"./RuntimeEffect\";\nimport type { ShaderFactory } from \"./Shader\";\nimport type { SkMatrix } from \"./Matrix\";\nimport type { PathEffectFactory } from \"./PathEffect\";\nimport type { SkPoint } from \"./Point\";\nimport type { SkVertices, VertexMode } from \"./Vertices/Vertices\";\nimport type { DataFactory } from \"./Data\";\nimport type { SVGFactory } from \"./SVG\";\nimport type { TextBlobFactory } from \"./TextBlob\";\nimport type { SkSurface, SurfaceFactory } from \"./Surface\";\nimport type { SkRSXform } from \"./RSXform\";\nimport type { SkPath } from \"./Path/Path\";\nimport type { SkContourMeasureIter } from \"./ContourMeasure\";\nimport type { PictureFactory, SkPictureRecorder } from \"./Picture\";\nimport type { Color, SkColor } from \"./Color\";\nimport type { TypefaceFontProviderFactory } from \"./Paragraph/TypefaceFontProviderFactory\";\nimport type { AnimatedImageFactory } from \"./AnimatedImage\";\nimport type { ParagraphBuilderFactory } from \"./Paragraph/ParagraphBuilder\";\nimport type { Video } from \"./Video\";\nimport type { NativeBufferFactory } from \"./NativeBuffer\";\nimport type { JsiRecorder } from \"./Recorder\";\nimport type { SkottieFactory } from \"./Skottie\";\n\nexport interface SkiaContext {\n getSurface(): SkSurface;\n present(): void;\n}\n\n/**\n * Declares the interface for the native Skia API\n */\nexport interface Skia {\n Point: (x: number, y: number) => SkPoint;\n XYWHRect: (x: number, y: number, width: number, height: number) => SkHostRect;\n RuntimeShaderBuilder: (rt: SkRuntimeEffect) => SkRuntimeShaderBuilder;\n RRectXY: (rect: SkRect, rx: number, ry: number) => SkRRect;\n RSXform: (scos: number, ssin: number, tx: number, ty: number) => SkRSXform;\n RSXformFromRadians: (\n scale: number,\n radians: number,\n tx: number,\n ty: number,\n px: number,\n py: number\n ) => SkRSXform;\n Color: (color: Color) => SkColor;\n ContourMeasureIter: (\n path: SkPath,\n forceClosed: boolean,\n resScale: number\n ) => SkContourMeasureIter;\n Paint: () => SkPaint;\n PictureRecorder: () => SkPictureRecorder;\n Picture: PictureFactory;\n Path: PathFactory;\n Matrix: (matrix?: readonly number[]) => SkMatrix;\n ColorFilter: ColorFilterFactory;\n Font: (typeface?: SkTypeface, size?: number) => SkFont;\n Typeface: TypefaceFactory;\n TypefaceFontProvider: TypefaceFontProviderFactory;\n FontMgr: FontMgrFactory;\n MaskFilter: MaskFilterFactory;\n RuntimeEffect: RuntimeEffectFactory;\n ImageFilter: ImageFilterFactory;\n Shader: ShaderFactory;\n PathEffect: PathEffectFactory;\n /**\n * Returns an Vertices based on the given positions and optional parameters.\n * See SkVertices.h (especially the Builder) for more details.\n * @param mode\n * @param positions\n * @param textureCoordinates\n * @param colors - either a list of int colors or a flattened color array.\n * @param indices\n * @param isVolatile\n */\n MakeVertices(\n mode: VertexMode,\n positions: SkPoint[],\n textureCoordinates?: SkPoint[] | null,\n colors?: SkColor[],\n indices?: number[] | null,\n isVolatile?: boolean\n ): SkVertices;\n Data: DataFactory;\n Image: ImageFactory;\n AnimatedImage: AnimatedImageFactory;\n SVG: SVGFactory;\n TextBlob: TextBlobFactory;\n Surface: SurfaceFactory;\n ParagraphBuilder: ParagraphBuilderFactory;\n Skottie: SkottieFactory;\n Video: (url: string) => Promise<Video> | Video;\n Context(surface: bigint, width: number, height: number): SkiaContext;\n NativeBuffer: NativeBufferFactory;\n Recorder(): JsiRecorder;\n /**\n * Returns whether the Graphite backend is enabled and WebGPU is available.\n *\n * @returns true if Graphite/WebGPU is available, false otherwise\n */\n hasDevice(): boolean;\n /**\n * Returns the shared WebGPU device used by Skia's Graphite backend.\n * This allows direct access to the GPU device for WebGPU operations.\n *\n * Note: This method is only available when the Graphite backend is enabled.\n * Use hasDevice() to check availability before calling this method.\n *\n * @returns The GPUDevice used by Skia\n * @throws Error if Graphite backend is not enabled\n */\n getDevice(): GPUDevice;\n}\n"],"mappings":"","ignoreList":[]}
|
|
1
|
+
{"version":3,"names":[],"sources":["Skia.ts"],"sourcesContent":["import type { ImageFilterFactory } from \"./ImageFilter\";\nimport type { PathFactory, PathBuilderFactory } from \"./Path\";\nimport type { ColorFilterFactory } from \"./ColorFilter\";\nimport type { SkFont, FontMgrFactory } from \"./Font\";\nimport type { SkTypeface, TypefaceFactory } from \"./Typeface\";\nimport type { ImageFactory } from \"./Image\";\nimport type { MaskFilterFactory } from \"./MaskFilter\";\nimport type { SkPaint } from \"./Paint\";\nimport type { SkHostRect, SkRect } from \"./Rect\";\nimport type { SkRRect } from \"./RRect\";\nimport type {\n RuntimeEffectFactory,\n SkRuntimeEffect,\n SkRuntimeShaderBuilder,\n} from \"./RuntimeEffect\";\nimport type { ShaderFactory } from \"./Shader\";\nimport type { SkMatrix } from \"./Matrix\";\nimport type { PathEffectFactory } from \"./PathEffect\";\nimport type { SkPoint } from \"./Point\";\nimport type { SkVertices, VertexMode } from \"./Vertices/Vertices\";\nimport type { DataFactory } from \"./Data\";\nimport type { SVGFactory } from \"./SVG\";\nimport type { TextBlobFactory } from \"./TextBlob\";\nimport type { SkSurface, SurfaceFactory } from \"./Surface\";\nimport type { SkRSXform } from \"./RSXform\";\nimport type { SkPath } from \"./Path/Path\";\nimport type { SkContourMeasureIter } from \"./ContourMeasure\";\nimport type { PictureFactory, SkPictureRecorder } from \"./Picture\";\nimport type { Color, SkColor } from \"./Color\";\nimport type { TypefaceFontProviderFactory } from \"./Paragraph/TypefaceFontProviderFactory\";\nimport type { AnimatedImageFactory } from \"./AnimatedImage\";\nimport type { ParagraphBuilderFactory } from \"./Paragraph/ParagraphBuilder\";\nimport type { Video } from \"./Video\";\nimport type { NativeBufferFactory } from \"./NativeBuffer\";\nimport type { JsiRecorder } from \"./Recorder\";\nimport type { SkottieFactory } from \"./Skottie\";\n\nexport interface SkiaContext {\n getSurface(): SkSurface;\n present(): void;\n}\n\n/**\n * Declares the interface for the native Skia API\n */\nexport interface Skia {\n Point: (x: number, y: number) => SkPoint;\n XYWHRect: (x: number, y: number, width: number, height: number) => SkHostRect;\n RuntimeShaderBuilder: (rt: SkRuntimeEffect) => SkRuntimeShaderBuilder;\n RRectXY: (rect: SkRect, rx: number, ry: number) => SkRRect;\n RSXform: (scos: number, ssin: number, tx: number, ty: number) => SkRSXform;\n RSXformFromRadians: (\n scale: number,\n radians: number,\n tx: number,\n ty: number,\n px: number,\n py: number\n ) => SkRSXform;\n Color: (color: Color) => SkColor;\n ContourMeasureIter: (\n path: SkPath,\n forceClosed: boolean,\n resScale: number\n ) => SkContourMeasureIter;\n Paint: () => SkPaint;\n PictureRecorder: () => SkPictureRecorder;\n Picture: PictureFactory;\n Path: PathFactory;\n PathBuilder: PathBuilderFactory;\n Matrix: (matrix?: readonly number[]) => SkMatrix;\n ColorFilter: ColorFilterFactory;\n Font: (typeface?: SkTypeface, size?: number) => SkFont;\n Typeface: TypefaceFactory;\n TypefaceFontProvider: TypefaceFontProviderFactory;\n FontMgr: FontMgrFactory;\n MaskFilter: MaskFilterFactory;\n RuntimeEffect: RuntimeEffectFactory;\n ImageFilter: ImageFilterFactory;\n Shader: ShaderFactory;\n PathEffect: PathEffectFactory;\n /**\n * Returns an Vertices based on the given positions and optional parameters.\n * See SkVertices.h (especially the Builder) for more details.\n * @param mode\n * @param positions\n * @param textureCoordinates\n * @param colors - either a list of int colors or a flattened color array.\n * @param indices\n * @param isVolatile\n */\n MakeVertices(\n mode: VertexMode,\n positions: SkPoint[],\n textureCoordinates?: SkPoint[] | null,\n colors?: SkColor[],\n indices?: number[] | null,\n isVolatile?: boolean\n ): SkVertices;\n Data: DataFactory;\n Image: ImageFactory;\n AnimatedImage: AnimatedImageFactory;\n SVG: SVGFactory;\n TextBlob: TextBlobFactory;\n Surface: SurfaceFactory;\n ParagraphBuilder: ParagraphBuilderFactory;\n Skottie: SkottieFactory;\n Video: (url: string) => Promise<Video> | Video;\n Context(surface: bigint, width: number, height: number): SkiaContext;\n NativeBuffer: NativeBufferFactory;\n Recorder(): JsiRecorder;\n /**\n * Returns whether the Graphite backend is enabled and WebGPU is available.\n *\n * @returns true if Graphite/WebGPU is available, false otherwise\n */\n hasDevice(): boolean;\n /**\n * Returns the shared WebGPU device used by Skia's Graphite backend.\n * This allows direct access to the GPU device for WebGPU operations.\n *\n * Note: This method is only available when the Graphite backend is enabled.\n * Use hasDevice() to check availability before calling this method.\n *\n * @returns The GPUDevice used by Skia\n * @throws Error if Graphite backend is not enabled\n */\n getDevice(): GPUDevice;\n}\n"],"mappings":"","ignoreList":[]}
|
|
@@ -40,9 +40,7 @@ export const getEnum = (CanvasKit, name, v) => {
|
|
|
40
40
|
if (typeof e !== "function") {
|
|
41
41
|
throw new Error(`${name} is not an number`);
|
|
42
42
|
}
|
|
43
|
-
const result = Object.values(e).find(
|
|
44
|
-
value
|
|
45
|
-
}) => value === v);
|
|
43
|
+
const result = Object.values(e).find(entry => entry !== null && typeof entry === "object" && "value" in entry && entry.value === v);
|
|
46
44
|
if (!result) {
|
|
47
45
|
throw new Error(`Enum ${name} does not have value ${v} on React Native Web`);
|
|
48
46
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["throwNotImplementedOnRNWeb","jest","fn","Error","Host","constructor","CanvasKit","_defineProperty","BaseHostObject","ref","typename","__typename__","dispose","Symbol","delete","HostObject","fromValue","value","getEnum","name","v","e","result","Object","values","find","optEnum","undefined"],"sources":["Host.ts"],"sourcesContent":["import type { CanvasKit, EmbindEnumEntity } from \"canvaskit-wasm\";\n\nimport type { SkJSIInstance } from \"../types\";\n\nexport const throwNotImplementedOnRNWeb = <T>(): T => {\n if (typeof jest !== \"undefined\") {\n return jest.fn() as unknown as T;\n }\n throw new Error(\"Not implemented on React Native Web\");\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 dispose() {\n this[Symbol.dispose]();\n }\n\n [Symbol.dispose](): void {\n if (\n this.ref !== null &&\n typeof this.ref === \"object\" &&\n \"delete\" in this.ref &&\n typeof this.ref.delete === \"function\"\n ) {\n this.ref.delete();\n }\n }\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 = (\n CanvasKit: CanvasKit,\n name: keyof CanvasKit,\n v: number\n): EmbindEnumEntity => {\n const e = CanvasKit[name];\n if (typeof e !== \"function\") {\n throw new Error(`${name} is not an number`);\n }\n const result = Object.values(e).find((
|
|
1
|
+
{"version":3,"names":["throwNotImplementedOnRNWeb","jest","fn","Error","Host","constructor","CanvasKit","_defineProperty","BaseHostObject","ref","typename","__typename__","dispose","Symbol","delete","HostObject","fromValue","value","getEnum","name","v","e","result","Object","values","find","entry","optEnum","undefined"],"sources":["Host.ts"],"sourcesContent":["import type { CanvasKit, EmbindEnumEntity } from \"canvaskit-wasm\";\n\nimport type { SkJSIInstance } from \"../types\";\n\nexport const throwNotImplementedOnRNWeb = <T>(): T => {\n if (typeof jest !== \"undefined\") {\n return jest.fn() as unknown as T;\n }\n throw new Error(\"Not implemented on React Native Web\");\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 dispose() {\n this[Symbol.dispose]();\n }\n\n [Symbol.dispose](): void {\n if (\n this.ref !== null &&\n typeof this.ref === \"object\" &&\n \"delete\" in this.ref &&\n typeof this.ref.delete === \"function\"\n ) {\n this.ref.delete();\n }\n }\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 = (\n CanvasKit: CanvasKit,\n name: keyof CanvasKit,\n v: number\n): EmbindEnumEntity => {\n const e = CanvasKit[name];\n if (typeof e !== \"function\") {\n throw new Error(`${name} is not an number`);\n }\n const result = Object.values(e).find(\n (entry) =>\n entry !== null &&\n typeof entry === \"object\" &&\n \"value\" in entry &&\n entry.value === v\n );\n if (!result) {\n throw new Error(\n `Enum ${name} does not have value ${v} on React Native Web`\n );\n }\n return result;\n};\n\nexport const optEnum = (\n CanvasKit: CanvasKit,\n name: keyof CanvasKit,\n v: number | undefined\n): EmbindEnumEntity | undefined => {\n return v === undefined ? undefined : getEnum(CanvasKit, name, v);\n};\n"],"mappings":";;;AAIA,OAAO,MAAMA,0BAA0B,GAAGA,CAAA,KAAY;EACpD,IAAI,OAAOC,IAAI,KAAK,WAAW,EAAE;IAC/B,OAAOA,IAAI,CAACC,EAAE,CAAC,CAAC;EAClB;EACA,MAAM,IAAIC,KAAK,CAAC,qCAAqC,CAAC;AACxD,CAAC;AAED,OAAO,MAAeC,IAAI,CAAC;EAGzBC,WAAWA,CAACC,SAAoB,EAAE;IAAAC,eAAA;IAChC,IAAI,CAACD,SAAS,GAAGA,SAAS;EAC5B;AACF;AAEA,OAAO,MAAeE,cAAc,SAC1BJ,IAAI,CAEd;EAIEC,WAAWA,CAACC,SAAoB,EAAEG,GAAM,EAAEC,QAAW,EAAE;IACrD,KAAK,CAACJ,SAAS,CAAC;IAACC,eAAA;IAAAA,eAAA;IACjB,IAAI,CAACE,GAAG,GAAGA,GAAG;IACd,IAAI,CAACE,YAAY,GAAGD,QAAQ;EAC9B;EAEAE,OAAOA,CAAA,EAAG;IACR,IAAI,CAACC,MAAM,CAACD,OAAO,CAAC,CAAC,CAAC;EACxB;EAEA,CAACC,MAAM,CAACD,OAAO,IAAU;IACvB,IACE,IAAI,CAACH,GAAG,KAAK,IAAI,IACjB,OAAO,IAAI,CAACA,GAAG,KAAK,QAAQ,IAC5B,QAAQ,IAAI,IAAI,CAACA,GAAG,IACpB,OAAO,IAAI,CAACA,GAAG,CAACK,MAAM,KAAK,UAAU,EACrC;MACA,IAAI,CAACL,GAAG,CAACK,MAAM,CAAC,CAAC;IACnB;EACF;AACF;AAEA,OAAO,MAAeC,UAAU,SAA8BP,cAAc,CAG1E;EACA,OAAOQ,SAASA,CAAIC,KAA4B,EAAE;IAChD,OAAQA,KAAK,CAA2BR,GAAG;EAC7C;AACF;AAEA,OAAO,MAAMS,OAAO,GAAGA,CACrBZ,SAAoB,EACpBa,IAAqB,EACrBC,CAAS,KACY;EACrB,MAAMC,CAAC,GAAGf,SAAS,CAACa,IAAI,CAAC;EACzB,IAAI,OAAOE,CAAC,KAAK,UAAU,EAAE;IAC3B,MAAM,IAAIlB,KAAK,CAAC,GAAGgB,IAAI,mBAAmB,CAAC;EAC7C;EACA,MAAMG,MAAM,GAAGC,MAAM,CAACC,MAAM,CAACH,CAAC,CAAC,CAACI,IAAI,CACjCC,KAAK,IACJA,KAAK,KAAK,IAAI,IACd,OAAOA,KAAK,KAAK,QAAQ,IACzB,OAAO,IAAIA,KAAK,IAChBA,KAAK,CAACT,KAAK,KAAKG,CACpB,CAAC;EACD,IAAI,CAACE,MAAM,EAAE;IACX,MAAM,IAAInB,KAAK,CACb,QAAQgB,IAAI,wBAAwBC,CAAC,sBACvC,CAAC;EACH;EACA,OAAOE,MAAM;AACf,CAAC;AAED,OAAO,MAAMK,OAAO,GAAGA,CACrBrB,SAAoB,EACpBa,IAAqB,EACrBC,CAAqB,KACY;EACjC,OAAOA,CAAC,KAAKQ,SAAS,GAAGA,SAAS,GAAGV,OAAO,CAACZ,SAAS,EAAEa,IAAI,EAAEC,CAAC,CAAC;AAClE,CAAC","ignoreList":[]}
|