@shopify/react-native-skia 0.1.122 → 0.1.125
Sign up to get free protection for your applications and to get access to all the features.
- package/android/CMakeLists.txt +6 -1
- package/android/build.gradle +1 -1
- package/android/cpp/jni/JniSkiaDrawView.cpp +14 -71
- package/android/cpp/jni/JniSkiaManager.cpp +1 -1
- package/android/cpp/jni/include/JniSkiaDrawView.h +18 -22
- package/android/cpp/jni/include/JniSkiaManager.h +4 -4
- package/android/cpp/rnskia-android/RNSkDrawViewImpl.cpp +68 -0
- package/android/cpp/rnskia-android/RNSkDrawViewImpl.h +48 -0
- package/android/cpp/{jni/include/JniPlatformContextWrapper.h → rnskia-android/RNSkPlatformContextImpl.h} +4 -4
- package/android/cpp/{jni → rnskia-android}/SkiaOpenGLRenderer.cpp +39 -54
- package/android/cpp/{jni/include → rnskia-android}/SkiaOpenGLRenderer.h +2 -31
- package/android/src/main/java/com/shopify/reactnative/skia/RNSkiaViewManager.java +1 -1
- package/android/src/main/java/com/shopify/reactnative/skia/SkiaDrawView.java +21 -28
- 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/RNSkAnimation.h +0 -2
- package/cpp/rnskia/RNSkDrawView.cpp +84 -126
- package/cpp/rnskia/RNSkDrawView.h +7 -37
- package/cpp/rnskia/RNSkJsiViewApi.h +8 -5
- package/cpp/rnskia/RNSkManager.cpp +2 -2
- package/cpp/rnskia/RNSkManager.h +2 -2
- package/cpp/rnskia/RNSkPlatformContext.h +1 -1
- package/cpp/rnskia/RNSkValueApi.h +6 -2
- package/cpp/rnskia/values/RNSkClockValue.h +18 -10
- package/cpp/rnskia/values/RNSkDerivedValue.h +12 -5
- package/cpp/rnskia/values/RNSkReadonlyValue.h +25 -17
- package/cpp/rnskia/values/RNSkValue.h +8 -3
- package/cpp/utils/RNSkTimingInfo.h +13 -1
- package/ios/RNSkia-iOS/PlatformContext.h +30 -4
- package/ios/RNSkia-iOS/RNSkDrawViewImpl.h +8 -10
- package/ios/RNSkia-iOS/RNSkDrawViewImpl.mm +25 -10
- package/ios/RNSkia-iOS/SkiaDrawView.mm +22 -20
- 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 +3 -3
- package/lib/commonjs/animation/timing/functions/getResolvedParams.js.map +1 -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/Canvas.js +17 -8
- package/lib/commonjs/renderer/Canvas.js.map +1 -1
- package/lib/commonjs/renderer/components/Paint.js +1 -1
- package/lib/commonjs/renderer/components/Paint.js.map +1 -1
- package/lib/commonjs/renderer/components/colorFilters/BlendColor.js.map +1 -1
- package/lib/commonjs/renderer/components/colorFilters/Lerp.js +1 -1
- package/lib/commonjs/renderer/components/colorFilters/Lerp.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 +2 -2
- package/lib/commonjs/renderer/components/shaders/Shader.js.map +1 -1
- package/lib/commonjs/renderer/components/shapes/Path.js +9 -1
- package/lib/commonjs/renderer/components/shapes/Path.js.map +1 -1
- package/lib/commonjs/renderer/processors/Circles.js +3 -2
- package/lib/commonjs/renderer/processors/Circles.js.map +1 -1
- package/lib/commonjs/renderer/processors/Font.js +1 -1
- package/lib/commonjs/renderer/processors/Font.js.map +1 -1
- package/lib/commonjs/renderer/processors/Paint.js +6 -1
- package/lib/commonjs/renderer/processors/Paint.js.map +1 -1
- package/lib/commonjs/renderer/processors/Rects.js +11 -21
- 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/Paint/Paint.js +13 -1
- package/lib/commonjs/skia/Paint/Paint.js.map +1 -1
- package/lib/commonjs/skia/Paint/usePaint.js +2 -4
- package/lib/commonjs/skia/Paint/usePaint.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 -43
- 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 +3 -3
- package/lib/module/animation/timing/functions/getResolvedParams.js.map +1 -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/Canvas.js +12 -6
- package/lib/module/renderer/Canvas.js.map +1 -1
- package/lib/module/renderer/components/Paint.js +2 -2
- package/lib/module/renderer/components/Paint.js.map +1 -1
- package/lib/module/renderer/components/colorFilters/BlendColor.js.map +1 -1
- package/lib/module/renderer/components/colorFilters/Lerp.js +1 -1
- package/lib/module/renderer/components/colorFilters/Lerp.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 +3 -2
- package/lib/module/renderer/components/shaders/Shader.js.map +1 -1
- package/lib/module/renderer/components/shapes/Path.js +9 -2
- package/lib/module/renderer/components/shapes/Path.js.map +1 -1
- package/lib/module/renderer/processors/Circles.js +3 -2
- package/lib/module/renderer/processors/Circles.js.map +1 -1
- package/lib/module/renderer/processors/Font.js +1 -1
- package/lib/module/renderer/processors/Font.js.map +1 -1
- package/lib/module/renderer/processors/Paint.js +6 -1
- package/lib/module/renderer/processors/Paint.js.map +1 -1
- package/lib/module/renderer/processors/Rects.js +9 -21
- 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/Paint/Paint.js +6 -0
- package/lib/module/skia/Paint/Paint.js.map +1 -1
- package/lib/module/skia/Paint/usePaint.js +2 -3
- package/lib/module/skia/Paint/usePaint.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 -44
- 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 +5 -5
- package/lib/typescript/src/index.d.ts +1 -0
- package/lib/typescript/src/renderer/Canvas.d.ts +6 -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/components/shapes/Path.d.ts +3 -1
- package/lib/typescript/src/renderer/processors/Paint.d.ts +2 -1
- 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/Paint/Paint.d.ts +1 -0
- 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 +2 -2
- 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 +5 -5
- package/src/index.ts +1 -0
- package/src/renderer/Canvas.tsx +13 -6
- package/src/renderer/components/Paint.tsx +2 -2
- package/src/renderer/components/colorFilters/BlendColor.tsx +1 -1
- package/src/renderer/components/colorFilters/Lerp.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 +3 -3
- package/src/renderer/components/shapes/Path.tsx +11 -3
- package/src/renderer/processors/Circles.ts +2 -1
- package/src/renderer/processors/Font.ts +1 -1
- package/src/renderer/processors/Paint.ts +5 -0
- package/src/renderer/processors/Rects.ts +9 -14
- 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/Paint/Paint.ts +7 -0
- package/src/skia/Paint/usePaint.ts +2 -4
- 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 -123
- 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/functions/getResolvedParams.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/functions/getResolvedParams.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
@@ -11,6 +11,7 @@
|
|
11
11
|
|
12
12
|
#include <JsiSkHostObjects.h>
|
13
13
|
#include <RNSkPlatformContext.h>
|
14
|
+
#include <JsiSimpleValueWrapper.h>
|
14
15
|
|
15
16
|
namespace RNSkia
|
16
17
|
{
|
@@ -26,7 +27,8 @@ class RNSkReadonlyValue : public JsiSkHostObject,
|
|
26
27
|
public:
|
27
28
|
RNSkReadonlyValue(std::shared_ptr<RNSkPlatformContext> platformContext)
|
28
29
|
: JsiSkHostObject(platformContext),
|
29
|
-
|
30
|
+
_valueHolder(std::make_unique<JsiSimpleValueWrapper>(*platformContext->getJsRuntime()))
|
31
|
+
{ }
|
30
32
|
|
31
33
|
virtual ~RNSkReadonlyValue() { }
|
32
34
|
|
@@ -48,10 +50,13 @@ public:
|
|
48
50
|
}
|
49
51
|
auto callback = std::make_shared<jsi::Function>(arguments[0].asObject(runtime).asFunction(runtime));
|
50
52
|
|
51
|
-
auto unsubscribe = addListener([
|
52
|
-
this,
|
53
|
+
auto unsubscribe = addListener([weakSelf = weak_from_this(),
|
53
54
|
callback = std::move(callback)](jsi::Runtime& runtime){
|
54
|
-
|
55
|
+
auto self = weakSelf.lock();
|
56
|
+
if(self) {
|
57
|
+
auto selfReadonlyValue = std::dynamic_pointer_cast<RNSkReadonlyValue>(self);
|
58
|
+
callback->call(runtime, selfReadonlyValue->get_current(runtime));
|
59
|
+
}
|
55
60
|
});
|
56
61
|
|
57
62
|
return jsi::Function::createFromHostFunction(runtime,
|
@@ -74,32 +79,35 @@ public:
|
|
74
79
|
std::lock_guard<std::mutex> lock(_mutex);
|
75
80
|
auto listenerId = _listenerId++;
|
76
81
|
_listeners.emplace(listenerId, cb);
|
77
|
-
return [
|
78
|
-
|
82
|
+
return [weakSelf = weak_from_this(), listenerId]() {
|
83
|
+
auto self = weakSelf.lock();
|
84
|
+
if(self) {
|
85
|
+
self->removeListener(listenerId);
|
86
|
+
}
|
79
87
|
};
|
80
88
|
}
|
81
89
|
|
82
90
|
/**
|
83
|
-
Updates the underlying value and notifies all listeners about the change
|
91
|
+
Updates the underlying value and notifies all listeners about the change.
|
92
|
+
Listeners are only notified if the value was actually changed for numeric, boolean and string
|
93
|
+
values. For all other values listeners are notified without comparison.
|
84
94
|
@param runtime Current JS Runtime
|
85
95
|
@param value Next value
|
86
96
|
*/
|
87
97
|
virtual void update(jsi::Runtime &runtime, const jsi::Value &value) {
|
88
|
-
|
89
|
-
|
98
|
+
auto equal = _valueHolder->equals(runtime, value);
|
99
|
+
_valueHolder->setCurrent(runtime, value);
|
100
|
+
if(!equal) {
|
101
|
+
notifyListeners(runtime);
|
90
102
|
}
|
91
|
-
_valueHolder->setProperty(runtime, _propNameId, value);
|
92
|
-
notifyListeners(runtime);
|
93
103
|
}
|
94
104
|
|
95
105
|
jsi::Value getCurrent(jsi::Runtime &runtime) {
|
96
|
-
|
97
|
-
return jsi::Value::undefined();
|
98
|
-
}
|
99
|
-
return _valueHolder->getProperty(runtime, _propNameId);
|
106
|
+
return _valueHolder->getCurrent(runtime);
|
100
107
|
}
|
101
108
|
|
102
109
|
protected:
|
110
|
+
|
103
111
|
/**
|
104
112
|
Notifies listeners about changes
|
105
113
|
@param runtime Current JS Runtime
|
@@ -125,8 +133,8 @@ protected:
|
|
125
133
|
}
|
126
134
|
|
127
135
|
private:
|
128
|
-
|
129
|
-
|
136
|
+
std::unique_ptr<JsiSimpleValueWrapper> _valueHolder;
|
137
|
+
|
130
138
|
long _listenerId = 0;
|
131
139
|
std::unordered_map<long, std::function<void(jsi::Runtime&)>> _listeners;
|
132
140
|
std::mutex _mutex;
|
@@ -76,11 +76,16 @@ public:
|
|
76
76
|
|
77
77
|
private:
|
78
78
|
void subscribe(std::shared_ptr<RNSkAnimation> animation) {
|
79
|
-
unsubscribe();
|
80
79
|
if(animation != nullptr) {
|
81
80
|
_animation = animation;
|
82
|
-
|
83
|
-
|
81
|
+
_unsubscribe = std::make_shared<std::function<void()>>(
|
82
|
+
_animation->addListener([weakSelf = weak_from_this()](jsi::Runtime &runtime) {
|
83
|
+
auto self = weakSelf.lock();
|
84
|
+
if(self) {
|
85
|
+
auto selfAsThis = std::dynamic_pointer_cast<RNSkValue>(self);
|
86
|
+
selfAsThis->animationDidUpdate(runtime);
|
87
|
+
}
|
88
|
+
}));
|
84
89
|
// Start the animation
|
85
90
|
_animation->startClock();
|
86
91
|
}
|
@@ -1,5 +1,6 @@
|
|
1
1
|
#pragma once
|
2
2
|
|
3
|
+
#include <RNSkLog.h>
|
3
4
|
#include <chrono>
|
4
5
|
|
5
6
|
#define NUMBER_OF_DURATION_SAMPLES 10
|
@@ -12,7 +13,7 @@ using ms = duration<float, std::milli>;
|
|
12
13
|
|
13
14
|
class RNSkTimingInfo {
|
14
15
|
public:
|
15
|
-
RNSkTimingInfo() {
|
16
|
+
RNSkTimingInfo(const std::string &name): _name(std::move(name)) {
|
16
17
|
reset();
|
17
18
|
}
|
18
19
|
|
@@ -25,6 +26,7 @@ public:
|
|
25
26
|
_prevFpsTimer = -1;
|
26
27
|
_frameCount = 0;
|
27
28
|
_lastFrameCount = -1;
|
29
|
+
_didSkip = false;
|
28
30
|
}
|
29
31
|
|
30
32
|
void beginTiming() {
|
@@ -35,6 +37,14 @@ public:
|
|
35
37
|
time_point<steady_clock> stop = high_resolution_clock::now();
|
36
38
|
addLastDuration(duration_cast<milliseconds>(stop - _start).count());
|
37
39
|
tick(stop);
|
40
|
+
if(_didSkip) {
|
41
|
+
_didSkip = false;
|
42
|
+
RNSkLogger::logToConsole("%s: Skipped frame. Previous frame time: %lldms", _name.c_str(), _lastDuration);
|
43
|
+
}
|
44
|
+
}
|
45
|
+
|
46
|
+
void markSkipped() {
|
47
|
+
_didSkip = true;
|
38
48
|
}
|
39
49
|
|
40
50
|
long getAverage() { return static_cast<long>(_average); }
|
@@ -86,6 +96,8 @@ private:
|
|
86
96
|
long _prevFpsTimer;
|
87
97
|
double _frameCount;
|
88
98
|
double _lastFrameCount;
|
99
|
+
double _didSkip;
|
100
|
+
std::string _name;
|
89
101
|
};
|
90
102
|
|
91
103
|
} // namespace RNSkia
|
@@ -1,5 +1,7 @@
|
|
1
1
|
#pragma once
|
2
2
|
|
3
|
+
#import "RCTBridge.h"
|
4
|
+
|
3
5
|
#include <functional>
|
4
6
|
#include <memory>
|
5
7
|
#include <string>
|
@@ -26,13 +28,27 @@ namespace RNSkia {
|
|
26
28
|
|
27
29
|
using namespace facebook;
|
28
30
|
|
31
|
+
static void handleNotification(CFNotificationCenterRef center, void *observer, CFStringRef name, const void *object, CFDictionaryRef userInfo);
|
32
|
+
|
29
33
|
class PlatformContext : public RNSkPlatformContext {
|
30
34
|
public:
|
31
35
|
PlatformContext(jsi::Runtime *runtime,
|
32
36
|
std::shared_ptr<react::CallInvoker> callInvoker)
|
33
|
-
: RNSkPlatformContext(runtime, callInvoker, [[UIScreen mainScreen] scale]) {
|
34
|
-
|
35
|
-
|
37
|
+
: RNSkPlatformContext(runtime, callInvoker, [[UIScreen mainScreen] scale]) {
|
38
|
+
// We need to make sure we invalidate when modules are freed
|
39
|
+
CFNotificationCenterAddObserver(
|
40
|
+
CFNotificationCenterGetLocalCenter(),
|
41
|
+
this,
|
42
|
+
&handleNotification,
|
43
|
+
(__bridge CFStringRef)RCTBridgeWillInvalidateModulesNotification,
|
44
|
+
NULL,
|
45
|
+
CFNotificationSuspensionBehaviorDeliverImmediately
|
46
|
+
);
|
47
|
+
}
|
48
|
+
|
49
|
+
~PlatformContext() {
|
50
|
+
CFNotificationCenterRemoveEveryObserver(CFNotificationCenterGetLocalCenter(), this);
|
51
|
+
}
|
36
52
|
|
37
53
|
void startDrawLoop() override;
|
38
54
|
void stopDrawLoop() override;
|
@@ -42,9 +58,19 @@ public:
|
|
42
58
|
const std::function<void(std::unique_ptr<SkStreamAsset>)> &op) override;
|
43
59
|
|
44
60
|
void raiseError(const std::exception &err) override;
|
45
|
-
|
61
|
+
|
62
|
+
void willInvalidateModules() {
|
63
|
+
// We need to do some house-cleaning here!
|
64
|
+
invalidate();
|
65
|
+
}
|
66
|
+
|
46
67
|
private:
|
47
68
|
DisplayLink *_displayLink;
|
48
69
|
};
|
49
70
|
|
71
|
+
static void handleNotification(CFNotificationCenterRef center, void *observer, CFStringRef name,
|
72
|
+
const void *object, CFDictionaryRef userInfo) {
|
73
|
+
(static_cast<PlatformContext*>(observer))->willInvalidateModules();
|
74
|
+
}
|
75
|
+
|
50
76
|
} // namespace RNSkia
|
@@ -21,25 +21,23 @@
|
|
21
21
|
class RNSkDrawViewImpl : public RNSkia::RNSkDrawView {
|
22
22
|
public:
|
23
23
|
RNSkDrawViewImpl(std::shared_ptr<RNSkia::RNSkPlatformContext> context);
|
24
|
+
~RNSkDrawViewImpl();
|
24
25
|
|
25
|
-
|
26
|
+
CALayer* getLayer() { return _layer; }
|
26
27
|
|
27
|
-
|
28
|
+
void setSize(int width, int height);
|
28
29
|
|
29
30
|
protected:
|
30
|
-
|
31
|
-
|
32
|
-
void onInvalidated() override {
|
33
|
-
setNativeDrawFunc(nullptr);
|
34
|
-
};
|
31
|
+
float getScaledWidth() override { return _width * _context->getPixelDensity(); };
|
32
|
+
float getScaledHeight() override { return _height * _context->getPixelDensity(); };
|
35
33
|
|
36
34
|
private:
|
37
|
-
void
|
35
|
+
void drawPicture(const sk_sp<SkPicture> picture) override;
|
38
36
|
bool createSkiaSurface();
|
39
37
|
|
40
38
|
int _nativeId;
|
41
|
-
|
42
|
-
|
39
|
+
float _width = -1;
|
40
|
+
float _height = -1;
|
43
41
|
|
44
42
|
#pragma clang diagnostic push
|
45
43
|
#pragma clang diagnostic ignored "-Wunguarded-availability-new"
|
@@ -19,19 +19,34 @@ sk_sp<GrDirectContext> RNSkDrawViewImpl::_skContext = nullptr;
|
|
19
19
|
|
20
20
|
RNSkDrawViewImpl::RNSkDrawViewImpl(std::shared_ptr<RNSkia::RNSkPlatformContext> context):
|
21
21
|
_context(context), RNSkia::RNSkDrawView(context) {
|
22
|
-
|
23
22
|
#pragma clang diagnostic push
|
24
23
|
#pragma clang diagnostic ignored "-Wunguarded-availability-new"
|
25
|
-
|
24
|
+
_layer = [CAMetalLayer layer];
|
26
25
|
#pragma clang diagnostic pop
|
27
26
|
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
27
|
+
_layer.framebufferOnly = NO;
|
28
|
+
_layer.device = _device;
|
29
|
+
_layer.opaque = false;
|
30
|
+
_layer.contentsScale = _context->getPixelDensity();
|
31
|
+
_layer.pixelFormat = MTLPixelFormatBGRA8Unorm;
|
32
|
+
}
|
33
|
+
|
34
|
+
RNSkDrawViewImpl::~RNSkDrawViewImpl() {
|
35
|
+
if([[NSThread currentThread] isMainThread]) {
|
36
|
+
_layer = NULL;
|
37
|
+
} else {
|
38
|
+
__block auto tempLayer = _layer;
|
39
|
+
dispatch_async(dispatch_get_main_queue(), ^{
|
40
|
+
// By using the tempLayer variable in the block we capture it and it will be
|
41
|
+
// released after the block has finished. This way the CAMetalLayer dealloc will
|
42
|
+
// only be called on the main thread. Problem: this destructor might be called from
|
43
|
+
// releasing the RNSkDrawViewImpl from a thread capture (after dtor has started),
|
44
|
+
// which would cause the CAMetalLayer dealloc to be called on another thread which
|
45
|
+
// causes a crash.
|
46
|
+
// https://github.com/Shopify/react-native-skia/issues/398
|
47
|
+
tempLayer = tempLayer;
|
48
|
+
});
|
49
|
+
}
|
35
50
|
}
|
36
51
|
|
37
52
|
void RNSkDrawViewImpl::setSize(int width, int height) {
|
@@ -44,7 +59,7 @@ void RNSkDrawViewImpl::setSize(int width, int height) {
|
|
44
59
|
requestRedraw();
|
45
60
|
}
|
46
61
|
|
47
|
-
void RNSkDrawViewImpl::
|
62
|
+
void RNSkDrawViewImpl::drawPicture(const sk_sp<SkPicture> picture) {
|
48
63
|
if(_width == -1 && _height == -1) {
|
49
64
|
return;
|
50
65
|
}
|
@@ -26,53 +26,55 @@
|
|
26
26
|
_nativeId = 0;
|
27
27
|
_debugMode = false;
|
28
28
|
_drawingMode = RNSkia::RNSkDrawingMode::Default;
|
29
|
+
|
29
30
|
// Listen to notifications about module invalidation
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
usingBlock:^(NSNotification *notification){
|
35
|
-
// Remove local variables
|
36
|
-
self->_manager = nullptr;
|
37
|
-
}];
|
31
|
+
[[NSNotificationCenter defaultCenter] addObserver:self
|
32
|
+
selector:@selector(willInvalidateModules)
|
33
|
+
name:RCTBridgeWillInvalidateModulesNotification
|
34
|
+
object:nil];
|
38
35
|
}
|
39
36
|
return self;
|
40
37
|
}
|
41
38
|
|
42
|
-
- (void)
|
43
|
-
|
44
|
-
|
45
|
-
}
|
39
|
+
- (void) willInvalidateModules {
|
40
|
+
_impl = nullptr;
|
41
|
+
_manager = nullptr;
|
46
42
|
}
|
47
43
|
|
48
44
|
#pragma mark Lifecycle
|
49
45
|
|
50
|
-
- (void)
|
51
|
-
[super willMoveToWindow: newWindow];
|
52
|
-
|
46
|
+
- (void) willMoveToSuperview:(UIView *)newWindow {
|
53
47
|
if (newWindow == NULL) {
|
54
48
|
// Remove implementation view when the parent view is not set
|
55
49
|
if(_impl != nullptr) {
|
50
|
+
[_impl->getLayer() removeFromSuperlayer];
|
51
|
+
|
56
52
|
if(_nativeId != 0 && _manager != nullptr) {
|
57
53
|
_manager->setSkiaDrawView(_nativeId, nullptr);
|
58
54
|
}
|
59
|
-
|
55
|
+
|
60
56
|
_impl = nullptr;
|
61
57
|
}
|
62
58
|
} else {
|
63
59
|
// Create implementation view when the parent view is set
|
64
60
|
if(_impl == nullptr && _manager != nullptr) {
|
65
61
|
_impl = std::make_shared<RNSkDrawViewImpl>(_manager->getPlatformContext());
|
66
|
-
[self.layer addSublayer:_impl->getLayer()];
|
62
|
+
[self.layer addSublayer: _impl->getLayer()];
|
67
63
|
if(_nativeId != 0) {
|
68
|
-
_manager->setSkiaDrawView(_nativeId, _impl
|
64
|
+
_manager->setSkiaDrawView(_nativeId, _impl);
|
69
65
|
}
|
70
66
|
_impl->setDrawingMode(_drawingMode);
|
71
|
-
_impl->setShowDebugOverlays(_debugMode);
|
67
|
+
_impl->setShowDebugOverlays(_debugMode);
|
72
68
|
}
|
73
69
|
}
|
74
70
|
}
|
75
71
|
|
72
|
+
- (void) dealloc {
|
73
|
+
if(_manager != nullptr && _nativeId != 0) {
|
74
|
+
_manager->unregisterSkiaDrawView(_nativeId);
|
75
|
+
}
|
76
|
+
}
|
77
|
+
|
76
78
|
#pragma mark Layout
|
77
79
|
|
78
80
|
- (void) layoutSubviews {
|
@@ -103,7 +105,7 @@
|
|
103
105
|
_nativeId = nativeId;
|
104
106
|
|
105
107
|
if(_impl != nullptr) {
|
106
|
-
_manager->registerSkiaDrawView(nativeId, _impl
|
108
|
+
_manager->registerSkiaDrawView(nativeId, _impl);
|
107
109
|
}
|
108
110
|
}
|
109
111
|
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"sources":["runDecay.ts"],"names":["runDecay","value","config","resolvedConfig","deceleration","velocityFactor","velocity","from","current","updateFunction","t","state","finished","lastTimestamp","startTimestamp","initialVelocity","animation","ValueApi","createAnimation"],"mappings":";;;;;;;AAAA;;AAGA;;AAGA;AACA;AACA;AACA;AACA;AACA;AACA;AACO,MAAMA,QAAQ,GAAG,CAACC,KAAD,EAA2BC,MAA3B,KAAoD;AAC1E,QAAMC,cAAkC,GAAG;AACzCC,IAAAA,YAAY,EAAE,KAD2B;AAEzCC,IAAAA,cAAc,EAAE,CAFyB;AAGzCC,IAAAA,QAAQ,EAAE,CAH+B;AAIzCC,IAAAA,IAAI,EAAEN,KAAK,CAACO,OAJ6B;AAKzC,OAAGN;AALsC,GAA3C;;AAOA,QAAMO,cAAc,GAAG,CAACC,CAAD,EAAYC,KAAZ,KAA8C;AACnE,QAAI,CAACA,KAAL,EAAY;AACV,aAAO;AACLH,QAAAA,OAAO,EAAEL,cAAc,CAACI,IADnB;AAELK,QAAAA,QAAQ,EAAE,KAFL;AAGLC,QAAAA,aAAa,EAAEH,CAHV;AAILI,QAAAA,cAAc,EAAEJ,CAJX;AAKLK,QAAAA,eAAe,EAAEZ,cAAc,CAACG,QAL3B;AAMLA,QAAAA,QAAQ,EAAEH,cAAc,CAACG;AANpB,OAAP;AAQD;;AACD,WAAO,kBAAMI,CAAN,EAASC,KAAT,EAAgBR,cAAhB,CAAP;AACD,GAZD;;AAaAF,EAAAA,KAAK,CAACe,SAAN,GAAkBC,cAASC,eAAT,CAAyBT,cAAzB,CAAlB;AACA,SAAOR,KAAK,CAACe,SAAb;AACD,CAvBM","sourcesContent":["import { ValueApi } from \"../../values/api\";\nimport type { SkiaValue } from \"../../values/types\";\n\nimport { decay } from \"./decay\";\nimport type { DecayConfig, DefaultDecayConfig, DecayState } from \"./types\";\n\n/**\n * Runs a decay animation from the current value to zero with the given decay\n * configuration.\n * @param value value to animate\n * @param config Configuration or default configuration\n * @returns Animation\n */\nexport const runDecay = (value: SkiaValue<number>, config?: DecayConfig) => {\n const resolvedConfig: DefaultDecayConfig = {\n deceleration: 0.998,\n velocityFactor: 1,\n velocity: 0,\n from: value.current,\n ...config,\n };\n const updateFunction = (t: number, state: DecayState | undefined) => {\n if (!state) {\n return {\n current: resolvedConfig.from,\n finished: false,\n lastTimestamp: t,\n startTimestamp: t,\n initialVelocity: resolvedConfig.velocity,\n velocity: resolvedConfig.velocity,\n };\n }\n return decay(t, state, resolvedConfig);\n };\n value.animation = ValueApi.createAnimation(updateFunction);\n return value.animation;\n};\n"]}
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
@@ -0,0 +1,141 @@
|
|
1
|
+
"use strict";
|
2
|
+
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
4
|
+
value: true
|
5
|
+
});
|
6
|
+
exports.Extrapolate = void 0;
|
7
|
+
exports.interpolate = interpolate;
|
8
|
+
|
9
|
+
/* eslint-disable max-len */
|
10
|
+
let Extrapolate;
|
11
|
+
exports.Extrapolate = Extrapolate;
|
12
|
+
|
13
|
+
(function (Extrapolate) {
|
14
|
+
Extrapolate["IDENTITY"] = "identity";
|
15
|
+
Extrapolate["CLAMP"] = "clamp";
|
16
|
+
Extrapolate["EXTEND"] = "extend";
|
17
|
+
})(Extrapolate || (exports.Extrapolate = Extrapolate = {}));
|
18
|
+
|
19
|
+
function getVal(type, coef, val, leftEdgeOutput, rightEdgeOutput, x) {
|
20
|
+
switch (type) {
|
21
|
+
case Extrapolate.IDENTITY:
|
22
|
+
return x;
|
23
|
+
|
24
|
+
case Extrapolate.CLAMP:
|
25
|
+
if (coef * val < coef * leftEdgeOutput) {
|
26
|
+
return leftEdgeOutput;
|
27
|
+
}
|
28
|
+
|
29
|
+
return rightEdgeOutput;
|
30
|
+
|
31
|
+
case Extrapolate.EXTEND:
|
32
|
+
default:
|
33
|
+
return val;
|
34
|
+
}
|
35
|
+
}
|
36
|
+
|
37
|
+
function isExtrapolate(value) {
|
38
|
+
return value === Extrapolate.EXTEND || value === Extrapolate.CLAMP || value === Extrapolate.IDENTITY;
|
39
|
+
} // validates extrapolations type
|
40
|
+
// if type is correct, converts it to ExtrapolationConfig
|
41
|
+
|
42
|
+
|
43
|
+
function validateType(type) {
|
44
|
+
// initialize extrapolationConfig with default extrapolation
|
45
|
+
const extrapolationConfig = {
|
46
|
+
extrapolateLeft: Extrapolate.EXTEND,
|
47
|
+
extrapolateRight: Extrapolate.EXTEND
|
48
|
+
};
|
49
|
+
|
50
|
+
if (!type) {
|
51
|
+
return extrapolationConfig;
|
52
|
+
}
|
53
|
+
|
54
|
+
if (typeof type === "string") {
|
55
|
+
if (!isExtrapolate(type)) {
|
56
|
+
throw new Error(`No supported value for "interpolate" \nSupported values: ["extend", "clamp", "identity", Extrapolatation.CLAMP, Extrapolatation.EXTEND, Extrapolatation.IDENTITY]\n Valid example:
|
57
|
+
interpolate(value, [inputRange], [outputRange], "clamp")`);
|
58
|
+
}
|
59
|
+
|
60
|
+
extrapolationConfig.extrapolateLeft = type;
|
61
|
+
extrapolationConfig.extrapolateRight = type;
|
62
|
+
return extrapolationConfig;
|
63
|
+
} // otherwise type is extrapolation config object
|
64
|
+
|
65
|
+
|
66
|
+
if (type.extrapolateLeft && !isExtrapolate(type.extrapolateLeft) || type.extrapolateRight && !isExtrapolate(type.extrapolateRight)) {
|
67
|
+
throw new Error(`No supported value for "interpolate" \nSupported values: ["extend", "clamp", "identity", Extrapolatation.CLAMP, Extrapolatation.EXTEND, Extrapolatation.IDENTITY]\n Valid example:
|
68
|
+
interpolate(value, [inputRange], [outputRange], {
|
69
|
+
extrapolateLeft: Extrapolation.CLAMP,
|
70
|
+
extrapolateRight: Extrapolation.IDENTITY
|
71
|
+
}})`);
|
72
|
+
}
|
73
|
+
|
74
|
+
Object.assign(extrapolationConfig, type);
|
75
|
+
return extrapolationConfig;
|
76
|
+
}
|
77
|
+
|
78
|
+
function internalInterpolate(x, narrowedInput, extrapolationConfig) {
|
79
|
+
const {
|
80
|
+
leftEdgeInput,
|
81
|
+
rightEdgeInput,
|
82
|
+
leftEdgeOutput,
|
83
|
+
rightEdgeOutput
|
84
|
+
} = narrowedInput;
|
85
|
+
|
86
|
+
if (rightEdgeInput - leftEdgeInput === 0) {
|
87
|
+
return leftEdgeOutput;
|
88
|
+
}
|
89
|
+
|
90
|
+
const progress = (x - leftEdgeInput) / (rightEdgeInput - leftEdgeInput);
|
91
|
+
const val = leftEdgeOutput + progress * (rightEdgeOutput - leftEdgeOutput);
|
92
|
+
const coef = rightEdgeOutput >= leftEdgeOutput ? 1 : -1;
|
93
|
+
|
94
|
+
if (coef * val < coef * leftEdgeOutput) {
|
95
|
+
return getVal(extrapolationConfig.extrapolateLeft, coef, val, leftEdgeOutput, rightEdgeOutput, x);
|
96
|
+
} else if (coef * val > coef * rightEdgeOutput) {
|
97
|
+
return getVal(extrapolationConfig.extrapolateRight, coef, val, leftEdgeOutput, rightEdgeOutput, x);
|
98
|
+
}
|
99
|
+
|
100
|
+
return val;
|
101
|
+
} // e.g. function interpolate(x, input, output, type = Extrapolatation.CLAMP)
|
102
|
+
|
103
|
+
|
104
|
+
function interpolate(x, input, output, type) {
|
105
|
+
if (input.length < 2 || output.length < 2) {
|
106
|
+
throw Error("Interpolation input and output should contain at least two values.");
|
107
|
+
}
|
108
|
+
|
109
|
+
const extrapolationConfig = validateType(type);
|
110
|
+
const {
|
111
|
+
length
|
112
|
+
} = input;
|
113
|
+
const narrowedInput = {
|
114
|
+
leftEdgeInput: input[0],
|
115
|
+
rightEdgeInput: input[1],
|
116
|
+
leftEdgeOutput: output[0],
|
117
|
+
rightEdgeOutput: output[1]
|
118
|
+
};
|
119
|
+
|
120
|
+
if (length > 2) {
|
121
|
+
if (x > input[length - 1]) {
|
122
|
+
narrowedInput.leftEdgeInput = input[length - 2];
|
123
|
+
narrowedInput.rightEdgeInput = input[length - 1];
|
124
|
+
narrowedInput.leftEdgeOutput = output[length - 2];
|
125
|
+
narrowedInput.rightEdgeOutput = output[length - 1];
|
126
|
+
} else {
|
127
|
+
for (let i = 1; i < length; ++i) {
|
128
|
+
if (x <= input[i]) {
|
129
|
+
narrowedInput.leftEdgeInput = input[i - 1];
|
130
|
+
narrowedInput.rightEdgeInput = input[i];
|
131
|
+
narrowedInput.leftEdgeOutput = output[i - 1];
|
132
|
+
narrowedInput.rightEdgeOutput = output[i];
|
133
|
+
break;
|
134
|
+
}
|
135
|
+
}
|
136
|
+
}
|
137
|
+
}
|
138
|
+
|
139
|
+
return internalInterpolate(x, narrowedInput, extrapolationConfig);
|
140
|
+
}
|
141
|
+
//# sourceMappingURL=interpolate.js.map
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"sources":["interpolate.ts"],"names":["Extrapolate","getVal","type","coef","val","leftEdgeOutput","rightEdgeOutput","x","IDENTITY","CLAMP","EXTEND","isExtrapolate","value","validateType","extrapolationConfig","extrapolateLeft","extrapolateRight","Error","Object","assign","internalInterpolate","narrowedInput","leftEdgeInput","rightEdgeInput","progress","interpolate","input","output","length","i"],"mappings":"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","sourcesContent":["/* eslint-disable max-len */\nexport enum Extrapolate {\n IDENTITY = \"identity\",\n CLAMP = \"clamp\",\n EXTEND = \"extend\",\n}\n\ninterface InterpolationNarrowedInput {\n leftEdgeInput: number;\n rightEdgeInput: number;\n leftEdgeOutput: number;\n rightEdgeOutput: number;\n}\n\nexport interface ExtrapolationConfig {\n extrapolateLeft?: Extrapolate | string;\n extrapolateRight?: Extrapolate | string;\n}\n\ninterface RequiredExtrapolationConfig {\n extrapolateLeft: Extrapolate;\n extrapolateRight: Extrapolate;\n}\n\nexport type ExtrapolationType =\n | ExtrapolationConfig\n | Extrapolate\n | string\n | undefined;\n\nfunction getVal(\n type: Extrapolate,\n coef: number,\n val: number,\n leftEdgeOutput: number,\n rightEdgeOutput: number,\n x: number\n): number {\n switch (type) {\n case Extrapolate.IDENTITY:\n return x;\n case Extrapolate.CLAMP:\n if (coef * val < coef * leftEdgeOutput) {\n return leftEdgeOutput;\n }\n return rightEdgeOutput;\n case Extrapolate.EXTEND:\n default:\n return val;\n }\n}\n\nfunction isExtrapolate(value: string): value is Extrapolate {\n return (\n value === Extrapolate.EXTEND ||\n value === Extrapolate.CLAMP ||\n value === Extrapolate.IDENTITY\n );\n}\n\n// validates extrapolations type\n// if type is correct, converts it to ExtrapolationConfig\nfunction validateType(type: ExtrapolationType): RequiredExtrapolationConfig {\n // initialize extrapolationConfig with default extrapolation\n const extrapolationConfig: RequiredExtrapolationConfig = {\n extrapolateLeft: Extrapolate.EXTEND,\n extrapolateRight: Extrapolate.EXTEND,\n };\n\n if (!type) {\n return extrapolationConfig;\n }\n\n if (typeof type === \"string\") {\n if (!isExtrapolate(type)) {\n throw new Error(\n `No supported value for \"interpolate\" \\nSupported values: [\"extend\", \"clamp\", \"identity\", Extrapolatation.CLAMP, Extrapolatation.EXTEND, Extrapolatation.IDENTITY]\\n Valid example:\n interpolate(value, [inputRange], [outputRange], \"clamp\")`\n );\n }\n extrapolationConfig.extrapolateLeft = type;\n extrapolationConfig.extrapolateRight = type;\n return extrapolationConfig;\n }\n\n // otherwise type is extrapolation config object\n if (\n (type.extrapolateLeft && !isExtrapolate(type.extrapolateLeft)) ||\n (type.extrapolateRight && !isExtrapolate(type.extrapolateRight))\n ) {\n throw new Error(\n `No supported value for \"interpolate\" \\nSupported values: [\"extend\", \"clamp\", \"identity\", Extrapolatation.CLAMP, Extrapolatation.EXTEND, Extrapolatation.IDENTITY]\\n Valid example:\n interpolate(value, [inputRange], [outputRange], {\n extrapolateLeft: Extrapolation.CLAMP,\n extrapolateRight: Extrapolation.IDENTITY\n }})`\n );\n }\n\n Object.assign(extrapolationConfig, type);\n return extrapolationConfig;\n}\n\nfunction internalInterpolate(\n x: number,\n narrowedInput: InterpolationNarrowedInput,\n extrapolationConfig: RequiredExtrapolationConfig\n) {\n const { leftEdgeInput, rightEdgeInput, leftEdgeOutput, rightEdgeOutput } =\n narrowedInput;\n if (rightEdgeInput - leftEdgeInput === 0) {\n return leftEdgeOutput;\n }\n const progress = (x - leftEdgeInput) / (rightEdgeInput - leftEdgeInput);\n const val = leftEdgeOutput + progress * (rightEdgeOutput - leftEdgeOutput);\n const coef = rightEdgeOutput >= leftEdgeOutput ? 1 : -1;\n\n if (coef * val < coef * leftEdgeOutput) {\n return getVal(\n extrapolationConfig.extrapolateLeft,\n coef,\n val,\n leftEdgeOutput,\n rightEdgeOutput,\n x\n );\n } else if (coef * val > coef * rightEdgeOutput) {\n return getVal(\n extrapolationConfig.extrapolateRight,\n coef,\n val,\n leftEdgeOutput,\n rightEdgeOutput,\n x\n );\n }\n\n return val;\n}\n\n// e.g. function interpolate(x, input, output, type = Extrapolatation.CLAMP)\nexport function interpolate(\n x: number,\n input: readonly number[],\n output: readonly number[],\n type?: ExtrapolationType\n): number {\n if (input.length < 2 || output.length < 2) {\n throw Error(\n \"Interpolation input and output should contain at least two values.\"\n );\n }\n\n const extrapolationConfig = validateType(type);\n const { length } = input;\n const narrowedInput: InterpolationNarrowedInput = {\n leftEdgeInput: input[0],\n rightEdgeInput: input[1],\n leftEdgeOutput: output[0],\n rightEdgeOutput: output[1],\n };\n if (length > 2) {\n if (x > input[length - 1]) {\n narrowedInput.leftEdgeInput = input[length - 2];\n narrowedInput.rightEdgeInput = input[length - 1];\n narrowedInput.leftEdgeOutput = output[length - 2];\n narrowedInput.rightEdgeOutput = output[length - 1];\n } else {\n for (let i = 1; i < length; ++i) {\n if (x <= input[i]) {\n narrowedInput.leftEdgeInput = input[i - 1];\n narrowedInput.rightEdgeInput = input[i];\n narrowedInput.leftEdgeOutput = output[i - 1];\n narrowedInput.rightEdgeOutput = output[i];\n break;\n }\n }\n }\n }\n\n return internalInterpolate(x, narrowedInput, extrapolationConfig);\n}\n"]}
|
@@ -0,0 +1,39 @@
|
|
1
|
+
"use strict";
|
2
|
+
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
4
|
+
value: true
|
5
|
+
});
|
6
|
+
exports.mixColors = exports.interpolateColors = void 0;
|
7
|
+
|
8
|
+
var _renderer = require("../../renderer");
|
9
|
+
|
10
|
+
var _skia = require("../../skia");
|
11
|
+
|
12
|
+
var _interpolate = require("./interpolate");
|
13
|
+
|
14
|
+
const interpolateColorsRGB = (value, inputRange, outputRange) => {
|
15
|
+
const r = (0, _interpolate.interpolate)(value, inputRange, outputRange.map(c => c[0]), "clamp");
|
16
|
+
const g = (0, _interpolate.interpolate)(value, inputRange, outputRange.map(c => c[1]), "clamp");
|
17
|
+
const b = (0, _interpolate.interpolate)(value, inputRange, outputRange.map(c => c[2]), "clamp");
|
18
|
+
const a = (0, _interpolate.interpolate)(value, inputRange, outputRange.map(c => c[3]), "clamp");
|
19
|
+
return new Float32Array([r, g, b, a]);
|
20
|
+
};
|
21
|
+
|
22
|
+
const interpolateColors = (value, inputRange, _outputRange) => {
|
23
|
+
const outputRange = _outputRange.map(cl => _skia.Skia.Color(cl));
|
24
|
+
|
25
|
+
return interpolateColorsRGB(value, inputRange, outputRange);
|
26
|
+
};
|
27
|
+
|
28
|
+
exports.interpolateColors = interpolateColors;
|
29
|
+
|
30
|
+
const mixColors = (value, x, y) => {
|
31
|
+
const c1 = _skia.Skia.Color(x);
|
32
|
+
|
33
|
+
const c2 = _skia.Skia.Color(y);
|
34
|
+
|
35
|
+
return new Float32Array([(0, _renderer.mix)(value, c1[0], c2[0]), (0, _renderer.mix)(value, c1[1], c2[1]), (0, _renderer.mix)(value, c1[2], c2[2]), (0, _renderer.mix)(value, c1[3], c2[3])]);
|
36
|
+
};
|
37
|
+
|
38
|
+
exports.mixColors = mixColors;
|
39
|
+
//# sourceMappingURL=interpolateColors.js.map
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"sources":["interpolateColors.ts"],"names":["interpolateColorsRGB","value","inputRange","outputRange","r","map","c","g","b","a","Float32Array","interpolateColors","_outputRange","cl","Skia","Color","mixColors","x","y","c1","c2"],"mappings":";;;;;;;AAAA;;AAEA;;AAGA;;AAEA,MAAMA,oBAAoB,GAAG,CAC3BC,KAD2B,EAE3BC,UAF2B,EAG3BC,WAH2B,KAIxB;AACH,QAAMC,CAAC,GAAG,8BACRH,KADQ,EAERC,UAFQ,EAGRC,WAAW,CAACE,GAAZ,CAAiBC,CAAD,IAAOA,CAAC,CAAC,CAAD,CAAxB,CAHQ,EAIR,OAJQ,CAAV;AAMA,QAAMC,CAAC,GAAG,8BACRN,KADQ,EAERC,UAFQ,EAGRC,WAAW,CAACE,GAAZ,CAAiBC,CAAD,IAAOA,CAAC,CAAC,CAAD,CAAxB,CAHQ,EAIR,OAJQ,CAAV;AAMA,QAAME,CAAC,GAAG,8BACRP,KADQ,EAERC,UAFQ,EAGRC,WAAW,CAACE,GAAZ,CAAiBC,CAAD,IAAOA,CAAC,CAAC,CAAD,CAAxB,CAHQ,EAIR,OAJQ,CAAV;AAMA,QAAMG,CAAC,GAAG,8BACRR,KADQ,EAERC,UAFQ,EAGRC,WAAW,CAACE,GAAZ,CAAiBC,CAAD,IAAOA,CAAC,CAAC,CAAD,CAAxB,CAHQ,EAIR,OAJQ,CAAV;AAMA,SAAO,IAAII,YAAJ,CAAiB,CAACN,CAAD,EAAIG,CAAJ,EAAOC,CAAP,EAAUC,CAAV,CAAjB,CAAP;AACD,CA9BD;;AAgCO,MAAME,iBAAiB,GAAG,CAC/BV,KAD+B,EAE/BC,UAF+B,EAG/BU,YAH+B,KAI5B;AACH,QAAMT,WAAW,GAAGS,YAAY,CAACP,GAAb,CAAkBQ,EAAD,IAAQC,WAAKC,KAAL,CAAWF,EAAX,CAAzB,CAApB;;AACA,SAAOb,oBAAoB,CAACC,KAAD,EAAQC,UAAR,EAAoBC,WAApB,CAA3B;AACD,CAPM;;;;AASA,MAAMa,SAAS,GAAG,CAACf,KAAD,EAAgBgB,CAAhB,EAA0BC,CAA1B,KAAuC;AAC9D,QAAMC,EAAE,GAAGL,WAAKC,KAAL,CAAWE,CAAX,CAAX;;AACA,QAAMG,EAAE,GAAGN,WAAKC,KAAL,CAAWG,CAAX,CAAX;;AACA,SAAO,IAAIR,YAAJ,CAAiB,CACtB,mBAAIT,KAAJ,EAAWkB,EAAE,CAAC,CAAD,CAAb,EAAkBC,EAAE,CAAC,CAAD,CAApB,CADsB,EAEtB,mBAAInB,KAAJ,EAAWkB,EAAE,CAAC,CAAD,CAAb,EAAkBC,EAAE,CAAC,CAAD,CAApB,CAFsB,EAGtB,mBAAInB,KAAJ,EAAWkB,EAAE,CAAC,CAAD,CAAb,EAAkBC,EAAE,CAAC,CAAD,CAApB,CAHsB,EAItB,mBAAInB,KAAJ,EAAWkB,EAAE,CAAC,CAAD,CAAb,EAAkBC,EAAE,CAAC,CAAD,CAApB,CAJsB,CAAjB,CAAP;AAMD,CATM","sourcesContent":["import { mix } from \"../../renderer\";\nimport type { Color } from \"../../skia\";\nimport { Skia } from \"../../skia\";\nimport type { SkColor } from \"../../skia/Color\";\n\nimport { interpolate } from \"./interpolate\";\n\nconst interpolateColorsRGB = (\n value: number,\n inputRange: number[],\n outputRange: SkColor[]\n) => {\n const r = interpolate(\n value,\n inputRange,\n outputRange.map((c) => c[0]),\n \"clamp\"\n );\n const g = interpolate(\n value,\n inputRange,\n outputRange.map((c) => c[1]),\n \"clamp\"\n );\n const b = interpolate(\n value,\n inputRange,\n outputRange.map((c) => c[2]),\n \"clamp\"\n );\n const a = interpolate(\n value,\n inputRange,\n outputRange.map((c) => c[3]),\n \"clamp\"\n );\n return new Float32Array([r, g, b, a]);\n};\n\nexport const interpolateColors = (\n value: number,\n inputRange: number[],\n _outputRange: Color[]\n) => {\n const outputRange = _outputRange.map((cl) => Skia.Color(cl));\n return interpolateColorsRGB(value, inputRange, outputRange);\n};\n\nexport const mixColors = (value: number, x: Color, y: Color) => {\n const c1 = Skia.Color(x);\n const c2 = Skia.Color(y);\n return new Float32Array([\n mix(value, c1[0], c2[0]),\n mix(value, c1[1], c2[1]),\n mix(value, c1[2], c2[2]),\n mix(value, c1[3], c2[3]),\n ]);\n};\n"]}
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|