@shopify/react-native-skia 0.1.124 → 0.1.127
Sign up to get free protection for your applications and to get access to all the features.
- package/android/CMakeLists.txt +3 -0
- package/android/build.gradle +1 -1
- package/cpp/api/JsiSkApi.h +3 -1
- package/cpp/api/JsiSkCanvas.h +1 -1
- package/cpp/api/JsiSkColor.h +41 -7
- package/cpp/api/JsiSkColorFilterFactory.h +2 -1
- package/cpp/api/JsiSkImageFilter.h +0 -2
- package/cpp/api/JsiSkImageFilterFactory.h +37 -17
- package/cpp/api/JsiSkMatrix.h +44 -2
- package/cpp/api/JsiSkPaint.h +4 -7
- package/cpp/api/JsiSkRuntimeEffect.h +7 -0
- package/cpp/api/JsiSkRuntimeEffectFactory.h +3 -2
- package/cpp/api/JsiSkRuntimeShaderBuilder.h +70 -0
- package/cpp/api/JsiSkShaderFactory.h +2 -2
- package/cpp/api/JsiSkVertices.h +1 -1
- package/cpp/api/third_party/CSSColorParser.cpp +194 -0
- package/cpp/api/third_party/CSSColorParser.h +1 -191
- package/cpp/jsi/JsiSimpleValueWrapper.h +108 -0
- package/cpp/rnskia/values/RNSkReadonlyValue.h +13 -12
- package/ios/RNSkia-iOS/PlatformContext.h +30 -4
- package/ios/RNSkia-iOS/SkiaDrawView.mm +9 -12
- package/lib/commonjs/{values/animation → animation}/decay/decay.js +0 -0
- package/lib/commonjs/{values/animation → animation}/decay/decay.js.map +0 -0
- package/lib/commonjs/{values/animation → animation}/decay/index.js +0 -0
- package/lib/commonjs/{values/animation → animation}/decay/index.js.map +0 -0
- package/lib/commonjs/{values/animation → animation}/decay/runDecay.js +1 -1
- package/lib/commonjs/animation/decay/runDecay.js.map +1 -0
- package/lib/commonjs/{values/animation → animation}/decay/types.js +0 -0
- package/lib/commonjs/{values/animation → animation}/decay/types.js.map +0 -0
- package/lib/commonjs/{values/animation → animation}/functions/index.js +0 -0
- package/lib/commonjs/{values/animation → animation}/functions/index.js.map +0 -0
- package/lib/commonjs/animation/functions/interpolate.js +141 -0
- package/lib/commonjs/animation/functions/interpolate.js.map +1 -0
- package/lib/commonjs/animation/functions/interpolateColors.js +39 -0
- package/lib/commonjs/animation/functions/interpolateColors.js.map +1 -0
- package/lib/commonjs/{values/animation → animation}/index.js +0 -0
- package/lib/commonjs/{values/animation → animation}/index.js.map +0 -0
- package/lib/commonjs/{values/animation → animation}/spring/Spring.js +0 -0
- package/lib/commonjs/{values/animation → animation}/spring/Spring.js.map +0 -0
- package/lib/commonjs/{values/animation → animation}/spring/functions/index.js +0 -0
- package/lib/commonjs/{values/animation → animation}/spring/functions/index.js.map +0 -0
- package/lib/commonjs/{values/animation → animation}/spring/functions/spring.js +0 -0
- package/lib/commonjs/{values/animation → animation}/spring/functions/spring.js.map +0 -0
- package/lib/commonjs/{values/animation → animation}/spring/index.js +0 -0
- package/lib/commonjs/{values/animation → animation}/spring/index.js.map +0 -0
- package/lib/commonjs/{values/animation → animation}/spring/runSpring.js +0 -0
- package/lib/commonjs/animation/spring/runSpring.js.map +1 -0
- package/lib/commonjs/{values/animation → animation}/spring/types.js +0 -0
- package/lib/commonjs/{values/animation → animation}/spring/types.js.map +0 -0
- package/lib/commonjs/{values/animation → animation}/spring/useSpring.js +0 -0
- package/lib/commonjs/animation/spring/useSpring.js.map +1 -0
- package/lib/commonjs/{values/animation → animation}/timing/Easing.js +0 -0
- package/lib/commonjs/{values/animation → animation}/timing/Easing.js.map +0 -0
- package/lib/commonjs/{values/animation → animation}/timing/createTiming.js +1 -1
- package/lib/commonjs/animation/timing/createTiming.js.map +1 -0
- package/lib/commonjs/{values/animation → animation}/timing/functions/bezier.js +0 -0
- package/lib/commonjs/{values/animation → animation}/timing/functions/bezier.js.map +0 -0
- package/lib/commonjs/{values/animation → animation}/timing/functions/getResolvedParams.js +0 -0
- package/lib/commonjs/{values/animation → animation}/timing/functions/getResolvedParams.js.map +0 -0
- package/lib/commonjs/{values/animation → animation}/timing/functions/index.js +0 -0
- package/lib/commonjs/{values/animation → animation}/timing/functions/index.js.map +0 -0
- package/lib/commonjs/{values/animation → animation}/timing/functions/timing.js +0 -0
- package/lib/commonjs/{values/animation → animation}/timing/functions/timing.js.map +1 -1
- package/lib/commonjs/{values/animation → animation}/timing/functions/types.js +0 -0
- package/lib/commonjs/{values/animation → animation}/timing/functions/types.js.map +0 -0
- package/lib/commonjs/{values/animation → animation}/timing/index.js +0 -0
- package/lib/commonjs/{values/animation → animation}/timing/index.js.map +0 -0
- package/lib/commonjs/{values/animation → animation}/timing/runTiming.js +0 -0
- package/lib/commonjs/animation/timing/runTiming.js.map +1 -0
- package/lib/commonjs/{values/animation → animation}/timing/useLoop.js +0 -0
- package/lib/commonjs/{values/animation → animation}/timing/useLoop.js.map +0 -0
- package/lib/commonjs/{values/animation → animation}/timing/useTiming.js +1 -1
- package/lib/commonjs/animation/timing/useTiming.js.map +1 -0
- package/lib/commonjs/{values/animation → animation}/types.js +0 -0
- package/lib/commonjs/{values/animation → animation}/types.js.map +0 -0
- package/lib/commonjs/index.js +13 -0
- package/lib/commonjs/index.js.map +1 -1
- package/lib/commonjs/renderer/components/colorFilters/BlendColor.js.map +1 -1
- package/lib/commonjs/renderer/components/imageFilters/InnerShadow.js +4 -2
- package/lib/commonjs/renderer/components/imageFilters/InnerShadow.js.map +1 -1
- package/lib/commonjs/renderer/components/imageFilters/RuntimeShader.js +37 -0
- package/lib/commonjs/renderer/components/imageFilters/RuntimeShader.js.map +1 -0
- package/lib/commonjs/renderer/components/imageFilters/index.js +13 -0
- package/lib/commonjs/renderer/components/imageFilters/index.js.map +1 -1
- package/lib/commonjs/renderer/components/shaders/Gradient.js +1 -1
- package/lib/commonjs/renderer/components/shaders/Gradient.js.map +1 -1
- package/lib/commonjs/renderer/components/shaders/Shader.js.map +1 -1
- package/lib/commonjs/renderer/processors/Rects.js +5 -15
- package/lib/commonjs/renderer/processors/Rects.js.map +1 -1
- package/lib/commonjs/renderer/processors/math/Matrix3.js +42 -63
- package/lib/commonjs/renderer/processors/math/Matrix3.js.map +1 -1
- package/lib/commonjs/renderer/processors/math/Vector.js +4 -5
- package/lib/commonjs/renderer/processors/math/Vector.js.map +1 -1
- package/lib/commonjs/skia/Color.js +14 -38
- package/lib/commonjs/skia/Color.js.map +1 -1
- package/lib/commonjs/skia/ImageFilter/ImageFilterFactory.js.map +1 -1
- package/lib/commonjs/skia/Matrix.js.map +1 -1
- package/lib/commonjs/skia/Shader/useShader.js +4 -1
- package/lib/commonjs/skia/Shader/useShader.js.map +1 -1
- package/lib/commonjs/skia/Skia.js +3 -45
- package/lib/commonjs/skia/Skia.js.map +1 -1
- package/lib/commonjs/skia/SkiaApi.js +4 -0
- package/lib/commonjs/skia/SkiaApi.js.map +1 -0
- package/lib/commonjs/values/api.js +4 -6
- package/lib/commonjs/values/api.js.map +1 -1
- package/lib/commonjs/values/api.web.js +18 -0
- package/lib/commonjs/values/api.web.js.map +1 -0
- package/lib/commonjs/values/index.js +0 -13
- package/lib/commonjs/values/index.js.map +1 -1
- package/lib/commonjs/values/web/RNSkAnimation.js +46 -0
- package/lib/commonjs/values/web/RNSkAnimation.js.map +1 -0
- package/lib/commonjs/values/web/RNSkClockValue.js +75 -0
- package/lib/commonjs/values/web/RNSkClockValue.js.map +1 -0
- package/lib/commonjs/values/web/RNSkDerivedValue.js +51 -0
- package/lib/commonjs/values/web/RNSkDerivedValue.js.map +1 -0
- package/lib/commonjs/values/web/RNSkReadonlyValue.js +45 -0
- package/lib/commonjs/values/web/RNSkReadonlyValue.js.map +1 -0
- package/lib/commonjs/values/web/RNSkValue.js +73 -0
- package/lib/commonjs/values/web/RNSkValue.js.map +1 -0
- package/lib/commonjs/values/web/api.js +31 -0
- package/lib/commonjs/values/web/api.js.map +1 -0
- package/lib/commonjs/values/web/index.js +19 -0
- package/lib/commonjs/values/web/index.js.map +1 -0
- package/lib/commonjs/views/SkiaView.js +13 -10
- package/lib/commonjs/views/SkiaView.js.map +1 -1
- package/lib/commonjs/views/api.js +11 -0
- package/lib/commonjs/views/api.js.map +1 -0
- package/lib/commonjs/views/types.js.map +1 -1
- package/lib/module/{values/animation → animation}/decay/decay.js +0 -0
- package/lib/module/{values/animation → animation}/decay/decay.js.map +0 -0
- package/lib/module/{values/animation → animation}/decay/index.js +0 -0
- package/lib/module/{values/animation → animation}/decay/index.js.map +0 -0
- package/lib/module/{values/animation → animation}/decay/runDecay.js +1 -1
- package/lib/module/animation/decay/runDecay.js.map +1 -0
- package/lib/module/{values/animation → animation}/decay/types.js +0 -0
- package/lib/module/{values/animation → animation}/decay/types.js.map +0 -0
- package/lib/module/{values/animation → animation}/functions/index.js +0 -0
- package/lib/module/{values/animation → animation}/functions/index.js.map +0 -0
- package/lib/module/animation/functions/interpolate.js +132 -0
- package/lib/module/animation/functions/interpolate.js.map +1 -0
- package/lib/module/animation/functions/interpolateColors.js +23 -0
- package/lib/module/animation/functions/interpolateColors.js.map +1 -0
- package/lib/module/{values/animation → animation}/index.js +0 -0
- package/lib/module/{values/animation → animation}/index.js.map +0 -0
- package/lib/module/{values/animation → animation}/spring/Spring.js +0 -0
- package/lib/module/{values/animation → animation}/spring/Spring.js.map +0 -0
- package/lib/module/{values/animation → animation}/spring/functions/index.js +0 -0
- package/lib/module/{values/animation → animation}/spring/functions/index.js.map +0 -0
- package/lib/module/{values/animation → animation}/spring/functions/spring.js +0 -0
- package/lib/module/{values/animation → animation}/spring/functions/spring.js.map +0 -0
- package/lib/module/{values/animation → animation}/spring/index.js +0 -0
- package/lib/module/{values/animation → animation}/spring/index.js.map +0 -0
- package/lib/module/{values/animation → animation}/spring/runSpring.js +0 -0
- package/lib/module/animation/spring/runSpring.js.map +1 -0
- package/lib/module/{values/animation → animation}/spring/types.js +0 -0
- package/lib/module/{values/animation → animation}/spring/types.js.map +0 -0
- package/lib/module/{values/animation → animation}/spring/useSpring.js +0 -0
- package/lib/module/animation/spring/useSpring.js.map +1 -0
- package/lib/module/{values/animation → animation}/timing/Easing.js +0 -0
- package/lib/module/{values/animation → animation}/timing/Easing.js.map +0 -0
- package/lib/module/{values/animation → animation}/timing/createTiming.js +1 -1
- package/lib/module/animation/timing/createTiming.js.map +1 -0
- package/lib/module/{values/animation → animation}/timing/functions/bezier.js +0 -0
- package/lib/module/{values/animation → animation}/timing/functions/bezier.js.map +0 -0
- package/lib/module/{values/animation → animation}/timing/functions/getResolvedParams.js +0 -0
- package/lib/module/{values/animation → animation}/timing/functions/getResolvedParams.js.map +0 -0
- package/lib/module/{values/animation → animation}/timing/functions/index.js +0 -0
- package/lib/module/{values/animation → animation}/timing/functions/index.js.map +0 -0
- package/lib/module/{values/animation → animation}/timing/functions/timing.js +0 -0
- package/lib/module/{values/animation → animation}/timing/functions/timing.js.map +1 -1
- package/lib/module/{values/animation → animation}/timing/functions/types.js +0 -0
- package/lib/module/{values/animation → animation}/timing/functions/types.js.map +0 -0
- package/lib/module/{values/animation → animation}/timing/index.js +0 -0
- package/lib/module/{values/animation → animation}/timing/index.js.map +0 -0
- package/lib/module/{values/animation → animation}/timing/runTiming.js +0 -0
- package/lib/module/animation/timing/runTiming.js.map +1 -0
- package/lib/module/{values/animation → animation}/timing/useLoop.js +0 -0
- package/lib/module/{values/animation → animation}/timing/useLoop.js.map +0 -0
- package/lib/module/{values/animation → animation}/timing/useTiming.js +1 -1
- package/lib/module/animation/timing/useTiming.js.map +1 -0
- package/lib/module/{values/animation → animation}/types.js +0 -0
- package/lib/module/{values/animation → animation}/types.js.map +0 -0
- package/lib/module/index.js +1 -0
- package/lib/module/index.js.map +1 -1
- package/lib/module/renderer/components/colorFilters/BlendColor.js.map +1 -1
- package/lib/module/renderer/components/imageFilters/InnerShadow.js +3 -2
- package/lib/module/renderer/components/imageFilters/InnerShadow.js.map +1 -1
- package/lib/module/renderer/components/imageFilters/RuntimeShader.js +19 -0
- package/lib/module/renderer/components/imageFilters/RuntimeShader.js.map +1 -0
- package/lib/module/renderer/components/imageFilters/index.js +1 -0
- package/lib/module/renderer/components/imageFilters/index.js.map +1 -1
- package/lib/module/renderer/components/shaders/Gradient.js +2 -2
- package/lib/module/renderer/components/shaders/Gradient.js.map +1 -1
- package/lib/module/renderer/components/shaders/Shader.js.map +1 -1
- package/lib/module/renderer/processors/Rects.js +4 -15
- package/lib/module/renderer/processors/Rects.js.map +1 -1
- package/lib/module/renderer/processors/math/Matrix3.js +52 -72
- package/lib/module/renderer/processors/math/Matrix3.js.map +1 -1
- package/lib/module/renderer/processors/math/Vector.js +3 -5
- package/lib/module/renderer/processors/math/Vector.js.map +1 -1
- package/lib/module/skia/Color.js +9 -25
- package/lib/module/skia/Color.js.map +1 -1
- package/lib/module/skia/ImageFilter/ImageFilterFactory.js.map +1 -1
- package/lib/module/skia/Matrix.js.map +1 -1
- package/lib/module/skia/Shader/useShader.js +4 -1
- package/lib/module/skia/Shader/useShader.js.map +1 -1
- package/lib/module/skia/Skia.js +2 -46
- package/lib/module/skia/Skia.js.map +1 -1
- package/lib/module/skia/SkiaApi.js +2 -0
- package/lib/module/skia/SkiaApi.js.map +1 -0
- package/lib/module/values/api.js +4 -6
- package/lib/module/values/api.js.map +1 -1
- package/lib/module/values/api.web.js +7 -0
- package/lib/module/values/api.web.js.map +1 -0
- package/lib/module/values/index.js +0 -1
- package/lib/module/values/index.js.map +1 -1
- package/lib/module/values/web/RNSkAnimation.js +36 -0
- package/lib/module/values/web/RNSkAnimation.js.map +1 -0
- package/lib/module/values/web/RNSkClockValue.js +65 -0
- package/lib/module/values/web/RNSkClockValue.js.map +1 -0
- package/lib/module/values/web/RNSkDerivedValue.js +41 -0
- package/lib/module/values/web/RNSkDerivedValue.js.map +1 -0
- package/lib/module/values/web/RNSkReadonlyValue.js +36 -0
- package/lib/module/values/web/RNSkReadonlyValue.js.map +1 -0
- package/lib/module/values/web/RNSkValue.js +63 -0
- package/lib/module/values/web/RNSkValue.js.map +1 -0
- package/lib/module/values/web/api.js +19 -0
- package/lib/module/values/web/api.js.map +1 -0
- package/lib/module/values/web/index.js +2 -0
- package/lib/module/values/web/index.js.map +1 -0
- package/lib/module/views/SkiaView.js +1 -3
- package/lib/module/views/SkiaView.js.map +1 -1
- package/lib/module/views/api.js +4 -0
- package/lib/module/views/api.js.map +1 -0
- package/lib/module/views/types.js.map +1 -1
- package/lib/typescript/src/{values/animation → animation}/decay/decay.d.ts +0 -0
- package/lib/typescript/src/{values/animation → animation}/decay/index.d.ts +0 -0
- package/lib/typescript/src/{values/animation → animation}/decay/runDecay.d.ts +2 -2
- package/lib/typescript/src/{values/animation → animation}/decay/types.d.ts +1 -1
- package/lib/typescript/src/{values/animation → animation}/functions/index.d.ts +0 -0
- package/lib/typescript/src/animation/functions/interpolate.d.ts +11 -0
- package/lib/typescript/src/animation/functions/interpolateColors.d.ts +3 -0
- package/lib/typescript/src/{values/animation → animation}/index.d.ts +0 -0
- package/lib/typescript/src/{values/animation → animation}/spring/Spring.d.ts +0 -0
- package/lib/typescript/src/{values/animation → animation}/spring/functions/index.d.ts +0 -0
- package/lib/typescript/src/{values/animation → animation}/spring/functions/spring.d.ts +0 -0
- package/lib/typescript/src/{values/animation → animation}/spring/index.d.ts +0 -0
- package/lib/typescript/src/{values/animation → animation}/spring/runSpring.d.ts +1 -1
- package/lib/typescript/src/{values/animation → animation}/spring/types.d.ts +0 -0
- package/lib/typescript/src/{values/animation → animation}/spring/useSpring.d.ts +1 -1
- package/lib/typescript/src/{values/animation → animation}/timing/Easing.d.ts +0 -0
- package/lib/typescript/src/{values/animation → animation}/timing/createTiming.d.ts +2 -2
- package/lib/typescript/src/{values/animation → animation}/timing/functions/bezier.d.ts +0 -0
- package/lib/typescript/src/{values/animation → animation}/timing/functions/getResolvedParams.d.ts +0 -0
- package/lib/typescript/src/{values/animation → animation}/timing/functions/index.d.ts +0 -0
- package/lib/typescript/src/{values/animation → animation}/timing/functions/timing.d.ts +1 -1
- package/lib/typescript/src/{values/animation → animation}/timing/functions/types.d.ts +0 -0
- package/lib/typescript/src/{values/animation → animation}/timing/index.d.ts +0 -0
- package/lib/typescript/src/{values/animation → animation}/timing/runTiming.d.ts +1 -1
- package/lib/typescript/src/{values/animation → animation}/timing/useLoop.d.ts +0 -0
- package/lib/typescript/src/{values/animation → animation}/timing/useTiming.d.ts +1 -1
- package/lib/typescript/src/{values/animation → animation}/types.d.ts +0 -0
- package/lib/typescript/src/index.d.ts +1 -0
- package/lib/typescript/src/renderer/components/colorFilters/BlendColor.d.ts +1 -1
- package/lib/typescript/src/renderer/components/imageFilters/RuntimeShader.d.ts +7 -0
- package/lib/typescript/src/renderer/components/imageFilters/index.d.ts +1 -0
- package/lib/typescript/src/renderer/components/shaders/Gradient.d.ts +1 -1
- package/lib/typescript/src/renderer/components/shaders/Shader.d.ts +2 -2
- package/lib/typescript/src/renderer/components/shapes/Circle.d.ts +1 -4
- package/lib/typescript/src/renderer/processors/Rects.d.ts +9 -41
- package/lib/typescript/src/renderer/processors/math/Matrix3.d.ts +1 -5
- package/lib/typescript/src/renderer/processors/math/Vector.d.ts +5 -17
- package/lib/typescript/src/skia/Color.d.ts +8 -9
- package/lib/typescript/src/skia/ImageFilter/ImageFilterFactory.d.ts +16 -0
- package/lib/typescript/src/skia/Matrix.d.ts +7 -1
- package/lib/typescript/src/skia/RuntimeEffect/RuntimeEffect.d.ts +2 -1
- package/lib/typescript/src/skia/RuntimeEffect/RuntimeEffectFactory.d.ts +2 -2
- package/lib/typescript/src/skia/Shader/useShader.d.ts +1 -1
- package/lib/typescript/src/skia/Skia.d.ts +28 -95
- package/lib/typescript/src/skia/SkiaApi.d.ts +71 -0
- package/lib/typescript/src/skia/Surface/Surface.d.ts +1 -1
- package/lib/typescript/src/skia/Surface/SurfaceFactory.d.ts +2 -2
- package/lib/typescript/src/values/api.d.ts +2 -25
- package/lib/typescript/src/values/api.web.d.ts +2 -0
- package/lib/typescript/src/values/index.d.ts +0 -1
- package/lib/typescript/src/values/types.d.ts +24 -1
- package/lib/typescript/src/values/web/RNSkAnimation.d.ts +9 -0
- package/lib/typescript/src/values/web/RNSkClockValue.d.ts +13 -0
- package/lib/typescript/src/values/web/RNSkDerivedValue.d.ts +9 -0
- package/lib/typescript/src/values/web/RNSkReadonlyValue.d.ts +11 -0
- package/lib/typescript/src/values/web/RNSkValue.d.ts +14 -0
- package/lib/typescript/src/values/web/api.d.ts +2 -0
- package/lib/typescript/src/values/web/index.d.ts +1 -0
- package/lib/typescript/src/views/SkiaView.d.ts +3 -36
- package/lib/typescript/src/views/api.d.ts +5 -0
- package/lib/typescript/src/views/types.d.ts +32 -0
- package/package.json +2 -2
- package/src/{values/animation → animation}/decay/decay.ts +0 -0
- package/src/{values/animation → animation}/decay/index.ts +0 -0
- package/src/{values/animation → animation}/decay/runDecay.ts +2 -2
- package/src/{values/animation → animation}/decay/types.ts +1 -1
- package/src/{values/animation → animation}/functions/index.ts +0 -0
- package/src/animation/functions/interpolate.ts +182 -0
- package/src/animation/functions/interpolateColors.ts +58 -0
- package/src/{values/animation → animation}/index.ts +0 -0
- package/src/{values/animation → animation}/spring/Spring.ts +0 -0
- package/src/{values/animation → animation}/spring/functions/index.ts +0 -0
- package/src/{values/animation → animation}/spring/functions/spring.ts +0 -0
- package/src/{values/animation → animation}/spring/index.ts +0 -0
- package/src/{values/animation → animation}/spring/runSpring.ts +1 -1
- package/src/{values/animation → animation}/spring/types.ts +0 -0
- package/src/{values/animation → animation}/spring/useSpring.ts +1 -1
- package/src/{values/animation → animation}/timing/Easing.ts +0 -0
- package/src/{values/animation → animation}/timing/createTiming.ts +2 -2
- package/src/{values/animation → animation}/timing/functions/__tests__/timing.spec.ts +0 -0
- package/src/{values/animation → animation}/timing/functions/bezier.ts +0 -0
- package/src/{values/animation → animation}/timing/functions/getResolvedParams.ts +0 -0
- package/src/{values/animation → animation}/timing/functions/index.ts +0 -0
- package/src/{values/animation → animation}/timing/functions/timing.ts +1 -1
- package/src/{values/animation → animation}/timing/functions/types.ts +0 -0
- package/src/{values/animation → animation}/timing/index.ts +0 -0
- package/src/{values/animation → animation}/timing/runTiming.ts +1 -1
- package/src/{values/animation → animation}/timing/useLoop.ts +0 -0
- package/src/{values/animation → animation}/timing/useTiming.ts +2 -2
- package/src/{values/animation → animation}/types.ts +0 -0
- package/src/index.ts +1 -0
- package/src/renderer/components/colorFilters/BlendColor.tsx +1 -1
- package/src/renderer/components/imageFilters/InnerShadow.tsx +4 -2
- package/src/renderer/components/imageFilters/RuntimeShader.tsx +23 -0
- package/src/renderer/components/imageFilters/index.ts +1 -0
- package/src/renderer/components/shaders/Gradient.ts +2 -4
- package/src/renderer/components/shaders/Shader.tsx +2 -2
- package/src/renderer/processors/Rects.ts +6 -12
- package/src/renderer/processors/math/Matrix3.ts +24 -105
- package/src/renderer/processors/math/Vector.ts +3 -2
- package/src/skia/Color.ts +13 -27
- package/src/skia/ImageFilter/ImageFilterFactory.ts +20 -0
- package/src/skia/Matrix.ts +8 -1
- package/src/skia/RuntimeEffect/RuntimeEffect.ts +3 -1
- package/src/skia/RuntimeEffect/RuntimeEffectFactory.ts +2 -2
- package/src/skia/Shader/useShader.ts +4 -1
- package/src/skia/Skia.ts +4 -126
- package/src/skia/SkiaApi.ts +86 -0
- package/src/skia/Surface/Surface.ts +1 -1
- package/src/skia/Surface/SurfaceFactory.ts +2 -2
- package/src/values/api.ts +3 -42
- package/src/values/api.web.ts +5 -0
- package/src/values/index.ts +0 -1
- package/src/values/types.ts +30 -1
- package/src/values/web/RNSkAnimation.ts +33 -0
- package/src/values/web/RNSkClockValue.ts +58 -0
- package/src/values/web/RNSkDerivedValue.ts +38 -0
- package/src/values/web/RNSkReadonlyValue.ts +32 -0
- package/src/values/web/RNSkValue.ts +57 -0
- package/src/values/web/__tests__/RNSkAnimation.spec.ts +21 -0
- package/src/values/web/__tests__/RNSkDerivedValue.spec.ts +15 -0
- package/src/values/web/__tests__/RNSkReadonlyValue.spec.ts +8 -0
- package/src/values/web/__tests__/RNSkValue.spec.ts +11 -0
- package/src/values/web/api.ts +33 -0
- package/src/values/web/index.ts +1 -0
- package/src/views/SkiaView.tsx +3 -49
- package/src/views/api.ts +7 -0
- package/src/views/types.ts +40 -0
- package/lib/commonjs/values/animation/decay/runDecay.js.map +0 -1
- package/lib/commonjs/values/animation/functions/interpolate.js +0 -139
- package/lib/commonjs/values/animation/functions/interpolate.js.map +0 -1
- package/lib/commonjs/values/animation/functions/interpolateColors.js +0 -47
- package/lib/commonjs/values/animation/functions/interpolateColors.js.map +0 -1
- package/lib/commonjs/values/animation/spring/runSpring.js.map +0 -1
- package/lib/commonjs/values/animation/spring/useSpring.js.map +0 -1
- package/lib/commonjs/values/animation/timing/createTiming.js.map +0 -1
- package/lib/commonjs/values/animation/timing/runTiming.js.map +0 -1
- package/lib/commonjs/values/animation/timing/useTiming.js.map +0 -1
- package/lib/module/values/animation/decay/runDecay.js.map +0 -1
- package/lib/module/values/animation/functions/interpolate.js +0 -132
- package/lib/module/values/animation/functions/interpolate.js.map +0 -1
- package/lib/module/values/animation/functions/interpolateColors.js +0 -32
- package/lib/module/values/animation/functions/interpolateColors.js.map +0 -1
- package/lib/module/values/animation/spring/runSpring.js.map +0 -1
- package/lib/module/values/animation/spring/useSpring.js.map +0 -1
- package/lib/module/values/animation/timing/createTiming.js.map +0 -1
- package/lib/module/values/animation/timing/runTiming.js.map +0 -1
- package/lib/module/values/animation/timing/useTiming.js.map +0 -1
- package/lib/typescript/scripts/install-npm.d.ts +0 -1
- package/lib/typescript/src/values/animation/functions/interpolate.d.ts +0 -7
- package/lib/typescript/src/values/animation/functions/interpolateColors.d.ts +0 -3
- package/src/values/animation/functions/interpolate.ts +0 -169
- package/src/values/animation/functions/interpolateColors.ts +0 -62
@@ -1 +0,0 @@
|
|
1
|
-
{"version":3,"sources":["useSpring.ts"],"names":["useTiming","Spring","createSpringEasing","useSpring","toOrParams","config","callback","Config","Default"],"mappings":"AAMA,SAASA,SAAT,QAA0B,WAA1B;AAEA,SAASC,MAAT,QAAuB,UAAvB;AACA,SAASC,kBAAT,QAAmC,oBAAnC;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;;AACA,OAAO,MAAMC,SAAS,GAAG,CACvBC,UADuB,EAEvBC,MAFuB,EAGvBC,QAHuB,KAKvBN,SAAS,CACPI,UADO,EAEPF,kBAAkB,CAACG,MAAD,aAACA,MAAD,cAACA,MAAD,GAAWJ,MAAM,CAACM,MAAP,CAAcC,OAAzB,CAFX,EAGPF,QAHO,CALJ","sourcesContent":["import type { SkiaReadonlyValue } from \"../../types\";\nimport type {\n SpringConfig,\n AnimationParams,\n AnimationCallback,\n} from \"../types\";\nimport { useTiming } from \"../timing\";\n\nimport { Spring } from \"./Spring\";\nimport { createSpringEasing } from \"./functions/spring\";\n\n/**\n * Creats a spring based animation value that will run whenever\n * the animation parameters change.\n * @param toOrParams\n * @param config\n * @returns\n */\nexport const useSpring = (\n toOrParams: number | AnimationParams,\n config?: SpringConfig,\n callback?: AnimationCallback\n): SkiaReadonlyValue<number> =>\n useTiming(\n toOrParams,\n createSpringEasing(config ?? Spring.Config.Default),\n callback\n );\n"]}
|
@@ -1 +0,0 @@
|
|
1
|
-
{"version":3,"sources":["createTiming.ts"],"names":["ValueApi","timing","createTiming","params","value","callback","resolvedParams","from","current","animationFunction","t","state","nextState","duration","easing","loop","yoyo","finished","to","createAnimation"],"mappings":"AAMA,SAASA,QAAT,QAAyB,WAAzB;AAEA,SAASC,MAAT,QAAuB,aAAvB;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AACA,OAAO,MAAMC,YAAY,GAAG,CAC1BC,MAD0B,EAE1BC,KAF0B,EAG1BC,QAH0B,KAIvB;AAAA;;AACH;AACA;AACA,QAAMC,cAAc,GAAG,EACrB,GAAGH,MADkB;AAErBI,IAAAA,IAAI,0BAAEJ,MAAM,CAACI,IAAT,uDAAiBH,KAAjB,aAAiBA,KAAjB,uBAAiBA,KAAK,CAAEI,OAAxB,uCAAmC;AAFlB,GAAvB,CAHG,CAQH;;AACA,QAAMC,iBAAiB,GAAG,CAACC,CAAD,EAAYC,KAAZ,KAAkD;AAAA;;AAC1E;AACA,UAAMC,SAAS,GAAGX,MAAM,CACtBS,CADsB,EAEtBP,MAAM,CAACU,QAFe,EAGtBV,MAAM,CAACW,MAHe,kBAItBX,MAAM,CAACY,IAJe,uDAIP,KAJO,kBAKtBZ,MAAM,CAACa,IALe,uDAKP,KALO,EAMtBL,KANsB,aAMtBA,KANsB,cAMtBA,KANsB,GAMb;AAAEH,MAAAA,OAAO,EAAEL,MAAM,CAACI,IAAlB;AAAyBU,MAAAA,QAAQ,EAAE;AAAnC,KANa,CAAxB;AAQA,UAAMT,OAAO,GACXI,SAAS,CAACJ,OAAV,IAAqBF,cAAc,CAACY,EAAf,GAAoBZ,cAAc,CAACC,IAAxD,IACAD,cAAc,CAACC,IAFjB;;AAGA,QAAIF,QAAQ,IAAIO,SAAS,CAACK,QAAV,KAAuB,IAAvC,EAA6C;AAC3CZ,MAAAA,QAAQ,CAACG,OAAD,CAAR;AACD;;AACD,WAAO,EACL,GAAGI,SADE;AAELJ,MAAAA;AAFK,KAAP;AAID,GApBD,CATG,CA+BH;;;AACA,SAAOR,QAAQ,CAACmB,eAAT,CAAyBV,iBAAzB,CAAP;AACD,CArCM","sourcesContent":["import type {\n TimingConfig,\n RequiredAnimationParams,\n AnimationCallback,\n} from \"../types\";\nimport type { AnimationState, SkiaValue } from \"../../types\";\nimport { ValueApi } from \"../../api\";\n\nimport { timing } from \"./functions\";\n\n/**\n * Creates an animation that is driven by a clock value.\n * The value will be run from / to the value in params and modified\n * by the provided easing curve for the length of the duration. When\n * the value has reached its desired \"to\" value the animation\n * will be stopped. If loop is set to true, the animation will continue\n * to run until stopped.\n *\n * @param params Animation parameters\n * @param config Spring or timing configuration\n * @param value Optional value that the animation will update\n * @params an animation value that can be used to start/stop\n * the animation.\n */\nexport const createTiming = (\n params: RequiredAnimationParams & Required<TimingConfig>,\n value?: SkiaValue<number>,\n callback?: AnimationCallback\n) => {\n // Update from to be either the declared from value,\n // the current value of the value or zero\n const resolvedParams = {\n ...params,\n from: params.from ?? value?.current ?? 0,\n };\n\n // Update function for the animation value\n const animationFunction = (t: number, state: AnimationState | undefined) => {\n // Update the input value using the provided update function\n const nextState = timing(\n t,\n params.duration,\n params.easing,\n params.loop ?? false,\n params.yoyo ?? false,\n state ?? { current: params.from!, finished: false }\n );\n const current =\n nextState.current * (resolvedParams.to - resolvedParams.from!) +\n resolvedParams.from!;\n if (callback && nextState.finished === true) {\n callback(current);\n }\n return {\n ...nextState,\n current,\n };\n };\n\n // Create animation value\n return ValueApi.createAnimation(animationFunction);\n};\n"]}
|
@@ -1 +0,0 @@
|
|
1
|
-
{"version":3,"sources":["runTiming.ts"],"names":["getResolvedParams","createTiming","runTiming","value","toOrParams","config","callback","resolvedParameters","animation"],"mappings":"AAOA,SAASA,iBAAT,QAAkC,aAAlC;AACA,SAASC,YAAT,QAA6B,gBAA7B;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AACA,OAAO,MAAMC,SAAS,GAAG,CACvBC,KADuB,EAEvBC,UAFuB,EAGvBC,MAHuB,EAIvBC,QAJuB,KAKL;AAClB,QAAMC,kBAAkB,GAAGP,iBAAiB,CAACI,UAAD,EAAaC,MAAb,CAA5C;AACA,QAAMG,SAAS,GAAGP,YAAY,CAACM,kBAAD,EAAqBJ,KAArB,EAA4BG,QAA5B,CAA9B;AACAH,EAAAA,KAAK,CAACK,SAAN,GAAkBA,SAAlB;AACA,SAAOA,SAAP;AACD,CAVM","sourcesContent":["import type { SkiaValue, SkiaAnimation } from \"../../types\";\nimport type {\n AnimationParams,\n TimingConfig,\n AnimationCallback,\n} from \"../types\";\n\nimport { getResolvedParams } from \"./functions\";\nimport { createTiming } from \"./createTiming\";\n/**\n * Creates a new animation on an existing value that will be driven by\n * an animation value. The value will be run from / to the value in\n * params and modified by the provided easing curve for the length of\n * the duration. When the value has reached its desired \"to\" value the\n * animation will be stopped.\n *\n * @param value The value to animate\n * @param toOrParams To value or Animation parameters\n * @param config Spring or timing configuration\n * @returns an animation value that can be used to start/stop\n * the animation.\n */\nexport const runTiming = (\n value: SkiaValue<number>,\n toOrParams: number | AnimationParams,\n config?: TimingConfig,\n callback?: AnimationCallback\n): SkiaAnimation => {\n const resolvedParameters = getResolvedParams(toOrParams, config);\n const animation = createTiming(resolvedParameters, value, callback);\n value.animation = animation;\n return animation;\n};\n"]}
|
@@ -1 +0,0 @@
|
|
1
|
-
{"version":3,"sources":["useTiming.ts"],"names":["useEffect","useMemo","useRef","useValue","getResolvedParams","createTiming","useTiming","toOrParams","config","callback","prevCfgRef","resolvedParameters","nextParams","equals","current","value","from","prevAnimationRef","prevParamsRef","animation","undefined","a","b","JSON","stringify"],"mappings":"AAAA,SAASA,SAAT,EAAoBC,OAApB,EAA6BC,MAA7B,QAA2C,OAA3C;AAQA,SAASC,QAAT,QAAyB,sBAAzB;AAEA,SAASC,iBAAT,QAAkC,aAAlC;AACA,SAASC,YAAT,QAA6B,gBAA7B;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;;AACA,OAAO,MAAMC,SAAS,GAAG,CACvBC,UADuB,EAEvBC,MAFuB,EAGvBC,QAHuB,KAIO;AAAA;;AAC9B;AACA;AACA,QAAMC,UAAU,GAAGR,MAAM,EAAzB;AACA,QAAMS,kBAAkB,GAAGV,OAAO,CAAC,MAAM;AACvC,UAAMW,UAAU,GAAGR,iBAAiB,CAACG,UAAD,EAAaC,MAAb,CAApC;;AACA,QAAI,CAACK,MAAM,CAACH,UAAU,CAACI,OAAZ,EAAqBF,UAArB,CAAX,EAA6C;AAC3CF,MAAAA,UAAU,CAACI,OAAX,GAAqBF,UAArB;AACD;;AACD,WAAOF,UAAU,CAACI,OAAlB;AACD,GANiC,EAM/B,CAACN,MAAD,EAASD,UAAT,CAN+B,CAAlC,CAJ8B,CAY9B;;AACA,QAAMQ,KAAK,GAAGZ,QAAQ,0BAACQ,kBAAkB,CAACK,IAApB,yEAA4B,CAA5B,CAAtB,CAb8B,CAe9B;AACA;;AACA,QAAMC,gBAAgB,GAAGf,MAAM,EAA/B;AACA,QAAMgB,aAAa,GAAGhB,MAAM,EAA5B;AACA,QAAMiB,SAAS,GAAGlB,OAAO,CAAC,MAAM;AAC9B,QAAI,CAACY,MAAM,CAACK,aAAa,CAACJ,OAAf,EAAwBH,kBAAxB,CAAX,EAAwD;AACtDO,MAAAA,aAAa,CAACJ,OAAd,GAAwBH,kBAAxB;AACAM,MAAAA,gBAAgB,CAACH,OAAjB,GAA2BT,YAAY,CACrCM,kBADqC,EAErCI,KAFqC,EAGrCN,QAHqC,CAAvC;AAKD;;AACD,WAAOQ,gBAAgB,CAACH,OAAxB;AACD,GAVwB,EAUtB,CAACL,QAAD,EAAWE,kBAAX,EAA+BI,KAA/B,CAVsB,CAAzB,CAnB8B,CA+B9B;;AACAf,EAAAA,SAAS,CAAC,MAAM;AACde,IAAAA,KAAK,CAACI,SAAN,GAAkBA,SAAlB;AACA,WAAO,MAAOJ,KAAK,CAACI,SAAN,GAAkBC,SAAhC;AACD,GAHQ,EAGN,CAACD,SAAD,EAAYJ,KAAZ,CAHM,CAAT,CAhC8B,CAqC9B;;AACA,SAAOA,KAAP;AACD,CA3CM;;AA6CP,MAAMF,MAAM,GAAG,CAASQ,CAAT,EAAgBC,CAAhB,KAA0B;AACvC,SAAOC,IAAI,CAACC,SAAL,CAAeH,CAAf,MAAsBE,IAAI,CAACC,SAAL,CAAeF,CAAf,CAA7B;AACD,CAFD","sourcesContent":["import { useEffect, useMemo, useRef } from \"react\";\n\nimport type { SkiaReadonlyValue, SkiaAnimation } from \"../../types\";\nimport type {\n AnimationParams,\n TimingConfig,\n AnimationCallback,\n} from \"../types\";\nimport { useValue } from \"../../hooks/useValue\";\n\nimport { getResolvedParams } from \"./functions\";\nimport { createTiming } from \"./createTiming\";\n\n/**\n * Creats an animation value that will run whenever\n * the animation parameters change. The animation start immediately.\n * @param toOrParams\n * @param config\n * @returns A value that is animated\n */\nexport const useTiming = (\n toOrParams: number | AnimationParams,\n config?: TimingConfig,\n callback?: AnimationCallback\n): SkiaReadonlyValue<number> => {\n // Resolve parameters - keep a cached version to avoid\n // unnecesary re-renders.\n const prevCfgRef = useRef<ReturnType<typeof getResolvedParams>>();\n const resolvedParameters = useMemo(() => {\n const nextParams = getResolvedParams(toOrParams, config);\n if (!equals(prevCfgRef.current, nextParams)) {\n prevCfgRef.current = nextParams;\n }\n return prevCfgRef.current!;\n }, [config, toOrParams]);\n\n // Create value\n const value = useValue(resolvedParameters.from ?? 0);\n\n // Create timing animation - keep a cached version to avoid\n // uneccessary recreation of animations\n const prevAnimationRef = useRef<SkiaAnimation>();\n const prevParamsRef = useRef<typeof resolvedParameters>();\n const animation = useMemo(() => {\n if (!equals(prevParamsRef.current, resolvedParameters)) {\n prevParamsRef.current = resolvedParameters;\n prevAnimationRef.current = createTiming(\n resolvedParameters,\n value,\n callback\n );\n }\n return prevAnimationRef.current!;\n }, [callback, resolvedParameters, value]);\n\n // Run animation on the value - and stop it on unmount\n useEffect(() => {\n value.animation = animation;\n return () => (value.animation = undefined);\n }, [animation, value]);\n\n // Return the value that is animated\n return value;\n};\n\nconst equals = <T1, T2>(a: T1, b: T2) => {\n return JSON.stringify(a) === JSON.stringify(b);\n};\n"]}
|
@@ -1 +0,0 @@
|
|
1
|
-
export {};
|
@@ -1,7 +0,0 @@
|
|
1
|
-
declare type ExtrapolateType = "extend" | "identity" | "clamp";
|
2
|
-
export declare function interpolate(input: number, inputRange: readonly number[], outputRange: readonly number[], options?: {
|
3
|
-
easing?: (input: number) => number;
|
4
|
-
extrapolateLeft?: ExtrapolateType;
|
5
|
-
extrapolateRight?: ExtrapolateType;
|
6
|
-
}): number;
|
7
|
-
export {};
|
@@ -1,169 +0,0 @@
|
|
1
|
-
// eslint-disable-next-line max-len
|
2
|
-
// Taken from https://github.com/facebook/react-native/blob/0b9ea60b4fee8cacc36e7160e31b91fc114dbc0d/Libraries/Animated/src/nodes/AnimatedInterpolation.js
|
3
|
-
|
4
|
-
type ExtrapolateType = "extend" | "identity" | "clamp";
|
5
|
-
|
6
|
-
function interpolateFunction(
|
7
|
-
input: number,
|
8
|
-
inputRange: [number, number],
|
9
|
-
outputRange: [number, number],
|
10
|
-
options: {
|
11
|
-
easing: (input: number) => number;
|
12
|
-
extrapolateLeft: ExtrapolateType;
|
13
|
-
extrapolateRight: ExtrapolateType;
|
14
|
-
}
|
15
|
-
): number {
|
16
|
-
const { extrapolateLeft, extrapolateRight, easing } = options;
|
17
|
-
|
18
|
-
let result = input;
|
19
|
-
const [inputMin, inputMax] = inputRange;
|
20
|
-
const [outputMin, outputMax] = outputRange;
|
21
|
-
|
22
|
-
if (result < inputMin) {
|
23
|
-
if (extrapolateLeft === "identity") {
|
24
|
-
return result;
|
25
|
-
}
|
26
|
-
|
27
|
-
if (extrapolateLeft === "clamp") {
|
28
|
-
result = inputMin;
|
29
|
-
} else if (extrapolateLeft === "extend") {
|
30
|
-
// noop
|
31
|
-
}
|
32
|
-
}
|
33
|
-
|
34
|
-
if (result > inputMax) {
|
35
|
-
if (extrapolateRight === "identity") {
|
36
|
-
return result;
|
37
|
-
}
|
38
|
-
|
39
|
-
if (extrapolateRight === "clamp") {
|
40
|
-
result = inputMax;
|
41
|
-
} else if (extrapolateRight === "extend") {
|
42
|
-
// noop
|
43
|
-
}
|
44
|
-
}
|
45
|
-
|
46
|
-
if (outputMin === outputMax) {
|
47
|
-
return outputMin;
|
48
|
-
}
|
49
|
-
|
50
|
-
// Input Range
|
51
|
-
result = (result - inputMin) / (inputMax - inputMin);
|
52
|
-
|
53
|
-
// Easing
|
54
|
-
result = easing(result);
|
55
|
-
|
56
|
-
// Output Range
|
57
|
-
result = result * (outputMax - outputMin) + outputMin;
|
58
|
-
|
59
|
-
return result;
|
60
|
-
}
|
61
|
-
|
62
|
-
function findRange(input: number, inputRange: readonly number[]) {
|
63
|
-
let i;
|
64
|
-
for (i = 1; i < inputRange.length - 1; ++i) {
|
65
|
-
if (inputRange[i] >= input) {
|
66
|
-
break;
|
67
|
-
}
|
68
|
-
}
|
69
|
-
|
70
|
-
return i - 1;
|
71
|
-
}
|
72
|
-
|
73
|
-
function checkValidInputRange(arr: readonly number[]) {
|
74
|
-
for (let i = 1; i < arr.length; ++i) {
|
75
|
-
if (!(arr[i] > arr[i - 1])) {
|
76
|
-
throw new Error(
|
77
|
-
`inputRange must be strictly monotonically non-decreasing but got [${arr.join(
|
78
|
-
","
|
79
|
-
)}]`
|
80
|
-
);
|
81
|
-
}
|
82
|
-
}
|
83
|
-
}
|
84
|
-
|
85
|
-
function checkInfiniteRange(name: string, arr: readonly number[]) {
|
86
|
-
if (arr.length < 2) {
|
87
|
-
throw new Error(name + " must have at least 2 elements");
|
88
|
-
}
|
89
|
-
|
90
|
-
for (const index in arr) {
|
91
|
-
if (typeof arr[index] !== "number") {
|
92
|
-
throw new Error(`${name} must contain only numbers`);
|
93
|
-
}
|
94
|
-
|
95
|
-
if (arr[index] === -Infinity || arr[index] === Infinity) {
|
96
|
-
throw new Error(
|
97
|
-
`${name} must contain only finite numbers, but got [${arr.join(",")}]`
|
98
|
-
);
|
99
|
-
}
|
100
|
-
}
|
101
|
-
}
|
102
|
-
|
103
|
-
export function interpolate(
|
104
|
-
input: number,
|
105
|
-
inputRange: readonly number[],
|
106
|
-
outputRange: readonly number[],
|
107
|
-
options?: {
|
108
|
-
easing?: (input: number) => number;
|
109
|
-
extrapolateLeft?: ExtrapolateType;
|
110
|
-
extrapolateRight?: ExtrapolateType;
|
111
|
-
}
|
112
|
-
): number {
|
113
|
-
if (typeof input === "undefined") {
|
114
|
-
throw new Error("input can not be undefined");
|
115
|
-
}
|
116
|
-
|
117
|
-
if (typeof inputRange === "undefined") {
|
118
|
-
throw new Error("inputRange can not be undefined");
|
119
|
-
}
|
120
|
-
|
121
|
-
if (typeof outputRange === "undefined") {
|
122
|
-
throw new Error("outputRange can not be undefined");
|
123
|
-
}
|
124
|
-
|
125
|
-
if (inputRange.length !== outputRange.length) {
|
126
|
-
throw new Error(
|
127
|
-
"inputRange (" +
|
128
|
-
inputRange.length +
|
129
|
-
") and outputRange (" +
|
130
|
-
outputRange.length +
|
131
|
-
") must have the same length"
|
132
|
-
);
|
133
|
-
}
|
134
|
-
|
135
|
-
checkInfiniteRange("inputRange", inputRange);
|
136
|
-
checkInfiniteRange("outputRange", outputRange);
|
137
|
-
|
138
|
-
checkValidInputRange(inputRange);
|
139
|
-
|
140
|
-
const easing = options?.easing ?? ((num: number): number => num);
|
141
|
-
|
142
|
-
let extrapolateLeft: ExtrapolateType = "extend";
|
143
|
-
if (options?.extrapolateLeft !== undefined) {
|
144
|
-
// eslint-disable-next-line prefer-destructuring
|
145
|
-
extrapolateLeft = options.extrapolateLeft;
|
146
|
-
}
|
147
|
-
|
148
|
-
let extrapolateRight: ExtrapolateType = "extend";
|
149
|
-
if (options?.extrapolateRight !== undefined) {
|
150
|
-
// eslint-disable-next-line prefer-destructuring
|
151
|
-
extrapolateRight = options.extrapolateRight;
|
152
|
-
}
|
153
|
-
|
154
|
-
if (typeof input !== "number") {
|
155
|
-
throw new TypeError("Cannot interpolate an input which is not a number");
|
156
|
-
}
|
157
|
-
|
158
|
-
const range = findRange(input, inputRange);
|
159
|
-
return interpolateFunction(
|
160
|
-
input,
|
161
|
-
[inputRange[range], inputRange[range + 1]],
|
162
|
-
[outputRange[range], outputRange[range + 1]],
|
163
|
-
{
|
164
|
-
easing,
|
165
|
-
extrapolateLeft,
|
166
|
-
extrapolateRight,
|
167
|
-
}
|
168
|
-
);
|
169
|
-
}
|
@@ -1,62 +0,0 @@
|
|
1
|
-
import { mix } from "../../../renderer";
|
2
|
-
import type { Color } from "../../../skia";
|
3
|
-
import { alphaf, blue, green, red, rgbaColor, Skia } from "../../../skia";
|
4
|
-
|
5
|
-
import { interpolate } from "./interpolate";
|
6
|
-
|
7
|
-
const CLAMP = {
|
8
|
-
extrapolateLeft: "clamp",
|
9
|
-
extrapolateRight: "clamp",
|
10
|
-
} as const;
|
11
|
-
|
12
|
-
const interpolateColorsRGB = (
|
13
|
-
value: number,
|
14
|
-
inputRange: number[],
|
15
|
-
outputRange: number[]
|
16
|
-
) => {
|
17
|
-
const r = interpolate(
|
18
|
-
value,
|
19
|
-
inputRange,
|
20
|
-
outputRange.map((c) => red(c)),
|
21
|
-
CLAMP
|
22
|
-
);
|
23
|
-
const g = interpolate(
|
24
|
-
value,
|
25
|
-
inputRange,
|
26
|
-
outputRange.map((c) => green(c)),
|
27
|
-
CLAMP
|
28
|
-
);
|
29
|
-
const b = interpolate(
|
30
|
-
value,
|
31
|
-
inputRange,
|
32
|
-
outputRange.map((c) => blue(c)),
|
33
|
-
CLAMP
|
34
|
-
);
|
35
|
-
const a = interpolate(
|
36
|
-
value,
|
37
|
-
inputRange,
|
38
|
-
outputRange.map((c) => alphaf(c)),
|
39
|
-
CLAMP
|
40
|
-
);
|
41
|
-
return rgbaColor(r, g, b, a);
|
42
|
-
};
|
43
|
-
|
44
|
-
export const interpolateColors = (
|
45
|
-
value: number,
|
46
|
-
inputRange: number[],
|
47
|
-
_outputRange: Color[]
|
48
|
-
) => {
|
49
|
-
const outputRange = _outputRange.map((cl) => Skia.Color(cl));
|
50
|
-
return interpolateColorsRGB(value, inputRange, outputRange);
|
51
|
-
};
|
52
|
-
|
53
|
-
// This is fast. To be reconcilled with interpolateColors
|
54
|
-
// it looks like interpolateColors may not be working as expected
|
55
|
-
// these functions need to be tested more thoroughly on both platform
|
56
|
-
export const mixColors = (value: number, x: number, y: number) => {
|
57
|
-
const r = mix(value, red(x), red(y));
|
58
|
-
const g = mix(value, green(x), green(y));
|
59
|
-
const b = mix(value, blue(x), blue(y));
|
60
|
-
const a = mix(value, alphaf(x), alphaf(y));
|
61
|
-
return rgbaColor(r, g, b, a);
|
62
|
-
};
|