@shopify/react-native-skia 0.1.124 → 0.1.125
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 +98 -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
@@ -0,0 +1,71 @@
|
|
1
|
+
import type { ImageFilterFactory } from "./ImageFilter";
|
2
|
+
import type { PathFactory } from "./Path";
|
3
|
+
import type { ColorFilterFactory } from "./ColorFilter";
|
4
|
+
import type { SkFont } from "./Font";
|
5
|
+
import type { SkTypeface, TypefaceFactory } from "./Typeface";
|
6
|
+
import type { ImageFactory } from "./Image";
|
7
|
+
import type { MaskFilterFactory } from "./MaskFilter";
|
8
|
+
import type { SkPaint } from "./Paint";
|
9
|
+
import type { SkRect } from "./Rect";
|
10
|
+
import type { SkRRect } from "./RRect";
|
11
|
+
import type { RuntimeEffectFactory } from "./RuntimeEffect";
|
12
|
+
import type { ShaderFactory } from "./Shader";
|
13
|
+
import type { SkMatrix } from "./Matrix";
|
14
|
+
import type { PathEffectFactory } from "./PathEffect";
|
15
|
+
import type { SkPoint } from "./Point";
|
16
|
+
import type { SkVertices, VertexMode } from "./Vertices/Vertices";
|
17
|
+
import type { DataFactory } from "./Data";
|
18
|
+
import type { SVGFactory } from "./SVG";
|
19
|
+
import type { TextBlobFactory } from "./TextBlob";
|
20
|
+
import type { FontMgrFactory } from "./FontMgr/FontMgrFactory";
|
21
|
+
import type { SurfaceFactory } from "./Surface";
|
22
|
+
import "./NativeSetup";
|
23
|
+
import type { SkRSXform } from "./RSXform";
|
24
|
+
import type { SkPath } from "./Path/Path";
|
25
|
+
import type { SkContourMeasureIter } from "./ContourMeasure";
|
26
|
+
import type { PictureFactory, SkPictureRecorder } from "./Picture";
|
27
|
+
import type { Color, SkColor } from "./Color";
|
28
|
+
import type { SkRuntimeShaderBuilder, SkRuntimeEffect } from "./RuntimeEffect/RuntimeEffect";
|
29
|
+
/**
|
30
|
+
* Declares the interface for the native Skia API
|
31
|
+
*/
|
32
|
+
export interface SkiaApi {
|
33
|
+
Point: (x: number, y: number) => SkPoint;
|
34
|
+
XYWHRect: (x: number, y: number, width: number, height: number) => SkRect;
|
35
|
+
RuntimeShaderBuilder: (rt: SkRuntimeEffect) => SkRuntimeShaderBuilder;
|
36
|
+
RRectXY: (rect: SkRect, rx: number, ry: number) => SkRRect;
|
37
|
+
RSXform: (scos: number, ssin: number, tx: number, ty: number) => SkRSXform;
|
38
|
+
Color: (color: Color) => SkColor;
|
39
|
+
parseColorString: (color: string) => SkColor | undefined;
|
40
|
+
ContourMeasureIter: (path: SkPath, forceClosed: boolean, resScale: number) => SkContourMeasureIter;
|
41
|
+
Paint: () => SkPaint;
|
42
|
+
PictureRecorder: () => SkPictureRecorder;
|
43
|
+
Picture: PictureFactory;
|
44
|
+
Path: PathFactory;
|
45
|
+
Matrix: () => SkMatrix;
|
46
|
+
ColorFilter: ColorFilterFactory;
|
47
|
+
Font: (typeface?: SkTypeface, size?: number) => SkFont;
|
48
|
+
Typeface: TypefaceFactory;
|
49
|
+
MaskFilter: MaskFilterFactory;
|
50
|
+
RuntimeEffect: RuntimeEffectFactory;
|
51
|
+
ImageFilter: ImageFilterFactory;
|
52
|
+
Shader: ShaderFactory;
|
53
|
+
PathEffect: PathEffectFactory;
|
54
|
+
/**
|
55
|
+
* Returns an Vertices based on the given positions and optional parameters.
|
56
|
+
* See SkVertices.h (especially the Builder) for more details.
|
57
|
+
* @param mode
|
58
|
+
* @param positions
|
59
|
+
* @param textureCoordinates
|
60
|
+
* @param colors - either a list of int colors or a flattened color array.
|
61
|
+
* @param indices
|
62
|
+
* @param isVolatile
|
63
|
+
*/
|
64
|
+
MakeVertices(mode: VertexMode, positions: SkPoint[], textureCoordinates?: SkPoint[] | null, colors?: SkColor[], indices?: number[] | null, isVolatile?: boolean): SkVertices;
|
65
|
+
Data: DataFactory;
|
66
|
+
Image: ImageFactory;
|
67
|
+
SVG: SVGFactory;
|
68
|
+
FontMgr: FontMgrFactory;
|
69
|
+
TextBlob: TextBlobFactory;
|
70
|
+
Surface: SurfaceFactory;
|
71
|
+
}
|
@@ -2,7 +2,7 @@ import type { SkImage } from "../Image";
|
|
2
2
|
import type { SkCanvas } from "../Canvas";
|
3
3
|
import type { SkJSIInstance } from "../JsiInstance";
|
4
4
|
import type { SkRect } from "../Rect";
|
5
|
-
export interface
|
5
|
+
export interface SkSurface extends SkJSIInstance<"Surface"> {
|
6
6
|
/** Returns Canvas that draws into the surface. Subsequent calls return the
|
7
7
|
same Canvas. Canvas returned is managed and owned by Surface, and is
|
8
8
|
deleted when Surface is deleted.
|
@@ -1,4 +1,4 @@
|
|
1
|
-
import type {
|
1
|
+
import type { SkSurface } from "./Surface";
|
2
2
|
export interface SurfaceFactory {
|
3
3
|
/**
|
4
4
|
* Returns a CPU backed surface with the given dimensions, an SRGB colorspace, Unpremul
|
@@ -7,5 +7,5 @@ export interface SurfaceFactory {
|
|
7
7
|
* @param width - number of pixels of the width of the drawable area.
|
8
8
|
* @param height - number of pixels of the height of the drawable area.
|
9
9
|
*/
|
10
|
-
Make: (width: number, height: number) =>
|
10
|
+
Make: (width: number, height: number) => SkSurface | null;
|
11
11
|
}
|
@@ -1,29 +1,6 @@
|
|
1
|
-
import type {
|
2
|
-
export interface ISkiaValueApi {
|
3
|
-
/**
|
4
|
-
* Creates a new value that holds the initial value and that
|
5
|
-
* can be changed.
|
6
|
-
*/
|
7
|
-
createValue: <T>(initialValue: T) => SkiaValue<T>;
|
8
|
-
/**
|
9
|
-
* Creates a derived value. This is a calculated value that returns the result of
|
10
|
-
* a function that is called with the values of the dependencies.
|
11
|
-
*/
|
12
|
-
createDerivedValue: <R>(cb: () => R, values: Array<SkiaReadonlyValue<unknown>>) => SkiaReadonlyValue<R>;
|
13
|
-
/**
|
14
|
-
* Creates a clock value where the value is the number of milliseconds elapsed
|
15
|
-
* since the clock was created
|
16
|
-
*/
|
17
|
-
createClockValue: () => SkiaClockValue;
|
18
|
-
/**
|
19
|
-
* Creates an animation that is driven from a clock and updated every frame.
|
20
|
-
* @param cb Callback to calculate next value from time.
|
21
|
-
* @returns An animation object that can control a value.
|
22
|
-
*/
|
23
|
-
createAnimation: <S extends AnimationState = AnimationState>(cb: (t: number, state: S | undefined) => S) => SkiaAnimation;
|
24
|
-
}
|
1
|
+
import type { ISkiaValueApi } from "./types";
|
25
2
|
declare global {
|
26
3
|
var SkiaValueApi: ISkiaValueApi;
|
27
4
|
}
|
28
5
|
export declare const ValueApi: ISkiaValueApi;
|
29
|
-
export declare const createValue: <T>(initialValue: T) => SkiaValue<T>, createDerivedValue: <R>(cb: () => R, values:
|
6
|
+
export declare const createValue: <T>(initialValue: T) => import("./types").SkiaValue<T>, createDerivedValue: <R>(cb: () => R, values: import("./types").SkiaReadonlyValue<unknown>[]) => import("./types").SkiaReadonlyValue<R>;
|
@@ -0,0 +1,2 @@
|
|
1
|
+
export declare const ValueApi: import("./types").ISkiaValueApi;
|
2
|
+
export declare const createValue: <T>(initialValue: T) => import("./types").SkiaValue<T>, createDerivedValue: <R>(cb: () => R, values: import("./types").SkiaReadonlyValue<unknown>[]) => import("./types").SkiaReadonlyValue<R>;
|
@@ -27,10 +27,33 @@ export interface SkiaClockValue extends SkiaReadonlyValue<number> {
|
|
27
27
|
start: () => void;
|
28
28
|
stop: () => void;
|
29
29
|
}
|
30
|
-
export interface SkiaAnimation {
|
30
|
+
export interface SkiaAnimation extends SkiaClockValue {
|
31
31
|
cancel: () => void;
|
32
32
|
}
|
33
33
|
export interface AnimationState {
|
34
34
|
current: number;
|
35
35
|
finished: boolean;
|
36
36
|
}
|
37
|
+
export interface ISkiaValueApi {
|
38
|
+
/**
|
39
|
+
* Creates a new value that holds the initial value and that
|
40
|
+
* can be changed.
|
41
|
+
*/
|
42
|
+
createValue: <T>(initialValue: T) => SkiaValue<T>;
|
43
|
+
/**
|
44
|
+
* Creates a derived value. This is a calculated value that returns the result of
|
45
|
+
* a function that is called with the values of the dependencies.
|
46
|
+
*/
|
47
|
+
createDerivedValue: <R>(cb: () => R, values: Array<SkiaReadonlyValue<unknown>>) => SkiaReadonlyValue<R>;
|
48
|
+
/**
|
49
|
+
* Creates a clock value where the value is the number of milliseconds elapsed
|
50
|
+
* since the clock was created
|
51
|
+
*/
|
52
|
+
createClockValue: () => SkiaClockValue;
|
53
|
+
/**
|
54
|
+
* Creates an animation that is driven from a clock and updated every frame.
|
55
|
+
* @param cb Callback to calculate next value from time.
|
56
|
+
* @returns An animation object that can control a value.
|
57
|
+
*/
|
58
|
+
createAnimation: <S extends AnimationState = AnimationState>(cb: (t: number, state: S | undefined) => S) => SkiaAnimation;
|
59
|
+
}
|
@@ -0,0 +1,9 @@
|
|
1
|
+
import type { AnimationState, SkiaAnimation } from "../types";
|
2
|
+
import { RNSkClockValue } from "./RNSkClockValue";
|
3
|
+
export declare class RNSkAnimation<S extends AnimationState = AnimationState> extends RNSkClockValue implements SkiaAnimation {
|
4
|
+
constructor(callback: (t: number, state: S | undefined) => S, raf: (callback: (time: number) => void) => number);
|
5
|
+
private _callback;
|
6
|
+
private _animationState;
|
7
|
+
cancel(): void;
|
8
|
+
protected update(nextValue: number): void;
|
9
|
+
}
|
@@ -0,0 +1,13 @@
|
|
1
|
+
import type { SkiaClockValue } from "../types";
|
2
|
+
import { RNSkReadonlyValue } from "./RNSkReadonlyValue";
|
3
|
+
export declare class RNSkClockValue extends RNSkReadonlyValue<number> implements SkiaClockValue {
|
4
|
+
constructor(raf: (callback: (time: number) => void) => number);
|
5
|
+
private _raf;
|
6
|
+
private _start;
|
7
|
+
private _stop;
|
8
|
+
private _state;
|
9
|
+
private notifyUpdate;
|
10
|
+
protected tick(value: number): void;
|
11
|
+
start(): void;
|
12
|
+
stop(): void;
|
13
|
+
}
|
@@ -0,0 +1,9 @@
|
|
1
|
+
import type { DependencyList } from "react";
|
2
|
+
import { RNSkReadonlyValue } from "./RNSkReadonlyValue";
|
3
|
+
export declare class RNSkDerivedValue<T> extends RNSkReadonlyValue<T> {
|
4
|
+
constructor(callback: () => T, dependencies: DependencyList);
|
5
|
+
private dependecyUpdated;
|
6
|
+
private _callback;
|
7
|
+
private _unsubscribers;
|
8
|
+
unsubscribe(): void;
|
9
|
+
}
|
@@ -0,0 +1,11 @@
|
|
1
|
+
import type { SkiaReadonlyValue } from "../types";
|
2
|
+
export declare class RNSkReadonlyValue<T> implements SkiaReadonlyValue<T> {
|
3
|
+
constructor(value: T);
|
4
|
+
private _current;
|
5
|
+
private _listeners;
|
6
|
+
private notifyListeners;
|
7
|
+
protected update(nextValue: T): void;
|
8
|
+
readonly __typename__ = "RNSkValue";
|
9
|
+
get current(): T;
|
10
|
+
addListener(cb: (value: T) => void): () => void;
|
11
|
+
}
|
@@ -0,0 +1,14 @@
|
|
1
|
+
import type { SkiaAnimation, SkiaValue } from "../types";
|
2
|
+
import { RNSkReadonlyValue } from "./RNSkReadonlyValue";
|
3
|
+
export declare class RNSkValue<T> extends RNSkReadonlyValue<T> implements SkiaValue<T> {
|
4
|
+
constructor(value: T);
|
5
|
+
set current(value: T);
|
6
|
+
get current(): T;
|
7
|
+
private _unsubscribe;
|
8
|
+
private unsubscribe;
|
9
|
+
private subscribe;
|
10
|
+
private animationDidUpdate;
|
11
|
+
private _animation;
|
12
|
+
get animation(): SkiaAnimation | undefined;
|
13
|
+
set animation(v: SkiaAnimation | undefined);
|
14
|
+
}
|
@@ -0,0 +1 @@
|
|
1
|
+
export * from "./api";
|
@@ -1,40 +1,7 @@
|
|
1
1
|
import React from "react";
|
2
|
-
import type {
|
3
|
-
import type { SkImage, SkRect } from "../skia";
|
2
|
+
import type { SkRect } from "../skia";
|
4
3
|
import type { SkiaReadonlyValue } from "../values";
|
5
|
-
import type { DrawMode,
|
6
|
-
declare global {
|
7
|
-
var SkiaViewApi: {
|
8
|
-
invalidateSkiaView: (nativeId: number) => void;
|
9
|
-
makeImageSnapshot: (nativeId: number, rect?: SkRect) => SkImage;
|
10
|
-
setDrawCallback: (nativeId: number, callback: RNSkiaDrawCallback | undefined) => void;
|
11
|
-
setDrawMode: (nativeId: number, mode: DrawMode) => void;
|
12
|
-
registerValuesInView: (nativeId: number, values: SkiaReadonlyValue<unknown>[]) => () => void;
|
13
|
-
};
|
14
|
-
}
|
15
|
-
export interface SkiaViewProps extends ViewProps {
|
16
|
-
/**
|
17
|
-
* Sets the drawing mode for the skia view. There are two drawing
|
18
|
-
* modes, "continuous" and "default", where the continuous mode will
|
19
|
-
* continuously redraw the view, and the default mode will only
|
20
|
-
* redraw when any of the regular react properties are changed like
|
21
|
-
* sizes and margins.
|
22
|
-
*/
|
23
|
-
mode?: DrawMode;
|
24
|
-
/**
|
25
|
-
* When set to true the view will display information about the
|
26
|
-
* average time it takes to render.
|
27
|
-
*/
|
28
|
-
debug?: boolean;
|
29
|
-
/**
|
30
|
-
* Draw callback. Will be called whenever the view is invalidated and
|
31
|
-
* needs to redraw. This is either caused by a change in a react
|
32
|
-
* property, a touch event, or a call to redraw. If the view is in
|
33
|
-
* continuous mode the callback will be called 60 frames per second
|
34
|
-
* by the native view.
|
35
|
-
*/
|
36
|
-
onDraw?: RNSkiaDrawCallback;
|
37
|
-
}
|
4
|
+
import type { DrawMode, SkiaViewProps } from "./types";
|
38
5
|
export declare class SkiaView extends React.Component<SkiaViewProps> {
|
39
6
|
constructor(props: SkiaViewProps);
|
40
7
|
private _nativeId;
|
@@ -45,7 +12,7 @@ export declare class SkiaView extends React.Component<SkiaViewProps> {
|
|
45
12
|
* @param rect Rect to use as bounds. Optional.
|
46
13
|
* @returns An Image object.
|
47
14
|
*/
|
48
|
-
makeImageSnapshot(rect?: SkRect): SkImage;
|
15
|
+
makeImageSnapshot(rect?: SkRect): import("../skia").SkImage;
|
49
16
|
/**
|
50
17
|
* Sends a redraw request to the native SkiaView.
|
51
18
|
*/
|
@@ -1,5 +1,7 @@
|
|
1
1
|
import type { ViewProps } from "react-native";
|
2
|
+
import type { SkImage, SkRect } from "../skia";
|
2
3
|
import type { SkCanvas } from "../skia/Canvas";
|
4
|
+
import type { SkiaReadonlyValue } from "../values";
|
3
5
|
export declare type DrawMode = "continuous" | "default";
|
4
6
|
export declare type NativeSkiaViewProps = ViewProps & {
|
5
7
|
mode?: DrawMode;
|
@@ -42,3 +44,33 @@ export interface ValueListener {
|
|
42
44
|
addListener: (callback: () => void) => number;
|
43
45
|
removeListener: (id: number) => void;
|
44
46
|
}
|
47
|
+
export interface ISkiaViewApi {
|
48
|
+
invalidateSkiaView: (nativeId: number) => void;
|
49
|
+
makeImageSnapshot: (nativeId: number, rect?: SkRect) => SkImage;
|
50
|
+
setDrawCallback: (nativeId: number, callback: RNSkiaDrawCallback | undefined) => void;
|
51
|
+
setDrawMode: (nativeId: number, mode: DrawMode) => void;
|
52
|
+
registerValuesInView: (nativeId: number, values: SkiaReadonlyValue<unknown>[]) => () => void;
|
53
|
+
}
|
54
|
+
export interface SkiaViewProps extends ViewProps {
|
55
|
+
/**
|
56
|
+
* Sets the drawing mode for the skia view. There are two drawing
|
57
|
+
* modes, "continuous" and "default", where the continuous mode will
|
58
|
+
* continuously redraw the view, and the default mode will only
|
59
|
+
* redraw when any of the regular react properties are changed like
|
60
|
+
* sizes and margins.
|
61
|
+
*/
|
62
|
+
mode?: DrawMode;
|
63
|
+
/**
|
64
|
+
* When set to true the view will display information about the
|
65
|
+
* average time it takes to render.
|
66
|
+
*/
|
67
|
+
debug?: boolean;
|
68
|
+
/**
|
69
|
+
* Draw callback. Will be called whenever the view is invalidated and
|
70
|
+
* needs to redraw. This is either caused by a change in a react
|
71
|
+
* property, a touch event, or a call to redraw. If the view is in
|
72
|
+
* continuous mode the callback will be called 60 frames per second
|
73
|
+
* by the native view.
|
74
|
+
*/
|
75
|
+
onDraw?: RNSkiaDrawCallback;
|
76
|
+
}
|
package/package.json
CHANGED
@@ -4,7 +4,7 @@
|
|
4
4
|
"access": "public"
|
5
5
|
},
|
6
6
|
"title": "React Native Skia",
|
7
|
-
"version": "0.1.
|
7
|
+
"version": "0.1.125",
|
8
8
|
"description": "High-performance React Native Graphics using Skia",
|
9
9
|
"main": "lib/module/index.js",
|
10
10
|
"files": [
|
@@ -76,7 +76,7 @@
|
|
76
76
|
"react-native": "0.66.2",
|
77
77
|
"react-native-builder-bob": "^0.18.2",
|
78
78
|
"ts-jest": "^27.0.7",
|
79
|
-
"typescript": "^4.6.
|
79
|
+
"typescript": "^4.6.4"
|
80
80
|
},
|
81
81
|
"dependencies": {
|
82
82
|
"react-reconciler": "^0.26.2"
|
File without changes
|
File without changes
|
@@ -1,5 +1,5 @@
|
|
1
|
-
import { ValueApi } from "../../api";
|
2
|
-
import type { SkiaValue } from "../../types";
|
1
|
+
import { ValueApi } from "../../values/api";
|
2
|
+
import type { SkiaValue } from "../../values/types";
|
3
3
|
|
4
4
|
import { decay } from "./decay";
|
5
5
|
import type { DecayConfig, DefaultDecayConfig, DecayState } from "./types";
|
File without changes
|
@@ -0,0 +1,182 @@
|
|
1
|
+
/* eslint-disable max-len */
|
2
|
+
export enum Extrapolate {
|
3
|
+
IDENTITY = "identity",
|
4
|
+
CLAMP = "clamp",
|
5
|
+
EXTEND = "extend",
|
6
|
+
}
|
7
|
+
|
8
|
+
interface InterpolationNarrowedInput {
|
9
|
+
leftEdgeInput: number;
|
10
|
+
rightEdgeInput: number;
|
11
|
+
leftEdgeOutput: number;
|
12
|
+
rightEdgeOutput: number;
|
13
|
+
}
|
14
|
+
|
15
|
+
export interface ExtrapolationConfig {
|
16
|
+
extrapolateLeft?: Extrapolate | string;
|
17
|
+
extrapolateRight?: Extrapolate | string;
|
18
|
+
}
|
19
|
+
|
20
|
+
interface RequiredExtrapolationConfig {
|
21
|
+
extrapolateLeft: Extrapolate;
|
22
|
+
extrapolateRight: Extrapolate;
|
23
|
+
}
|
24
|
+
|
25
|
+
export type ExtrapolationType =
|
26
|
+
| ExtrapolationConfig
|
27
|
+
| Extrapolate
|
28
|
+
| string
|
29
|
+
| undefined;
|
30
|
+
|
31
|
+
function getVal(
|
32
|
+
type: Extrapolate,
|
33
|
+
coef: number,
|
34
|
+
val: number,
|
35
|
+
leftEdgeOutput: number,
|
36
|
+
rightEdgeOutput: number,
|
37
|
+
x: number
|
38
|
+
): number {
|
39
|
+
switch (type) {
|
40
|
+
case Extrapolate.IDENTITY:
|
41
|
+
return x;
|
42
|
+
case Extrapolate.CLAMP:
|
43
|
+
if (coef * val < coef * leftEdgeOutput) {
|
44
|
+
return leftEdgeOutput;
|
45
|
+
}
|
46
|
+
return rightEdgeOutput;
|
47
|
+
case Extrapolate.EXTEND:
|
48
|
+
default:
|
49
|
+
return val;
|
50
|
+
}
|
51
|
+
}
|
52
|
+
|
53
|
+
function isExtrapolate(value: string): value is Extrapolate {
|
54
|
+
return (
|
55
|
+
value === Extrapolate.EXTEND ||
|
56
|
+
value === Extrapolate.CLAMP ||
|
57
|
+
value === Extrapolate.IDENTITY
|
58
|
+
);
|
59
|
+
}
|
60
|
+
|
61
|
+
// validates extrapolations type
|
62
|
+
// if type is correct, converts it to ExtrapolationConfig
|
63
|
+
function validateType(type: ExtrapolationType): RequiredExtrapolationConfig {
|
64
|
+
// initialize extrapolationConfig with default extrapolation
|
65
|
+
const extrapolationConfig: RequiredExtrapolationConfig = {
|
66
|
+
extrapolateLeft: Extrapolate.EXTEND,
|
67
|
+
extrapolateRight: Extrapolate.EXTEND,
|
68
|
+
};
|
69
|
+
|
70
|
+
if (!type) {
|
71
|
+
return extrapolationConfig;
|
72
|
+
}
|
73
|
+
|
74
|
+
if (typeof type === "string") {
|
75
|
+
if (!isExtrapolate(type)) {
|
76
|
+
throw new Error(
|
77
|
+
`No supported value for "interpolate" \nSupported values: ["extend", "clamp", "identity", Extrapolatation.CLAMP, Extrapolatation.EXTEND, Extrapolatation.IDENTITY]\n Valid example:
|
78
|
+
interpolate(value, [inputRange], [outputRange], "clamp")`
|
79
|
+
);
|
80
|
+
}
|
81
|
+
extrapolationConfig.extrapolateLeft = type;
|
82
|
+
extrapolationConfig.extrapolateRight = type;
|
83
|
+
return extrapolationConfig;
|
84
|
+
}
|
85
|
+
|
86
|
+
// otherwise type is extrapolation config object
|
87
|
+
if (
|
88
|
+
(type.extrapolateLeft && !isExtrapolate(type.extrapolateLeft)) ||
|
89
|
+
(type.extrapolateRight && !isExtrapolate(type.extrapolateRight))
|
90
|
+
) {
|
91
|
+
throw new Error(
|
92
|
+
`No supported value for "interpolate" \nSupported values: ["extend", "clamp", "identity", Extrapolatation.CLAMP, Extrapolatation.EXTEND, Extrapolatation.IDENTITY]\n Valid example:
|
93
|
+
interpolate(value, [inputRange], [outputRange], {
|
94
|
+
extrapolateLeft: Extrapolation.CLAMP,
|
95
|
+
extrapolateRight: Extrapolation.IDENTITY
|
96
|
+
}})`
|
97
|
+
);
|
98
|
+
}
|
99
|
+
|
100
|
+
Object.assign(extrapolationConfig, type);
|
101
|
+
return extrapolationConfig;
|
102
|
+
}
|
103
|
+
|
104
|
+
function internalInterpolate(
|
105
|
+
x: number,
|
106
|
+
narrowedInput: InterpolationNarrowedInput,
|
107
|
+
extrapolationConfig: RequiredExtrapolationConfig
|
108
|
+
) {
|
109
|
+
const { leftEdgeInput, rightEdgeInput, leftEdgeOutput, rightEdgeOutput } =
|
110
|
+
narrowedInput;
|
111
|
+
if (rightEdgeInput - leftEdgeInput === 0) {
|
112
|
+
return leftEdgeOutput;
|
113
|
+
}
|
114
|
+
const progress = (x - leftEdgeInput) / (rightEdgeInput - leftEdgeInput);
|
115
|
+
const val = leftEdgeOutput + progress * (rightEdgeOutput - leftEdgeOutput);
|
116
|
+
const coef = rightEdgeOutput >= leftEdgeOutput ? 1 : -1;
|
117
|
+
|
118
|
+
if (coef * val < coef * leftEdgeOutput) {
|
119
|
+
return getVal(
|
120
|
+
extrapolationConfig.extrapolateLeft,
|
121
|
+
coef,
|
122
|
+
val,
|
123
|
+
leftEdgeOutput,
|
124
|
+
rightEdgeOutput,
|
125
|
+
x
|
126
|
+
);
|
127
|
+
} else if (coef * val > coef * rightEdgeOutput) {
|
128
|
+
return getVal(
|
129
|
+
extrapolationConfig.extrapolateRight,
|
130
|
+
coef,
|
131
|
+
val,
|
132
|
+
leftEdgeOutput,
|
133
|
+
rightEdgeOutput,
|
134
|
+
x
|
135
|
+
);
|
136
|
+
}
|
137
|
+
|
138
|
+
return val;
|
139
|
+
}
|
140
|
+
|
141
|
+
// e.g. function interpolate(x, input, output, type = Extrapolatation.CLAMP)
|
142
|
+
export function interpolate(
|
143
|
+
x: number,
|
144
|
+
input: readonly number[],
|
145
|
+
output: readonly number[],
|
146
|
+
type?: ExtrapolationType
|
147
|
+
): number {
|
148
|
+
if (input.length < 2 || output.length < 2) {
|
149
|
+
throw Error(
|
150
|
+
"Interpolation input and output should contain at least two values."
|
151
|
+
);
|
152
|
+
}
|
153
|
+
|
154
|
+
const extrapolationConfig = validateType(type);
|
155
|
+
const { length } = input;
|
156
|
+
const narrowedInput: InterpolationNarrowedInput = {
|
157
|
+
leftEdgeInput: input[0],
|
158
|
+
rightEdgeInput: input[1],
|
159
|
+
leftEdgeOutput: output[0],
|
160
|
+
rightEdgeOutput: output[1],
|
161
|
+
};
|
162
|
+
if (length > 2) {
|
163
|
+
if (x > input[length - 1]) {
|
164
|
+
narrowedInput.leftEdgeInput = input[length - 2];
|
165
|
+
narrowedInput.rightEdgeInput = input[length - 1];
|
166
|
+
narrowedInput.leftEdgeOutput = output[length - 2];
|
167
|
+
narrowedInput.rightEdgeOutput = output[length - 1];
|
168
|
+
} else {
|
169
|
+
for (let i = 1; i < length; ++i) {
|
170
|
+
if (x <= input[i]) {
|
171
|
+
narrowedInput.leftEdgeInput = input[i - 1];
|
172
|
+
narrowedInput.rightEdgeInput = input[i];
|
173
|
+
narrowedInput.leftEdgeOutput = output[i - 1];
|
174
|
+
narrowedInput.rightEdgeOutput = output[i];
|
175
|
+
break;
|
176
|
+
}
|
177
|
+
}
|
178
|
+
}
|
179
|
+
}
|
180
|
+
|
181
|
+
return internalInterpolate(x, narrowedInput, extrapolationConfig);
|
182
|
+
}
|
@@ -0,0 +1,58 @@
|
|
1
|
+
import { mix } from "../../renderer";
|
2
|
+
import type { Color } from "../../skia";
|
3
|
+
import { Skia } from "../../skia";
|
4
|
+
import type { SkColor } from "../../skia/Color";
|
5
|
+
|
6
|
+
import { interpolate } from "./interpolate";
|
7
|
+
|
8
|
+
const interpolateColorsRGB = (
|
9
|
+
value: number,
|
10
|
+
inputRange: number[],
|
11
|
+
outputRange: SkColor[]
|
12
|
+
) => {
|
13
|
+
const r = interpolate(
|
14
|
+
value,
|
15
|
+
inputRange,
|
16
|
+
outputRange.map((c) => c[0]),
|
17
|
+
"clamp"
|
18
|
+
);
|
19
|
+
const g = interpolate(
|
20
|
+
value,
|
21
|
+
inputRange,
|
22
|
+
outputRange.map((c) => c[1]),
|
23
|
+
"clamp"
|
24
|
+
);
|
25
|
+
const b = interpolate(
|
26
|
+
value,
|
27
|
+
inputRange,
|
28
|
+
outputRange.map((c) => c[2]),
|
29
|
+
"clamp"
|
30
|
+
);
|
31
|
+
const a = interpolate(
|
32
|
+
value,
|
33
|
+
inputRange,
|
34
|
+
outputRange.map((c) => c[3]),
|
35
|
+
"clamp"
|
36
|
+
);
|
37
|
+
return new Float32Array([r, g, b, a]);
|
38
|
+
};
|
39
|
+
|
40
|
+
export const interpolateColors = (
|
41
|
+
value: number,
|
42
|
+
inputRange: number[],
|
43
|
+
_outputRange: Color[]
|
44
|
+
) => {
|
45
|
+
const outputRange = _outputRange.map((cl) => Skia.Color(cl));
|
46
|
+
return interpolateColorsRGB(value, inputRange, outputRange);
|
47
|
+
};
|
48
|
+
|
49
|
+
export const mixColors = (value: number, x: Color, y: Color) => {
|
50
|
+
const c1 = Skia.Color(x);
|
51
|
+
const c2 = Skia.Color(y);
|
52
|
+
return new Float32Array([
|
53
|
+
mix(value, c1[0], c2[0]),
|
54
|
+
mix(value, c1[1], c2[1]),
|
55
|
+
mix(value, c1[2], c2[2]),
|
56
|
+
mix(value, c1[3], c2[3]),
|
57
|
+
]);
|
58
|
+
};
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|