@shopify/react-native-skia 0.1.182 → 0.1.184
Sign up to get free protection for your applications and to get access to all the features.
- package/ios/RNSkia-iOS/RNSkMetalCanvasProvider.mm +23 -8
- package/lib/commonjs/animation/functions/interpolate.js +10 -1
- package/lib/commonjs/animation/functions/interpolate.js.map +1 -1
- package/lib/commonjs/animation/functions/interpolateColors.js +6 -0
- package/lib/commonjs/animation/functions/interpolateColors.js.map +1 -1
- package/lib/commonjs/animation/functions/interpolatePaths.js +4 -0
- package/lib/commonjs/animation/functions/interpolatePaths.js.map +1 -1
- package/lib/commonjs/animation/functions/interpolateVector.js +13 -5
- package/lib/commonjs/animation/functions/interpolateVector.js.map +1 -1
- package/lib/commonjs/external/reanimated/useSharedValueEffect.js +5 -2
- package/lib/commonjs/external/reanimated/useSharedValueEffect.js.map +1 -1
- package/lib/commonjs/renderer/processors/math/Coordinates.js +42 -18
- package/lib/commonjs/renderer/processors/math/Coordinates.js.map +1 -1
- package/lib/commonjs/renderer/processors/math/Math.js +10 -2
- package/lib/commonjs/renderer/processors/math/Math.js.map +1 -1
- package/lib/commonjs/renderer/processors/math/Transforms.js +2 -0
- package/lib/commonjs/renderer/processors/math/Transforms.js.map +1 -1
- package/lib/commonjs/renderer/typeddash.js +2 -0
- package/lib/commonjs/renderer/typeddash.js.map +1 -1
- package/lib/commonjs/skia/core/Vector.js +24 -4
- package/lib/commonjs/skia/core/Vector.js.map +1 -1
- package/lib/module/animation/functions/interpolate.js +10 -1
- package/lib/module/animation/functions/interpolate.js.map +1 -1
- package/lib/module/animation/functions/interpolateColors.js +6 -0
- package/lib/module/animation/functions/interpolateColors.js.map +1 -1
- package/lib/module/animation/functions/interpolatePaths.js +4 -0
- package/lib/module/animation/functions/interpolatePaths.js.map +1 -1
- package/lib/module/animation/functions/interpolateVector.js +13 -5
- package/lib/module/animation/functions/interpolateVector.js.map +1 -1
- package/lib/module/external/reanimated/useSharedValueEffect.js +6 -3
- package/lib/module/external/reanimated/useSharedValueEffect.js.map +1 -1
- package/lib/module/renderer/processors/math/Coordinates.js +42 -18
- package/lib/module/renderer/processors/math/Coordinates.js.map +1 -1
- package/lib/module/renderer/processors/math/Math.js +10 -2
- package/lib/module/renderer/processors/math/Math.js.map +1 -1
- package/lib/module/renderer/processors/math/Transforms.js +2 -0
- package/lib/module/renderer/processors/math/Transforms.js.map +1 -1
- package/lib/module/renderer/typeddash.js +2 -0
- package/lib/module/renderer/typeddash.js.map +1 -1
- package/lib/module/skia/core/Vector.js +24 -4
- package/lib/module/skia/core/Vector.js.map +1 -1
- package/package.json +1 -1
- package/react-native-skia.podspec +2 -6
- package/src/animation/functions/interpolate.ts +5 -0
- package/src/animation/functions/interpolateColors.ts +3 -0
- package/src/animation/functions/interpolatePaths.ts +2 -0
- package/src/animation/functions/interpolateVector.ts +21 -16
- package/src/external/reanimated/useSharedValueEffect.ts +7 -4
- package/src/renderer/processors/math/Coordinates.ts +36 -20
- package/src/renderer/processors/math/Math.ts +12 -4
- package/src/renderer/processors/math/Transforms.ts +1 -0
- package/src/renderer/typeddash.ts +1 -0
- package/src/skia/core/Vector.ts +24 -7
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"names":["Extrapolate","getVal","type","coef","val","leftEdgeOutput","rightEdgeOutput","x","IDENTITY","CLAMP","EXTEND","isExtrapolate","value","validateInterpolationOptions","extrapolationConfig","extrapolateLeft","extrapolateRight","Error","Object","assign","internalInterpolate","narrowedInput","leftEdgeInput","rightEdgeInput","progress","interpolate","input","output","length","i"],"sources":["interpolate.ts"],"sourcesContent":["/* eslint-disable max-len */\nexport enum Extrapolate {\n IDENTITY = \"identity\",\n CLAMP = \"clamp\",\n EXTEND = \"extend\",\n}\n\ninterface InterpolationNarrowedInput {\n leftEdgeInput: number;\n rightEdgeInput: number;\n leftEdgeOutput: number;\n rightEdgeOutput: number;\n}\n\nexport interface ExtrapolationConfig {\n extrapolateLeft?: Extrapolate | string;\n extrapolateRight?: Extrapolate | string;\n}\n\ninterface RequiredExtrapolationConfig {\n extrapolateLeft: Extrapolate;\n extrapolateRight: Extrapolate;\n}\n\nexport type ExtrapolationType =\n | ExtrapolationConfig\n | Extrapolate\n | string\n | undefined;\n\nfunction getVal(\n type: Extrapolate,\n coef: number,\n val: number,\n leftEdgeOutput: number,\n rightEdgeOutput: number,\n x: number\n): number {\n switch (type) {\n case Extrapolate.IDENTITY:\n return x;\n case Extrapolate.CLAMP:\n if (coef * val < coef * leftEdgeOutput) {\n return leftEdgeOutput;\n }\n return rightEdgeOutput;\n case Extrapolate.EXTEND:\n default:\n return val;\n }\n}\n\nfunction isExtrapolate(value: string): value is Extrapolate {\n return (\n value === Extrapolate.EXTEND ||\n value === Extrapolate.CLAMP ||\n value === Extrapolate.IDENTITY\n );\n}\n\n// validates extrapolations type\n// if type is correct, converts it to ExtrapolationConfig\nexport function validateInterpolationOptions(\n type: ExtrapolationType\n): RequiredExtrapolationConfig {\n // initialize extrapolationConfig with default extrapolation\n const extrapolationConfig: RequiredExtrapolationConfig = {\n extrapolateLeft: Extrapolate.EXTEND,\n extrapolateRight: Extrapolate.EXTEND,\n };\n\n if (!type) {\n return extrapolationConfig;\n }\n\n if (typeof type === \"string\") {\n if (!isExtrapolate(type)) {\n throw new Error(\n `No supported value for \"interpolate\" \\nSupported values: [\"extend\", \"clamp\", \"identity\", Extrapolatation.CLAMP, Extrapolatation.EXTEND, Extrapolatation.IDENTITY]\\n Valid example:\n interpolate(value, [inputRange], [outputRange], \"clamp\")`\n );\n }\n extrapolationConfig.extrapolateLeft = type;\n extrapolationConfig.extrapolateRight = type;\n return extrapolationConfig;\n }\n\n // otherwise type is extrapolation config object\n if (\n (type.extrapolateLeft && !isExtrapolate(type.extrapolateLeft)) ||\n (type.extrapolateRight && !isExtrapolate(type.extrapolateRight))\n ) {\n throw new Error(\n `No supported value for \"interpolate\" \\nSupported values: [\"extend\", \"clamp\", \"identity\", Extrapolatation.CLAMP, Extrapolatation.EXTEND, Extrapolatation.IDENTITY]\\n Valid example:\n interpolate(value, [inputRange], [outputRange], {\n extrapolateLeft: Extrapolation.CLAMP,\n extrapolateRight: Extrapolation.IDENTITY\n }})`\n );\n }\n\n Object.assign(extrapolationConfig, type);\n return extrapolationConfig;\n}\n\nfunction internalInterpolate(\n x: number,\n narrowedInput: InterpolationNarrowedInput,\n extrapolationConfig: RequiredExtrapolationConfig\n) {\n const { leftEdgeInput, rightEdgeInput, leftEdgeOutput, rightEdgeOutput } =\n narrowedInput;\n if (rightEdgeInput - leftEdgeInput === 0) {\n return leftEdgeOutput;\n }\n const progress = (x - leftEdgeInput) / (rightEdgeInput - leftEdgeInput);\n const val = leftEdgeOutput + progress * (rightEdgeOutput - leftEdgeOutput);\n const coef = rightEdgeOutput >= leftEdgeOutput ? 1 : -1;\n\n if (coef * val < coef * leftEdgeOutput) {\n return getVal(\n extrapolationConfig.extrapolateLeft,\n coef,\n val,\n leftEdgeOutput,\n rightEdgeOutput,\n x\n );\n } else if (coef * val > coef * rightEdgeOutput) {\n return getVal(\n extrapolationConfig.extrapolateRight,\n coef,\n val,\n leftEdgeOutput,\n rightEdgeOutput,\n x\n );\n }\n\n return val;\n}\n\n// e.g. function interpolate(x, input, output, type = Extrapolatation.CLAMP)\nexport function interpolate(\n x: number,\n input: readonly number[],\n output: readonly number[],\n type?: ExtrapolationType\n): number {\n if (input.length < 2 || output.length < 2) {\n throw Error(\n \"Interpolation input and output should contain at least two values.\"\n );\n }\n\n const extrapolationConfig = validateInterpolationOptions(type);\n const { length } = input;\n const narrowedInput: InterpolationNarrowedInput = {\n leftEdgeInput: input[0],\n rightEdgeInput: input[1],\n leftEdgeOutput: output[0],\n rightEdgeOutput: output[1],\n };\n if (length > 2) {\n if (x > input[length - 1]) {\n narrowedInput.leftEdgeInput = input[length - 2];\n narrowedInput.rightEdgeInput = input[length - 1];\n narrowedInput.leftEdgeOutput = output[length - 2];\n narrowedInput.rightEdgeOutput = output[length - 1];\n } else {\n for (let i = 1; i < length; ++i) {\n if (x <= input[i]) {\n narrowedInput.leftEdgeInput = input[i - 1];\n narrowedInput.rightEdgeInput = input[i];\n narrowedInput.leftEdgeOutput = output[i - 1];\n narrowedInput.rightEdgeOutput = output[i];\n break;\n }\n }\n }\n }\n\n return internalInterpolate(x, narrowedInput, extrapolationConfig);\n}\n"],"mappings":"AAAA;AACA,WAAYA,WAAZ;;WAAYA,W;EAAAA,W;EAAAA,W;EAAAA,W;GAAAA,W,KAAAA,W;;AA6BZ,SAASC,MAAT,CACEC,IADF,EAEEC,IAFF,EAGEC,GAHF,EAIEC,cAJF,EAKEC,eALF,EAMEC,CANF,EAOU;EACR,QAAQL,IAAR;IACE,KAAKF,WAAW,CAACQ,QAAjB;MACE,OAAOD,CAAP;;IACF,KAAKP,WAAW,CAACS,KAAjB;MACE,IAAIN,IAAI,GAAGC,GAAP,GAAaD,IAAI,GAAGE,cAAxB,EAAwC;QACtC,OAAOA,cAAP;MACD;;MACD,OAAOC,eAAP;;IACF,KAAKN,WAAW,CAACU,MAAjB;IACA;MACE,OAAON,GAAP;EAVJ;AAYD;;AAED,SAASO,aAAT,CAAuBC,KAAvB,EAA4D;EAC1D,OACEA,KAAK,KAAKZ,WAAW,CAACU,MAAtB,IACAE,KAAK,KAAKZ,WAAW,CAACS,KADtB,IAEAG,KAAK,KAAKZ,WAAW,CAACQ,QAHxB;AAKD,C,CAED;AACA;;;AACA,OAAO,SAASK,4BAAT,CACLX,IADK,EAEwB;EAC7B
|
1
|
+
{"version":3,"names":["Extrapolate","getVal","type","coef","val","leftEdgeOutput","rightEdgeOutput","x","IDENTITY","CLAMP","EXTEND","isExtrapolate","value","validateInterpolationOptions","extrapolationConfig","extrapolateLeft","extrapolateRight","Error","Object","assign","internalInterpolate","narrowedInput","leftEdgeInput","rightEdgeInput","progress","interpolate","input","output","length","i"],"sources":["interpolate.ts"],"sourcesContent":["/* eslint-disable max-len */\nexport enum Extrapolate {\n IDENTITY = \"identity\",\n CLAMP = \"clamp\",\n EXTEND = \"extend\",\n}\n\ninterface InterpolationNarrowedInput {\n leftEdgeInput: number;\n rightEdgeInput: number;\n leftEdgeOutput: number;\n rightEdgeOutput: number;\n}\n\nexport interface ExtrapolationConfig {\n extrapolateLeft?: Extrapolate | string;\n extrapolateRight?: Extrapolate | string;\n}\n\ninterface RequiredExtrapolationConfig {\n extrapolateLeft: Extrapolate;\n extrapolateRight: Extrapolate;\n}\n\nexport type ExtrapolationType =\n | ExtrapolationConfig\n | Extrapolate\n | string\n | undefined;\n\nfunction getVal(\n type: Extrapolate,\n coef: number,\n val: number,\n leftEdgeOutput: number,\n rightEdgeOutput: number,\n x: number\n): number {\n \"worklet\";\n switch (type) {\n case Extrapolate.IDENTITY:\n return x;\n case Extrapolate.CLAMP:\n if (coef * val < coef * leftEdgeOutput) {\n return leftEdgeOutput;\n }\n return rightEdgeOutput;\n case Extrapolate.EXTEND:\n default:\n return val;\n }\n}\n\nfunction isExtrapolate(value: string): value is Extrapolate {\n \"worklet\";\n return (\n value === Extrapolate.EXTEND ||\n value === Extrapolate.CLAMP ||\n value === Extrapolate.IDENTITY\n );\n}\n\n// validates extrapolations type\n// if type is correct, converts it to ExtrapolationConfig\nexport function validateInterpolationOptions(\n type: ExtrapolationType\n): RequiredExtrapolationConfig {\n \"worklet\";\n // initialize extrapolationConfig with default extrapolation\n const extrapolationConfig: RequiredExtrapolationConfig = {\n extrapolateLeft: Extrapolate.EXTEND,\n extrapolateRight: Extrapolate.EXTEND,\n };\n\n if (!type) {\n return extrapolationConfig;\n }\n\n if (typeof type === \"string\") {\n if (!isExtrapolate(type)) {\n throw new Error(\n `No supported value for \"interpolate\" \\nSupported values: [\"extend\", \"clamp\", \"identity\", Extrapolatation.CLAMP, Extrapolatation.EXTEND, Extrapolatation.IDENTITY]\\n Valid example:\n interpolate(value, [inputRange], [outputRange], \"clamp\")`\n );\n }\n extrapolationConfig.extrapolateLeft = type;\n extrapolationConfig.extrapolateRight = type;\n return extrapolationConfig;\n }\n\n // otherwise type is extrapolation config object\n if (\n (type.extrapolateLeft && !isExtrapolate(type.extrapolateLeft)) ||\n (type.extrapolateRight && !isExtrapolate(type.extrapolateRight))\n ) {\n throw new Error(\n `No supported value for \"interpolate\" \\nSupported values: [\"extend\", \"clamp\", \"identity\", Extrapolatation.CLAMP, Extrapolatation.EXTEND, Extrapolatation.IDENTITY]\\n Valid example:\n interpolate(value, [inputRange], [outputRange], {\n extrapolateLeft: Extrapolation.CLAMP,\n extrapolateRight: Extrapolation.IDENTITY\n }})`\n );\n }\n\n Object.assign(extrapolationConfig, type);\n return extrapolationConfig;\n}\n\nfunction internalInterpolate(\n x: number,\n narrowedInput: InterpolationNarrowedInput,\n extrapolationConfig: RequiredExtrapolationConfig\n) {\n \"worklet\";\n const { leftEdgeInput, rightEdgeInput, leftEdgeOutput, rightEdgeOutput } =\n narrowedInput;\n if (rightEdgeInput - leftEdgeInput === 0) {\n return leftEdgeOutput;\n }\n const progress = (x - leftEdgeInput) / (rightEdgeInput - leftEdgeInput);\n const val = leftEdgeOutput + progress * (rightEdgeOutput - leftEdgeOutput);\n const coef = rightEdgeOutput >= leftEdgeOutput ? 1 : -1;\n\n if (coef * val < coef * leftEdgeOutput) {\n return getVal(\n extrapolationConfig.extrapolateLeft,\n coef,\n val,\n leftEdgeOutput,\n rightEdgeOutput,\n x\n );\n } else if (coef * val > coef * rightEdgeOutput) {\n return getVal(\n extrapolationConfig.extrapolateRight,\n coef,\n val,\n leftEdgeOutput,\n rightEdgeOutput,\n x\n );\n }\n\n return val;\n}\n\n// e.g. function interpolate(x, input, output, type = Extrapolatation.CLAMP)\nexport function interpolate(\n x: number,\n input: readonly number[],\n output: readonly number[],\n type?: ExtrapolationType\n): number {\n \"worklet\";\n if (input.length < 2 || output.length < 2) {\n throw Error(\n \"Interpolation input and output should contain at least two values.\"\n );\n }\n\n const extrapolationConfig = validateInterpolationOptions(type);\n const { length } = input;\n const narrowedInput: InterpolationNarrowedInput = {\n leftEdgeInput: input[0],\n rightEdgeInput: input[1],\n leftEdgeOutput: output[0],\n rightEdgeOutput: output[1],\n };\n if (length > 2) {\n if (x > input[length - 1]) {\n narrowedInput.leftEdgeInput = input[length - 2];\n narrowedInput.rightEdgeInput = input[length - 1];\n narrowedInput.leftEdgeOutput = output[length - 2];\n narrowedInput.rightEdgeOutput = output[length - 1];\n } else {\n for (let i = 1; i < length; ++i) {\n if (x <= input[i]) {\n narrowedInput.leftEdgeInput = input[i - 1];\n narrowedInput.rightEdgeInput = input[i];\n narrowedInput.leftEdgeOutput = output[i - 1];\n narrowedInput.rightEdgeOutput = output[i];\n break;\n }\n }\n }\n }\n\n return internalInterpolate(x, narrowedInput, extrapolationConfig);\n}\n"],"mappings":"AAAA;AACA,WAAYA,WAAZ;;WAAYA,W;EAAAA,W;EAAAA,W;EAAAA,W;GAAAA,W,KAAAA,W;;AA6BZ,SAASC,MAAT,CACEC,IADF,EAEEC,IAFF,EAGEC,GAHF,EAIEC,cAJF,EAKEC,eALF,EAMEC,CANF,EAOU;EACR;;EACA,QAAQL,IAAR;IACE,KAAKF,WAAW,CAACQ,QAAjB;MACE,OAAOD,CAAP;;IACF,KAAKP,WAAW,CAACS,KAAjB;MACE,IAAIN,IAAI,GAAGC,GAAP,GAAaD,IAAI,GAAGE,cAAxB,EAAwC;QACtC,OAAOA,cAAP;MACD;;MACD,OAAOC,eAAP;;IACF,KAAKN,WAAW,CAACU,MAAjB;IACA;MACE,OAAON,GAAP;EAVJ;AAYD;;AAED,SAASO,aAAT,CAAuBC,KAAvB,EAA4D;EAC1D;;EACA,OACEA,KAAK,KAAKZ,WAAW,CAACU,MAAtB,IACAE,KAAK,KAAKZ,WAAW,CAACS,KADtB,IAEAG,KAAK,KAAKZ,WAAW,CAACQ,QAHxB;AAKD,C,CAED;AACA;;;AACA,OAAO,SAASK,4BAAT,CACLX,IADK,EAEwB;EAC7B,UAD6B,CAE7B;;EACA,MAAMY,mBAAgD,GAAG;IACvDC,eAAe,EAAEf,WAAW,CAACU,MAD0B;IAEvDM,gBAAgB,EAAEhB,WAAW,CAACU;EAFyB,CAAzD;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MAAM,GAAG,CAAV,CAAtC;IACD,CALD,MAKO;MACL,KAAK,IAAIC,CAAC,GAAG,CAAb,EAAgBA,CAAC,GAAGD,MAApB,EAA4B,EAAEC,CAA9B,EAAiC;QAC/B,IAAItB,CAAC,IAAImB,KAAK,CAACG,CAAD,CAAd,EAAmB;UACjBR,aAAa,CAACC,aAAd,GAA8BI,KAAK,CAACG,CAAC,GAAG,CAAL,CAAnC;UACAR,aAAa,CAACE,cAAd,GAA+BG,KAAK,CAACG,CAAD,CAApC;UACAR,aAAa,CAAChB,cAAd,GAA+BsB,MAAM,CAACE,CAAC,GAAG,CAAL,CAArC;UACAR,aAAa,CAACf,eAAd,GAAgCqB,MAAM,CAACE,CAAD,CAAtC;UACA;QACD;MACF;IACF;EACF;;EAED,OAAOT,mBAAmB,CAACb,CAAD,EAAIc,aAAJ,EAAmBP,mBAAnB,CAA1B;AACD"}
|
@@ -3,6 +3,8 @@ import { Skia } from "../../skia";
|
|
3
3
|
import { interpolate } from "./interpolate";
|
4
4
|
|
5
5
|
const interpolateColorsRGB = (value, inputRange, outputRange) => {
|
6
|
+
"worklet";
|
7
|
+
|
6
8
|
const r = interpolate(value, inputRange, outputRange.map(c => c[0]), "clamp");
|
7
9
|
const g = interpolate(value, inputRange, outputRange.map(c => c[1]), "clamp");
|
8
10
|
const b = interpolate(value, inputRange, outputRange.map(c => c[2]), "clamp");
|
@@ -11,11 +13,15 @@ const interpolateColorsRGB = (value, inputRange, outputRange) => {
|
|
11
13
|
};
|
12
14
|
|
13
15
|
export const interpolateColors = (value, inputRange, _outputRange) => {
|
16
|
+
"worklet";
|
17
|
+
|
14
18
|
const outputRange = _outputRange.map(cl => Skia.Color(cl));
|
15
19
|
|
16
20
|
return interpolateColorsRGB(value, inputRange, outputRange);
|
17
21
|
};
|
18
22
|
export const mixColors = (value, x, y) => {
|
23
|
+
"worklet";
|
24
|
+
|
19
25
|
const c1 = Skia.Color(x);
|
20
26
|
const c2 = Skia.Color(y);
|
21
27
|
return new Float32Array([mix(value, c1[0], c2[0]), mix(value, c1[1], c2[1]), mix(value, c1[2], c2[2]), mix(value, c1[3], c2[3])]);
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"names":["mix","Skia","interpolate","interpolateColorsRGB","value","inputRange","outputRange","r","map","c","g","b","a","Float32Array","interpolateColors","_outputRange","cl","Color","mixColors","x","y","c1","c2"],"sources":["interpolateColors.ts"],"sourcesContent":["import { mix } from \"../../renderer/processors/math\";\nimport type { Color, SkColor } from \"../../skia\";\nimport { Skia } from \"../../skia\";\n\nimport { interpolate } from \"./interpolate\";\n\nconst interpolateColorsRGB = (\n value: number,\n inputRange: number[],\n outputRange: SkColor[]\n) => {\n const r = interpolate(\n value,\n inputRange,\n outputRange.map((c) => c[0]),\n \"clamp\"\n );\n const g = interpolate(\n value,\n inputRange,\n outputRange.map((c) => c[1]),\n \"clamp\"\n );\n const b = interpolate(\n value,\n inputRange,\n outputRange.map((c) => c[2]),\n \"clamp\"\n );\n const a = interpolate(\n value,\n inputRange,\n outputRange.map((c) => c[3]),\n \"clamp\"\n );\n return new Float32Array([r, g, b, a]);\n};\n\nexport const interpolateColors = (\n value: number,\n inputRange: number[],\n _outputRange: Color[]\n) => {\n const outputRange = _outputRange.map((cl) => Skia.Color(cl));\n return interpolateColorsRGB(value, inputRange, outputRange);\n};\n\nexport const mixColors = (value: number, x: Color, y: Color) => {\n const c1 = Skia.Color(x);\n const c2 = Skia.Color(y);\n return new Float32Array([\n mix(value, c1[0], c2[0]),\n mix(value, c1[1], c2[1]),\n mix(value, c1[2], c2[2]),\n mix(value, c1[3], c2[3]),\n ]);\n};\n"],"mappings":"AAAA,SAASA,GAAT,QAAoB,gCAApB;AAEA,SAASC,IAAT,QAAqB,YAArB;AAEA,SAASC,WAAT,QAA4B,eAA5B;;AAEA,MAAMC,oBAAoB,GAAG,CAC3BC,KAD2B,EAE3BC,UAF2B,EAG3BC,WAH2B,KAIxB;EACH,MAAMC,CAAC,GAAGL,WAAW,CACnBE,KADmB,EAEnBC,UAFmB,EAGnBC,WAAW,CAACE,GAAZ,CAAiBC,CAAD,IAAOA,CAAC,CAAC,CAAD,CAAxB,CAHmB,EAInB,OAJmB,CAArB;EAMA,MAAMC,CAAC,GAAGR,WAAW,CACnBE,KADmB,EAEnBC,UAFmB,EAGnBC,WAAW,CAACE,GAAZ,CAAiBC,CAAD,IAAOA,CAAC,CAAC,CAAD,CAAxB,CAHmB,EAInB,OAJmB,CAArB;EAMA,MAAME,CAAC,GAAGT,WAAW,CACnBE,KADmB,EAEnBC,UAFmB,EAGnBC,WAAW,CAACE,GAAZ,CAAiBC,CAAD,IAAOA,CAAC,CAAC,CAAD,CAAxB,CAHmB,EAInB,OAJmB,CAArB;EAMA,MAAMG,CAAC,GAAGV,WAAW,CACnBE,KADmB,EAEnBC,UAFmB,EAGnBC,WAAW,CAACE,GAAZ,CAAiBC,CAAD,IAAOA,CAAC,CAAC,CAAD,CAAxB,CAHmB,EAInB,OAJmB,CAArB;EAMA,OAAO,IAAII,YAAJ,CAAiB,CAACN,CAAD,EAAIG,CAAJ,EAAOC,CAAP,EAAUC,CAAV,CAAjB,CAAP;AACD,
|
1
|
+
{"version":3,"names":["mix","Skia","interpolate","interpolateColorsRGB","value","inputRange","outputRange","r","map","c","g","b","a","Float32Array","interpolateColors","_outputRange","cl","Color","mixColors","x","y","c1","c2"],"sources":["interpolateColors.ts"],"sourcesContent":["import { mix } from \"../../renderer/processors/math\";\nimport type { Color, SkColor } from \"../../skia\";\nimport { Skia } from \"../../skia\";\n\nimport { interpolate } from \"./interpolate\";\n\nconst interpolateColorsRGB = (\n value: number,\n inputRange: number[],\n outputRange: SkColor[]\n) => {\n \"worklet\";\n const r = interpolate(\n value,\n inputRange,\n outputRange.map((c) => c[0]),\n \"clamp\"\n );\n const g = interpolate(\n value,\n inputRange,\n outputRange.map((c) => c[1]),\n \"clamp\"\n );\n const b = interpolate(\n value,\n inputRange,\n outputRange.map((c) => c[2]),\n \"clamp\"\n );\n const a = interpolate(\n value,\n inputRange,\n outputRange.map((c) => c[3]),\n \"clamp\"\n );\n return new Float32Array([r, g, b, a]);\n};\n\nexport const interpolateColors = (\n value: number,\n inputRange: number[],\n _outputRange: Color[]\n) => {\n \"worklet\";\n const outputRange = _outputRange.map((cl) => Skia.Color(cl));\n return interpolateColorsRGB(value, inputRange, outputRange);\n};\n\nexport const mixColors = (value: number, x: Color, y: Color) => {\n \"worklet\";\n const c1 = Skia.Color(x);\n const c2 = Skia.Color(y);\n return new Float32Array([\n mix(value, c1[0], c2[0]),\n mix(value, c1[1], c2[1]),\n mix(value, c1[2], c2[2]),\n mix(value, c1[3], c2[3]),\n ]);\n};\n"],"mappings":"AAAA,SAASA,GAAT,QAAoB,gCAApB;AAEA,SAASC,IAAT,QAAqB,YAArB;AAEA,SAASC,WAAT,QAA4B,eAA5B;;AAEA,MAAMC,oBAAoB,GAAG,CAC3BC,KAD2B,EAE3BC,UAF2B,EAG3BC,WAH2B,KAIxB;EACH;;EACA,MAAMC,CAAC,GAAGL,WAAW,CACnBE,KADmB,EAEnBC,UAFmB,EAGnBC,WAAW,CAACE,GAAZ,CAAiBC,CAAD,IAAOA,CAAC,CAAC,CAAD,CAAxB,CAHmB,EAInB,OAJmB,CAArB;EAMA,MAAMC,CAAC,GAAGR,WAAW,CACnBE,KADmB,EAEnBC,UAFmB,EAGnBC,WAAW,CAACE,GAAZ,CAAiBC,CAAD,IAAOA,CAAC,CAAC,CAAD,CAAxB,CAHmB,EAInB,OAJmB,CAArB;EAMA,MAAME,CAAC,GAAGT,WAAW,CACnBE,KADmB,EAEnBC,UAFmB,EAGnBC,WAAW,CAACE,GAAZ,CAAiBC,CAAD,IAAOA,CAAC,CAAC,CAAD,CAAxB,CAHmB,EAInB,OAJmB,CAArB;EAMA,MAAMG,CAAC,GAAGV,WAAW,CACnBE,KADmB,EAEnBC,UAFmB,EAGnBC,WAAW,CAACE,GAAZ,CAAiBC,CAAD,IAAOA,CAAC,CAAC,CAAD,CAAxB,CAHmB,EAInB,OAJmB,CAArB;EAMA,OAAO,IAAII,YAAJ,CAAiB,CAACN,CAAD,EAAIG,CAAJ,EAAOC,CAAP,EAAUC,CAAV,CAAjB,CAAP;AACD,CA/BD;;AAiCA,OAAO,MAAME,iBAAiB,GAAG,CAC/BV,KAD+B,EAE/BC,UAF+B,EAG/BU,YAH+B,KAI5B;EACH;;EACA,MAAMT,WAAW,GAAGS,YAAY,CAACP,GAAb,CAAkBQ,EAAD,IAAQf,IAAI,CAACgB,KAAL,CAAWD,EAAX,CAAzB,CAApB;;EACA,OAAOb,oBAAoB,CAACC,KAAD,EAAQC,UAAR,EAAoBC,WAApB,CAA3B;AACD,CARM;AAUP,OAAO,MAAMY,SAAS,GAAG,CAACd,KAAD,EAAgBe,CAAhB,EAA0BC,CAA1B,KAAuC;EAC9D;;EACA,MAAMC,EAAE,GAAGpB,IAAI,CAACgB,KAAL,CAAWE,CAAX,CAAX;EACA,MAAMG,EAAE,GAAGrB,IAAI,CAACgB,KAAL,CAAWG,CAAX,CAAX;EACA,OAAO,IAAIP,YAAJ,CAAiB,CACtBb,GAAG,CAACI,KAAD,EAAQiB,EAAE,CAAC,CAAD,CAAV,EAAeC,EAAE,CAAC,CAAD,CAAjB,CADmB,EAEtBtB,GAAG,CAACI,KAAD,EAAQiB,EAAE,CAAC,CAAD,CAAV,EAAeC,EAAE,CAAC,CAAD,CAAjB,CAFmB,EAGtBtB,GAAG,CAACI,KAAD,EAAQiB,EAAE,CAAC,CAAD,CAAV,EAAeC,EAAE,CAAC,CAAD,CAAjB,CAHmB,EAItBtB,GAAG,CAACI,KAAD,EAAQiB,EAAE,CAAC,CAAD,CAAV,EAAeC,EAAE,CAAC,CAAD,CAAjB,CAJmB,CAAjB,CAAP;AAMD,CAVM"}
|
@@ -2,6 +2,8 @@ import { exhaustiveCheck } from "../../renderer/typeddash";
|
|
2
2
|
import { validateInterpolationOptions, Extrapolate } from "./interpolate";
|
3
3
|
|
4
4
|
const lerp = (value, from, to, p1, p2) => {
|
5
|
+
"worklet";
|
6
|
+
|
5
7
|
const t = (value - from) / (to - from);
|
6
8
|
return p2.interpolate(p1, t);
|
7
9
|
};
|
@@ -24,6 +26,8 @@ const lerp = (value, from, to, p1, p2) => {
|
|
24
26
|
|
25
27
|
|
26
28
|
export const interpolatePaths = (value, input, outputRange, options) => {
|
29
|
+
"worklet";
|
30
|
+
|
27
31
|
const extrapolation = validateInterpolationOptions(options);
|
28
32
|
|
29
33
|
if (value < input[0]) {
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"names":["exhaustiveCheck","validateInterpolationOptions","Extrapolate","lerp","value","from","to","p1","p2","t","interpolate","interpolatePaths","input","outputRange","options","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 const t = (value - from) / (to - from);\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) => {\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,eAAT,QAAgC,0BAAhC;AAGA,SAASC,4BAAT,EAAuCC,WAAvC,QAA0D,eAA1D;;AAEA,MAAMC,IAAI,GAAG,CACXC,KADW,EAEXC,IAFW,EAGXC,EAHW,EAIXC,EAJW,EAKXC,EALW,KAMR;EACH,MAAMC,CAAC,GAAG,CAACL,KAAK,GAAGC,IAAT,KAAkBC,EAAE,GAAGD,IAAvB,CAAV;EACA,OAAOG,EAAE,CAACE,WAAH,CAAeH,EAAf,EAAmBE,CAAnB,CAAP;AACD,
|
1
|
+
{"version":3,"names":["exhaustiveCheck","validateInterpolationOptions","Extrapolate","lerp","value","from","to","p1","p2","t","interpolate","interpolatePaths","input","outputRange","options","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 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) => {\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 );\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B;MACE,KAAKpB,WAAW,CAACe,KAAjB;QACE,OAAOJ,WAAW,CAACA,WAAW,CAACQ,MAAZ,GAAqB,CAAtB,CAAlB;;MACF,KAAKnB,WAAW,CAACgB,MAAjB;QACE,OAAOf,IAAI,CACTC,KADS,EAETQ,KAAK,CAACA,KAAK,CAACS,MAAN,GAAe,CAAhB,CAFI,EAGTT,KAAK,CAACA,KAAK,CAACS,MAAN,GAAe,CAAhB,CAHI,EAITR,WAAW,CAACD,KAAK,CAACS,MAAN,GAAe,CAAhB,CAJF,EAKTR,WAAW,CAACD,KAAK,CAACS,MAAN,GAAe,CAAhB,CALF,CAAX;;MAOF,KAAKnB,WAAW,CAACiB,QAAjB;QACE,MAAM,IAAIC,KAAJ,CACJ,uEADI,CAAN;;MAGF;QACEpB,eAAe,CAACe,aAAa,CAACO,gBAAf,CAAf;IAhBJ;EAkBD;;EACD,IAAIC,CAAC,GAAG,CAAR;;EACA,OAAOA,CAAC,IAAIX,KAAK,CAACS,MAAN,GAAe,CAA3B,EAA8BE,CAAC,EAA/B,EAAmC;IACjC,IAAInB,KAAK,IAAIQ,KAAK,CAACW,CAAD,CAAd,IAAqBnB,KAAK,IAAIQ,KAAK,CAACW,CAAC,GAAG,CAAL,CAAvC,EAAgD;MAC9C;IACD;EACF;;EACD,OAAOpB,IAAI,CACTC,KADS,EAETQ,KAAK,CAACW,CAAD,CAFI,EAGTX,KAAK,CAACW,CAAC,GAAG,CAAL,CAHI,EAITV,WAAW,CAACU,CAAD,CAJF,EAKTV,WAAW,CAACU,CAAC,GAAG,CAAL,CALF,CAAX;AAOD,CAtDM"}
|
@@ -1,7 +1,15 @@
|
|
1
1
|
import { interpolate } from "./interpolate";
|
2
|
-
export const interpolateVector = (value, inputRange, outputRange, options) =>
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
|
2
|
+
export const interpolateVector = (value, inputRange, outputRange, options) => {
|
3
|
+
"worklet";
|
4
|
+
|
5
|
+
return {
|
6
|
+
x: interpolate(value, inputRange, outputRange.map(v => v.x), options),
|
7
|
+
y: interpolate(value, inputRange, outputRange.map(v => v.y), options)
|
8
|
+
};
|
9
|
+
};
|
10
|
+
export const mixVector = (value, from, to) => {
|
11
|
+
"worklet";
|
12
|
+
|
13
|
+
return interpolateVector(value, [0, 1], [from, to]);
|
14
|
+
};
|
7
15
|
//# sourceMappingURL=interpolateVector.js.map
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"names":["interpolate","interpolateVector","value","inputRange","outputRange","options","x","map","v","y","mixVector","from","to"],"sources":["interpolateVector.ts"],"sourcesContent":["import type { Vector } from \"../../skia/types\";\n\nimport { interpolate } from \"./interpolate\";\n\nexport const interpolateVector = (\n value: number,\n inputRange: readonly number[],\n outputRange: readonly Vector[],\n options?: Parameters<typeof interpolate>[3]\n) =>
|
1
|
+
{"version":3,"names":["interpolate","interpolateVector","value","inputRange","outputRange","options","x","map","v","y","mixVector","from","to"],"sources":["interpolateVector.ts"],"sourcesContent":["import type { Vector } from \"../../skia/types\";\n\nimport { interpolate } from \"./interpolate\";\n\nexport const interpolateVector = (\n value: number,\n inputRange: readonly number[],\n outputRange: readonly Vector[],\n options?: Parameters<typeof interpolate>[3]\n) => {\n \"worklet\";\n return {\n x: interpolate(\n value,\n inputRange,\n outputRange.map((v) => v.x),\n options\n ),\n y: interpolate(\n value,\n inputRange,\n outputRange.map((v) => v.y),\n options\n ),\n };\n};\n\nexport const mixVector = (value: number, from: Vector, to: Vector) => {\n \"worklet\";\n return interpolateVector(value, [0, 1], [from, to]);\n};\n"],"mappings":"AAEA,SAASA,WAAT,QAA4B,eAA5B;AAEA,OAAO,MAAMC,iBAAiB,GAAG,CAC/BC,KAD+B,EAE/BC,UAF+B,EAG/BC,WAH+B,EAI/BC,OAJ+B,KAK5B;EACH;;EACA,OAAO;IACLC,CAAC,EAAEN,WAAW,CACZE,KADY,EAEZC,UAFY,EAGZC,WAAW,CAACG,GAAZ,CAAiBC,CAAD,IAAOA,CAAC,CAACF,CAAzB,CAHY,EAIZD,OAJY,CADT;IAOLI,CAAC,EAAET,WAAW,CACZE,KADY,EAEZC,UAFY,EAGZC,WAAW,CAACG,GAAZ,CAAiBC,CAAD,IAAOA,CAAC,CAACC,CAAzB,CAHY,EAIZJ,OAJY;EAPT,CAAP;AAcD,CArBM;AAuBP,OAAO,MAAMK,SAAS,GAAG,CAACR,KAAD,EAAgBS,IAAhB,EAA8BC,EAA9B,KAA6C;EACpE;;EACA,OAAOX,iBAAiB,CAACC,KAAD,EAAQ,CAAC,CAAD,EAAI,CAAJ,CAAR,EAAgB,CAACS,IAAD,EAAOC,EAAP,CAAhB,CAAxB;AACD,CAHM"}
|
@@ -1,5 +1,5 @@
|
|
1
1
|
import { useEffect } from "react";
|
2
|
-
import { HAS_REANIMATED2, useSharedValue, runOnJS, startMapper, stopMapper } from "./moduleWrapper";
|
2
|
+
import { HAS_REANIMATED2, useSharedValue, runOnJS, startMapper, stopMapper, HAS_REANIMATED3 } from "./moduleWrapper";
|
3
3
|
/**
|
4
4
|
* Connects a shared value from reanimated to a SkiaView or Canvas
|
5
5
|
* so whenever the shared value changes the SkiaView will redraw.
|
@@ -12,8 +12,11 @@ export const useSharedValueEffect = function (cb, value) {
|
|
12
12
|
values[_key - 2] = arguments[_key];
|
13
13
|
}
|
14
14
|
|
15
|
-
|
16
|
-
|
15
|
+
if (HAS_REANIMATED3) {
|
16
|
+
console.warn(`useSharedValueEffect() is deprecated with Reanimated 3, you can use Reanimated values directly.
|
17
|
+
Learn more at https://shopify.github.io/react-native-skia/docs/animations/reanimated.`);
|
18
|
+
}
|
19
|
+
|
17
20
|
const input = useSharedValue(0);
|
18
21
|
useEffect(() => {
|
19
22
|
if (!HAS_REANIMATED2) {
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"names":["useEffect","HAS_REANIMATED2","useSharedValue","runOnJS","startMapper","stopMapper","useSharedValueEffect","cb","value","values","console","warn","input","mapperId","undefined"],"sources":["useSharedValueEffect.ts"],"sourcesContent":["import { useEffect } from \"react\";\n\nimport type { SharedValueType } from \"../../renderer/processors/Animations\";\n\nimport {\n HAS_REANIMATED2,\n useSharedValue,\n runOnJS,\n startMapper,\n stopMapper,\n} from \"./moduleWrapper\";\n\n/**\n * Connects a shared value from reanimated to a SkiaView or Canvas\n * so whenever the shared value changes the SkiaView will redraw.\n * @param cb Callback that will be called whenever the shared value changes.\n * @param values One or more shared values to listen for.\n */\nexport const useSharedValueEffect = <T = number>(\n cb: () => void,\n value: SharedValueType<T>,\n ...values: SharedValueType<T>[]\n) => {\n console.warn(\n
|
1
|
+
{"version":3,"names":["useEffect","HAS_REANIMATED2","useSharedValue","runOnJS","startMapper","stopMapper","HAS_REANIMATED3","useSharedValueEffect","cb","value","values","console","warn","input","mapperId","undefined"],"sources":["useSharedValueEffect.ts"],"sourcesContent":["import { useEffect } from \"react\";\n\nimport type { SharedValueType } from \"../../renderer/processors/Animations\";\n\nimport {\n HAS_REANIMATED2,\n useSharedValue,\n runOnJS,\n startMapper,\n stopMapper,\n HAS_REANIMATED3,\n} from \"./moduleWrapper\";\n\n/**\n * Connects a shared value from reanimated to a SkiaView or Canvas\n * so whenever the shared value changes the SkiaView will redraw.\n * @param cb Callback that will be called whenever the shared value changes.\n * @param values One or more shared values to listen for.\n */\nexport const useSharedValueEffect = <T = number>(\n cb: () => void,\n value: SharedValueType<T>,\n ...values: SharedValueType<T>[]\n) => {\n if (HAS_REANIMATED3) {\n console.warn(\n `useSharedValueEffect() is deprecated with Reanimated 3, you can use Reanimated values directly.\nLearn more at https://shopify.github.io/react-native-skia/docs/animations/reanimated.`\n );\n }\n const input = useSharedValue(0);\n\n useEffect(() => {\n if (!HAS_REANIMATED2) {\n console.warn(\n \"Reanimated was not found and the useSharedValueEffect hook will have no effect.\"\n );\n } else {\n // Start a mapper in Reanimated\n const mapperId = startMapper(\n () => {\n \"worklet\";\n runOnJS(cb)();\n },\n [value, ...values],\n [input]\n );\n // Return unregistering the mapper\n return () => {\n if (stopMapper && mapperId !== undefined) {\n stopMapper(mapperId);\n }\n };\n }\n return () => {};\n // eslint-disable-next-line react-hooks/exhaustive-deps\n }, [input, value, ...values]);\n};\n"],"mappings":"AAAA,SAASA,SAAT,QAA0B,OAA1B;AAIA,SACEC,eADF,EAEEC,cAFF,EAGEC,OAHF,EAIEC,WAJF,EAKEC,UALF,EAMEC,eANF,QAOO,iBAPP;AASA;AACA;AACA;AACA;AACA;AACA;;AACA,OAAO,MAAMC,oBAAoB,GAAG,UAClCC,EADkC,EAElCC,KAFkC,EAI/B;EAAA,kCADAC,MACA;IADAA,MACA;EAAA;;EACH,IAAIJ,eAAJ,EAAqB;IACnBK,OAAO,CAACC,IAAR,CACG;AACP,sFAFI;EAID;;EACD,MAAMC,KAAK,GAAGX,cAAc,CAAC,CAAD,CAA5B;EAEAF,SAAS,CAAC,MAAM;IACd,IAAI,CAACC,eAAL,EAAsB;MACpBU,OAAO,CAACC,IAAR,CACE,iFADF;IAGD,CAJD,MAIO;MACL;MACA,MAAME,QAAQ,GAAGV,WAAW,CAC1B,MAAM;QACJ;;QACAD,OAAO,CAACK,EAAD,CAAP;MACD,CAJyB,EAK1B,CAACC,KAAD,EAAQ,GAAGC,MAAX,CAL0B,EAM1B,CAACG,KAAD,CAN0B,CAA5B,CAFK,CAUL;;MACA,OAAO,MAAM;QACX,IAAIR,UAAU,IAAIS,QAAQ,KAAKC,SAA/B,EAA0C;UACxCV,UAAU,CAACS,QAAD,CAAV;QACD;MACF,CAJD;IAKD;;IACD,OAAO,MAAM,CAAE,CAAf,CAtBc,CAuBd;EACD,CAxBQ,EAwBN,CAACD,KAAD,EAAQJ,KAAR,EAAe,GAAGC,MAAlB,CAxBM,CAAT;AAyBD,CAtCM"}
|
@@ -1,19 +1,43 @@
|
|
1
|
-
export const canvas2Cartesian = (v, center) =>
|
2
|
-
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
}
|
9
|
-
export const
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
}
|
17
|
-
export const
|
18
|
-
|
1
|
+
export const canvas2Cartesian = (v, center) => {
|
2
|
+
"worklet";
|
3
|
+
|
4
|
+
return {
|
5
|
+
x: v.x - center.x,
|
6
|
+
y: -1 * (v.y - center.y)
|
7
|
+
};
|
8
|
+
};
|
9
|
+
export const cartesian2Canvas = (v, center) => {
|
10
|
+
"worklet";
|
11
|
+
|
12
|
+
return {
|
13
|
+
x: v.x + center.x,
|
14
|
+
y: -1 * v.y + center.y
|
15
|
+
};
|
16
|
+
};
|
17
|
+
export const cartesian2Polar = v => {
|
18
|
+
"worklet";
|
19
|
+
|
20
|
+
return {
|
21
|
+
theta: Math.atan2(v.y, v.x),
|
22
|
+
radius: Math.sqrt(v.x ** 2 + v.y ** 2)
|
23
|
+
};
|
24
|
+
};
|
25
|
+
export const polar2Cartesian = p => {
|
26
|
+
"worklet";
|
27
|
+
|
28
|
+
return {
|
29
|
+
x: p.radius * Math.cos(p.theta),
|
30
|
+
y: p.radius * Math.sin(p.theta)
|
31
|
+
};
|
32
|
+
};
|
33
|
+
export const polar2Canvas = (p, center) => {
|
34
|
+
"worklet";
|
35
|
+
|
36
|
+
return cartesian2Canvas(polar2Cartesian(p), center);
|
37
|
+
};
|
38
|
+
export const canvas2Polar = (v, center) => {
|
39
|
+
"worklet";
|
40
|
+
|
41
|
+
return cartesian2Polar(canvas2Cartesian(v, center));
|
42
|
+
};
|
19
43
|
//# sourceMappingURL=Coordinates.js.map
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"names":["canvas2Cartesian","v","center","x","y","cartesian2Canvas","cartesian2Polar","theta","Math","atan2","radius","sqrt","polar2Cartesian","p","cos","sin","polar2Canvas","canvas2Polar"],"sources":["Coordinates.ts"],"sourcesContent":["import type { Vector } from \"../../../skia/types\";\n\nexport interface PolarPoint {\n theta: number;\n radius: number;\n}\n\nexport const canvas2Cartesian = (v: Vector, center: Vector) =>
|
1
|
+
{"version":3,"names":["canvas2Cartesian","v","center","x","y","cartesian2Canvas","cartesian2Polar","theta","Math","atan2","radius","sqrt","polar2Cartesian","p","cos","sin","polar2Canvas","canvas2Polar"],"sources":["Coordinates.ts"],"sourcesContent":["import type { Vector } from \"../../../skia/types\";\n\nexport interface PolarPoint {\n theta: number;\n radius: number;\n}\n\nexport const canvas2Cartesian = (v: Vector, center: Vector) => {\n \"worklet\";\n return {\n x: v.x - center.x,\n y: -1 * (v.y - center.y),\n };\n};\n\nexport const cartesian2Canvas = (v: Vector, center: Vector) => {\n \"worklet\";\n return {\n x: v.x + center.x,\n y: -1 * v.y + center.y,\n };\n};\n\nexport const cartesian2Polar = (v: Vector) => {\n \"worklet\";\n return {\n theta: Math.atan2(v.y, v.x),\n radius: Math.sqrt(v.x ** 2 + v.y ** 2),\n };\n};\n\nexport const polar2Cartesian = (p: PolarPoint) => {\n \"worklet\";\n return {\n x: p.radius * Math.cos(p.theta),\n y: p.radius * Math.sin(p.theta),\n };\n};\n\nexport const polar2Canvas = (p: PolarPoint, center: Vector) => {\n \"worklet\";\n return cartesian2Canvas(polar2Cartesian(p), center);\n};\n\nexport const canvas2Polar = (v: Vector, center: Vector) => {\n \"worklet\";\n return cartesian2Polar(canvas2Cartesian(v, center));\n};\n"],"mappings":"AAOA,OAAO,MAAMA,gBAAgB,GAAG,CAACC,CAAD,EAAYC,MAAZ,KAA+B;EAC7D;;EACA,OAAO;IACLC,CAAC,EAAEF,CAAC,CAACE,CAAF,GAAMD,MAAM,CAACC,CADX;IAELC,CAAC,EAAE,CAAC,CAAD,IAAMH,CAAC,CAACG,CAAF,GAAMF,MAAM,CAACE,CAAnB;EAFE,CAAP;AAID,CANM;AAQP,OAAO,MAAMC,gBAAgB,GAAG,CAACJ,CAAD,EAAYC,MAAZ,KAA+B;EAC7D;;EACA,OAAO;IACLC,CAAC,EAAEF,CAAC,CAACE,CAAF,GAAMD,MAAM,CAACC,CADX;IAELC,CAAC,EAAE,CAAC,CAAD,GAAKH,CAAC,CAACG,CAAP,GAAWF,MAAM,CAACE;EAFhB,CAAP;AAID,CANM;AAQP,OAAO,MAAME,eAAe,GAAIL,CAAD,IAAe;EAC5C;;EACA,OAAO;IACLM,KAAK,EAAEC,IAAI,CAACC,KAAL,CAAWR,CAAC,CAACG,CAAb,EAAgBH,CAAC,CAACE,CAAlB,CADF;IAELO,MAAM,EAAEF,IAAI,CAACG,IAAL,CAAUV,CAAC,CAACE,CAAF,IAAO,CAAP,GAAWF,CAAC,CAACG,CAAF,IAAO,CAA5B;EAFH,CAAP;AAID,CANM;AAQP,OAAO,MAAMQ,eAAe,GAAIC,CAAD,IAAmB;EAChD;;EACA,OAAO;IACLV,CAAC,EAAEU,CAAC,CAACH,MAAF,GAAWF,IAAI,CAACM,GAAL,CAASD,CAAC,CAACN,KAAX,CADT;IAELH,CAAC,EAAES,CAAC,CAACH,MAAF,GAAWF,IAAI,CAACO,GAAL,CAASF,CAAC,CAACN,KAAX;EAFT,CAAP;AAID,CANM;AAQP,OAAO,MAAMS,YAAY,GAAG,CAACH,CAAD,EAAgBX,MAAhB,KAAmC;EAC7D;;EACA,OAAOG,gBAAgB,CAACO,eAAe,CAACC,CAAD,CAAhB,EAAqBX,MAArB,CAAvB;AACD,CAHM;AAKP,OAAO,MAAMe,YAAY,GAAG,CAAChB,CAAD,EAAYC,MAAZ,KAA+B;EACzD;;EACA,OAAOI,eAAe,CAACN,gBAAgB,CAACC,CAAD,EAAIC,MAAJ,CAAjB,CAAtB;AACD,CAHM"}
|
@@ -4,7 +4,11 @@
|
|
4
4
|
* @param x
|
5
5
|
* @param y
|
6
6
|
*/
|
7
|
-
export const mix = (value, x, y) =>
|
7
|
+
export const mix = (value, x, y) => {
|
8
|
+
"worklet";
|
9
|
+
|
10
|
+
return x * (1 - value) + y * value;
|
11
|
+
};
|
8
12
|
/**
|
9
13
|
* @summary Clamps a node with a lower and upper bound.
|
10
14
|
* @example
|
@@ -13,5 +17,9 @@ export const mix = (value, x, y) => x * (1 - value) + y * value;
|
|
13
17
|
clamp(101, 0, 100); // 100
|
14
18
|
*/
|
15
19
|
|
16
|
-
export const clamp = (value, lowerBound, upperBound) =>
|
20
|
+
export const clamp = (value, lowerBound, upperBound) => {
|
21
|
+
"worklet";
|
22
|
+
|
23
|
+
return Math.min(Math.max(lowerBound, value), upperBound);
|
24
|
+
};
|
17
25
|
//# sourceMappingURL=Math.js.map
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"names":["mix","value","x","y","clamp","lowerBound","upperBound","Math","min","max"],"sources":["Math.ts"],"sourcesContent":["/**\n * Linear interpolation\n * @param value\n * @param x\n * @param y\n */\nexport const mix = (value: number, x: number, y: number)
|
1
|
+
{"version":3,"names":["mix","value","x","y","clamp","lowerBound","upperBound","Math","min","max"],"sources":["Math.ts"],"sourcesContent":["/**\n * Linear interpolation\n * @param value\n * @param x\n * @param y\n */\nexport const mix = (value: number, x: number, y: number) => {\n \"worklet\";\n return x * (1 - value) + y * value;\n};\n\n/**\n * @summary Clamps a node with a lower and upper bound.\n * @example\n clamp(-1, 0, 100); // 0\n clamp(1, 0, 100); // 1\n clamp(101, 0, 100); // 100\n */\nexport const clamp = (\n value: number,\n lowerBound: number,\n upperBound: number\n) => {\n \"worklet\";\n return Math.min(Math.max(lowerBound, value), upperBound);\n};\n"],"mappings":"AAAA;AACA;AACA;AACA;AACA;AACA;AACA,OAAO,MAAMA,GAAG,GAAG,CAACC,KAAD,EAAgBC,CAAhB,EAA2BC,CAA3B,KAAyC;EAC1D;;EACA,OAAOD,CAAC,IAAI,IAAID,KAAR,CAAD,GAAkBE,CAAC,GAAGF,KAA7B;AACD,CAHM;AAKP;AACA;AACA;AACA;AACA;AACA;AACA;;AACA,OAAO,MAAMG,KAAK,GAAG,CACnBH,KADmB,EAEnBI,UAFmB,EAGnBC,UAHmB,KAIhB;EACH;;EACA,OAAOC,IAAI,CAACC,GAAL,CAASD,IAAI,CAACE,GAAL,CAASJ,UAAT,EAAqBJ,KAArB,CAAT,EAAsCK,UAAtC,CAAP;AACD,CAPM"}
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"names":["canvas2Polar","polar2Canvas","rotate","tr","origin","rotation","radius","theta"],"sources":["Transforms.ts"],"sourcesContent":["import type { Vector } from \"../../../skia/types\";\n\nimport { canvas2Polar, polar2Canvas } from \"./Coordinates\";\n\nexport const rotate = (tr: Vector, origin: Vector, rotation: number) => {\n const { radius, theta } = canvas2Polar(tr, origin);\n return polar2Canvas({ radius, theta: theta + rotation }, origin);\n};\n"],"mappings":"AAEA,SAASA,YAAT,EAAuBC,YAAvB,QAA2C,eAA3C;AAEA,OAAO,MAAMC,MAAM,GAAG,CAACC,EAAD,EAAaC,MAAb,EAA6BC,QAA7B,KAAkD;EACtE,MAAM;IAAEC,MAAF;IAAUC;EAAV,IAAoBP,YAAY,CAACG,EAAD,EAAKC,MAAL,CAAtC;EACA,OAAOH,YAAY,CAAC;IAAEK,MAAF;IAAUC,KAAK,EAAEA,KAAK,GAAGF;EAAzB,CAAD,EAAsCD,MAAtC,CAAnB;AACD,
|
1
|
+
{"version":3,"names":["canvas2Polar","polar2Canvas","rotate","tr","origin","rotation","radius","theta"],"sources":["Transforms.ts"],"sourcesContent":["import type { Vector } from \"../../../skia/types\";\n\nimport { canvas2Polar, polar2Canvas } from \"./Coordinates\";\n\nexport const rotate = (tr: Vector, origin: Vector, rotation: number) => {\n \"worklet\";\n const { radius, theta } = canvas2Polar(tr, origin);\n return polar2Canvas({ radius, theta: theta + rotation }, origin);\n};\n"],"mappings":"AAEA,SAASA,YAAT,EAAuBC,YAAvB,QAA2C,eAA3C;AAEA,OAAO,MAAMC,MAAM,GAAG,CAACC,EAAD,EAAaC,MAAb,EAA6BC,QAA7B,KAAkD;EACtE;;EACA,MAAM;IAAEC,MAAF;IAAUC;EAAV,IAAoBP,YAAY,CAACG,EAAD,EAAKC,MAAL,CAAtC;EACA,OAAOH,YAAY,CAAC;IAAEK,MAAF;IAAUC,KAAK,EAAEA,KAAK,GAAGF;EAAzB,CAAD,EAAsCD,MAAtC,CAAnB;AACD,CAJM"}
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"names":["mapKeys","obj","Object","keys","exhaustiveCheck","a","Error","shallowEq","p1","p2","keys1","keys2","length","key"],"sources":["typeddash.ts"],"sourcesContent":["export const mapKeys = <T extends object>(obj: T) =>\n Object.keys(obj) as (keyof T)[];\n\nexport const exhaustiveCheck = (a: never): never => {\n throw new Error(`Unexhaustive handling for ${a}`);\n};\n\n// Shallow eq on props (without children)\nexport const shallowEq = <P extends object>(p1: P, p2: P): boolean => {\n const keys1 = mapKeys(p1);\n const keys2 = mapKeys(p2);\n if (keys1.length !== keys2.length) {\n return false;\n }\n for (const key of keys1) {\n if (key === \"children\") {\n continue;\n }\n if (p1[key] !== p2[key]) {\n return false;\n }\n }\n return true;\n};\n"],"mappings":"AAAA,OAAO,MAAMA,OAAO,GAAsBC,GAAnB,IACrBC,MAAM,CAACC,IAAP,CAAYF,GAAZ,CADK;AAGP,OAAO,MAAMG,eAAe,GAAIC,CAAD,IAAqB;EAClD,MAAM,IAAIC,KAAJ,CAAW,6BAA4BD,CAAE,EAAzC,CAAN;AACD,
|
1
|
+
{"version":3,"names":["mapKeys","obj","Object","keys","exhaustiveCheck","a","Error","shallowEq","p1","p2","keys1","keys2","length","key"],"sources":["typeddash.ts"],"sourcesContent":["export const mapKeys = <T extends object>(obj: T) =>\n Object.keys(obj) as (keyof T)[];\n\nexport const exhaustiveCheck = (a: never): never => {\n \"worklet\";\n throw new Error(`Unexhaustive handling for ${a}`);\n};\n\n// Shallow eq on props (without children)\nexport const shallowEq = <P extends object>(p1: P, p2: P): boolean => {\n const keys1 = mapKeys(p1);\n const keys2 = mapKeys(p2);\n if (keys1.length !== keys2.length) {\n return false;\n }\n for (const key of keys1) {\n if (key === \"children\") {\n continue;\n }\n if (p1[key] !== p2[key]) {\n return false;\n }\n }\n return true;\n};\n"],"mappings":"AAAA,OAAO,MAAMA,OAAO,GAAsBC,GAAnB,IACrBC,MAAM,CAACC,IAAP,CAAYF,GAAZ,CADK;AAGP,OAAO,MAAMG,eAAe,GAAIC,CAAD,IAAqB;EAClD;;EACA,MAAM,IAAIC,KAAJ,CAAW,6BAA4BD,CAAE,EAAzC,CAAN;AACD,CAHM,C,CAKP;;AACA,OAAO,MAAME,SAAS,GAAG,CAAmBC,EAAnB,EAA0BC,EAA1B,KAA6C;EACpE,MAAMC,KAAK,GAAGV,OAAO,CAACQ,EAAD,CAArB;EACA,MAAMG,KAAK,GAAGX,OAAO,CAACS,EAAD,CAArB;;EACA,IAAIC,KAAK,CAACE,MAAN,KAAiBD,KAAK,CAACC,MAA3B,EAAmC;IACjC,OAAO,KAAP;EACD;;EACD,KAAK,MAAMC,GAAX,IAAkBH,KAAlB,EAAyB;IACvB,IAAIG,GAAG,KAAK,UAAZ,EAAwB;MACtB;IACD;;IACD,IAAIL,EAAE,CAACK,GAAD,CAAF,KAAYJ,EAAE,CAACI,GAAD,CAAlB,EAAyB;MACvB,OAAO,KAAP;IACD;EACF;;EACD,OAAO,IAAP;AACD,CAfM"}
|
@@ -1,15 +1,35 @@
|
|
1
1
|
import { Skia } from "../Skia";
|
2
2
|
export const vec = function () {
|
3
|
+
"worklet";
|
4
|
+
|
3
5
|
let x = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : 0;
|
4
6
|
let y = arguments.length > 1 ? arguments[1] : undefined;
|
5
7
|
return Skia.Point(x, y !== null && y !== void 0 ? y : x);
|
6
8
|
};
|
7
9
|
export const point = vec;
|
8
|
-
export const neg = a =>
|
9
|
-
|
10
|
-
|
11
|
-
|
10
|
+
export const neg = a => {
|
11
|
+
"worklet";
|
12
|
+
|
13
|
+
return vec(-a.x, -a.y);
|
14
|
+
};
|
15
|
+
export const add = (a, b) => {
|
16
|
+
"worklet";
|
17
|
+
|
18
|
+
return vec(a.x + b.x, a.y + b.y);
|
19
|
+
};
|
20
|
+
export const sub = (a, b) => {
|
21
|
+
"worklet";
|
22
|
+
|
23
|
+
return vec(a.x - b.x, a.y - b.y);
|
24
|
+
};
|
25
|
+
export const dist = (a, b) => {
|
26
|
+
"worklet";
|
27
|
+
|
28
|
+
return Math.hypot(a.x - b.x, a.y - b.y);
|
29
|
+
};
|
12
30
|
export const translate = _ref => {
|
31
|
+
"worklet";
|
32
|
+
|
13
33
|
let {
|
14
34
|
x,
|
15
35
|
y
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"names":["Skia","vec","x","y","Point","point","neg","a","add","b","sub","dist","Math","hypot","translate","translateX","translateY"],"sources":["Vector.ts"],"sourcesContent":["import { Skia } from \"../Skia\";\nimport type { Vector } from \"../types\";\n\nexport const vec = (x = 0, y?: number) => Skia.Point(x, y ?? x);\nexport const point = vec;\nexport const neg = (a: Vector) => vec(-a.x, -a.y);\nexport const add = (a: Vector, b: Vector) => vec(a.x + b.x, a.y + b.y);\nexport const sub = (a: Vector, b: Vector) => vec(a.x - b.x, a.y - b.y);\nexport const dist = (a: Vector, b: Vector) => Math.hypot(a.x - b.x, a.y - b.y);\nexport const translate = ({ x, y }: Vector)
|
1
|
+
{"version":3,"names":["Skia","vec","x","y","Point","point","neg","a","add","b","sub","dist","Math","hypot","translate","translateX","translateY"],"sources":["Vector.ts"],"sourcesContent":["import { Skia } from \"../Skia\";\nimport type { Vector } from \"../types\";\n\nexport const vec = (x = 0, y?: number) => {\n \"worklet\";\n return Skia.Point(x, y ?? x);\n};\nexport const point = vec;\nexport const neg = (a: Vector) => {\n \"worklet\";\n return vec(-a.x, -a.y);\n};\nexport const add = (a: Vector, b: Vector) => {\n \"worklet\";\n return vec(a.x + b.x, a.y + b.y);\n};\nexport const sub = (a: Vector, b: Vector) => {\n \"worklet\";\n return vec(a.x - b.x, a.y - b.y);\n};\nexport const dist = (a: Vector, b: Vector) => {\n \"worklet\";\n return Math.hypot(a.x - b.x, a.y - b.y);\n};\nexport const translate = ({ x, y }: Vector) => {\n \"worklet\";\n return [{ translateX: x }, { translateY: y }] as const;\n};\n"],"mappings":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EAAoB;IAAEc,UAAU,EAAEb;EAAd,CAApB,CAAP;AACD,CAHM"}
|
package/package.json
CHANGED
@@ -25,11 +25,7 @@ Pod::Spec.new do |s|
|
|
25
25
|
'GCC_PREPROCESSOR_DEFINITIONS' => '$(inherited) SK_GL=1 SK_METAL=1',
|
26
26
|
'CLANG_CXX_LANGUAGE_STANDARD' => 'c++17',
|
27
27
|
'DEFINES_MODULE' => 'YES',
|
28
|
-
"HEADER_SEARCH_PATHS" => '"$(
|
29
|
-
'"$(PODS_ROOT)/../../node_modules/@shopify/react-native-skia/cpp/api/" ' +
|
30
|
-
'"$(PODS_ROOT)/../../node_modules/@shopify/react-native-skia/cpp/rnskia/" ' +
|
31
|
-
'"$(PODS_ROOT)/../../node_modules/@shopify/react-native-skia/cpp/rnskia/dom/" ' +
|
32
|
-
'"$(PODS_ROOT)/../../node_modules/@shopify/react-native-skia/cpp/skia/"'
|
28
|
+
"HEADER_SEARCH_PATHS" => '"$(PODS_TARGET_SRCROOT)/cpp/"/**'
|
33
29
|
}
|
34
30
|
|
35
31
|
s.frameworks = 'GLKit', 'MetalKit'
|
@@ -45,7 +41,7 @@ Pod::Spec.new do |s|
|
|
45
41
|
# All iOS cpp/h files
|
46
42
|
s.source_files = [
|
47
43
|
"ios/**/*.{h,c,cc,cpp,m,mm,swift}",
|
48
|
-
"cpp/**/*.{h,cpp}"
|
44
|
+
"cpp/**/*.{h,cpp}"
|
49
45
|
]
|
50
46
|
|
51
47
|
s.dependency "React"
|
@@ -36,6 +36,7 @@ function getVal(
|
|
36
36
|
rightEdgeOutput: number,
|
37
37
|
x: number
|
38
38
|
): number {
|
39
|
+
"worklet";
|
39
40
|
switch (type) {
|
40
41
|
case Extrapolate.IDENTITY:
|
41
42
|
return x;
|
@@ -51,6 +52,7 @@ function getVal(
|
|
51
52
|
}
|
52
53
|
|
53
54
|
function isExtrapolate(value: string): value is Extrapolate {
|
55
|
+
"worklet";
|
54
56
|
return (
|
55
57
|
value === Extrapolate.EXTEND ||
|
56
58
|
value === Extrapolate.CLAMP ||
|
@@ -63,6 +65,7 @@ function isExtrapolate(value: string): value is Extrapolate {
|
|
63
65
|
export function validateInterpolationOptions(
|
64
66
|
type: ExtrapolationType
|
65
67
|
): RequiredExtrapolationConfig {
|
68
|
+
"worklet";
|
66
69
|
// initialize extrapolationConfig with default extrapolation
|
67
70
|
const extrapolationConfig: RequiredExtrapolationConfig = {
|
68
71
|
extrapolateLeft: Extrapolate.EXTEND,
|
@@ -108,6 +111,7 @@ function internalInterpolate(
|
|
108
111
|
narrowedInput: InterpolationNarrowedInput,
|
109
112
|
extrapolationConfig: RequiredExtrapolationConfig
|
110
113
|
) {
|
114
|
+
"worklet";
|
111
115
|
const { leftEdgeInput, rightEdgeInput, leftEdgeOutput, rightEdgeOutput } =
|
112
116
|
narrowedInput;
|
113
117
|
if (rightEdgeInput - leftEdgeInput === 0) {
|
@@ -147,6 +151,7 @@ export function interpolate(
|
|
147
151
|
output: readonly number[],
|
148
152
|
type?: ExtrapolationType
|
149
153
|
): number {
|
154
|
+
"worklet";
|
150
155
|
if (input.length < 2 || output.length < 2) {
|
151
156
|
throw Error(
|
152
157
|
"Interpolation input and output should contain at least two values."
|
@@ -9,6 +9,7 @@ const interpolateColorsRGB = (
|
|
9
9
|
inputRange: number[],
|
10
10
|
outputRange: SkColor[]
|
11
11
|
) => {
|
12
|
+
"worklet";
|
12
13
|
const r = interpolate(
|
13
14
|
value,
|
14
15
|
inputRange,
|
@@ -41,11 +42,13 @@ export const interpolateColors = (
|
|
41
42
|
inputRange: number[],
|
42
43
|
_outputRange: Color[]
|
43
44
|
) => {
|
45
|
+
"worklet";
|
44
46
|
const outputRange = _outputRange.map((cl) => Skia.Color(cl));
|
45
47
|
return interpolateColorsRGB(value, inputRange, outputRange);
|
46
48
|
};
|
47
49
|
|
48
50
|
export const mixColors = (value: number, x: Color, y: Color) => {
|
51
|
+
"worklet";
|
49
52
|
const c1 = Skia.Color(x);
|
50
53
|
const c2 = Skia.Color(y);
|
51
54
|
return new Float32Array([
|
@@ -11,6 +11,7 @@ const lerp = (
|
|
11
11
|
p1: SkPath,
|
12
12
|
p2: SkPath
|
13
13
|
) => {
|
14
|
+
"worklet";
|
14
15
|
const t = (value - from) / (to - from);
|
15
16
|
return p2.interpolate(p1, t)!;
|
16
17
|
};
|
@@ -37,6 +38,7 @@ export const interpolatePaths = (
|
|
37
38
|
outputRange: SkPath[],
|
38
39
|
options?: ExtrapolationType
|
39
40
|
) => {
|
41
|
+
"worklet";
|
40
42
|
const extrapolation = validateInterpolationOptions(options);
|
41
43
|
if (value < input[0]) {
|
42
44
|
switch (extrapolation.extrapolateLeft) {
|
@@ -7,20 +7,25 @@ export const interpolateVector = (
|
|
7
7
|
inputRange: readonly number[],
|
8
8
|
outputRange: readonly Vector[],
|
9
9
|
options?: Parameters<typeof interpolate>[3]
|
10
|
-
) =>
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
10
|
+
) => {
|
11
|
+
"worklet";
|
12
|
+
return {
|
13
|
+
x: interpolate(
|
14
|
+
value,
|
15
|
+
inputRange,
|
16
|
+
outputRange.map((v) => v.x),
|
17
|
+
options
|
18
|
+
),
|
19
|
+
y: interpolate(
|
20
|
+
value,
|
21
|
+
inputRange,
|
22
|
+
outputRange.map((v) => v.y),
|
23
|
+
options
|
24
|
+
),
|
25
|
+
};
|
26
|
+
};
|
24
27
|
|
25
|
-
export const mixVector = (value: number, from: Vector, to: Vector) =>
|
26
|
-
|
28
|
+
export const mixVector = (value: number, from: Vector, to: Vector) => {
|
29
|
+
"worklet";
|
30
|
+
return interpolateVector(value, [0, 1], [from, to]);
|
31
|
+
};
|
@@ -8,6 +8,7 @@ import {
|
|
8
8
|
runOnJS,
|
9
9
|
startMapper,
|
10
10
|
stopMapper,
|
11
|
+
HAS_REANIMATED3,
|
11
12
|
} from "./moduleWrapper";
|
12
13
|
|
13
14
|
/**
|
@@ -21,10 +22,12 @@ export const useSharedValueEffect = <T = number>(
|
|
21
22
|
value: SharedValueType<T>,
|
22
23
|
...values: SharedValueType<T>[]
|
23
24
|
) => {
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
25
|
+
if (HAS_REANIMATED3) {
|
26
|
+
console.warn(
|
27
|
+
`useSharedValueEffect() is deprecated with Reanimated 3, you can use Reanimated values directly.
|
28
|
+
Learn more at https://shopify.github.io/react-native-skia/docs/animations/reanimated.`
|
29
|
+
);
|
30
|
+
}
|
28
31
|
const input = useSharedValue(0);
|
29
32
|
|
30
33
|
useEffect(() => {
|