@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
@@ -1,4 +1,4 @@
|
|
1
|
-
import {
|
1
|
+
import { Skia, TileMode } from "../../../skia";
|
2
2
|
import type { SkEnum } from "../../processors/Paint";
|
3
3
|
import type { TransformProps } from "../../processors/Transform";
|
4
4
|
import { enumKey } from "../../processors/Paint";
|
@@ -19,9 +19,7 @@ export const processGradientProps = ({
|
|
19
19
|
flags,
|
20
20
|
...transform
|
21
21
|
}: GradientProps) => ({
|
22
|
-
colors: colors.map((color) =>
|
23
|
-
typeof color === "string" ? Skia.Color(color) : color
|
24
|
-
),
|
22
|
+
colors: colors.map((color) => Skia.Color(color)),
|
25
23
|
positions: positions ?? null,
|
26
24
|
mode: TileMode[enumKey(mode ?? "clamp")],
|
27
25
|
flags,
|
@@ -2,13 +2,13 @@ import React from "react";
|
|
2
2
|
import type { ReactNode } from "react";
|
3
3
|
|
4
4
|
import { isShader } from "../../../skia";
|
5
|
-
import type {
|
5
|
+
import type { SkRuntimeEffect } from "../../../skia";
|
6
6
|
import type { Vector, AnimatedProps, TransformProps } from "../../processors";
|
7
7
|
import { createDeclaration } from "../../nodes/Declaration";
|
8
8
|
import { localMatrix } from "../../processors";
|
9
9
|
|
10
|
-
// We need to use any here because hasOwnProperty doesn't work on JSI instances
|
11
10
|
const isVector = (obj: unknown): obj is Vector =>
|
11
|
+
// We have an issue to check property existence on JSI backed instances
|
12
12
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
13
13
|
(obj as any).x !== undefined && (obj as any).y !== undefined;
|
14
14
|
|
@@ -28,7 +28,7 @@ const processValue = (value: UniformValue): number | readonly number[] => {
|
|
28
28
|
};
|
29
29
|
|
30
30
|
export interface ShaderProps extends TransformProps {
|
31
|
-
source:
|
31
|
+
source: SkRuntimeEffect;
|
32
32
|
uniforms: Uniforms;
|
33
33
|
opaque?: boolean;
|
34
34
|
children?: ReactNode | ReactNode[];
|
@@ -4,9 +4,11 @@ import type {
|
|
4
4
|
CustomPaintProps,
|
5
5
|
AnimatedProps,
|
6
6
|
PathDef,
|
7
|
+
SkEnum,
|
7
8
|
} from "../../processors";
|
8
9
|
import { createDrawing } from "../../nodes";
|
9
|
-
import { processPath } from "../../processors";
|
10
|
+
import { processPath, enumKey } from "../../processors";
|
11
|
+
import { FillType } from "../../../skia";
|
10
12
|
|
11
13
|
interface StrokeOpts {
|
12
14
|
width?: number;
|
@@ -19,16 +21,22 @@ export interface PathProps extends CustomPaintProps {
|
|
19
21
|
start: number;
|
20
22
|
end: number;
|
21
23
|
stroke?: StrokeOpts;
|
24
|
+
fillType?: SkEnum<typeof FillType>;
|
22
25
|
}
|
23
26
|
|
24
27
|
const onDraw = createDrawing<PathProps>(
|
25
|
-
({ canvas, paint }, { start, end, stroke, ...pathProps }) => {
|
28
|
+
({ canvas, paint }, { start, end, stroke, fillType, ...pathProps }) => {
|
26
29
|
const hasStartOffset = start !== 0;
|
27
30
|
const hasEndOffset = end !== 1;
|
28
31
|
const hasStrokeOptions = stroke !== undefined;
|
29
|
-
const
|
32
|
+
const hasFillType = !!fillType;
|
33
|
+
const willMutatePath =
|
34
|
+
hasStartOffset || hasEndOffset || hasStrokeOptions || hasFillType;
|
30
35
|
const pristinePath = processPath(pathProps.path);
|
31
36
|
const path = willMutatePath ? pristinePath.copy() : pristinePath;
|
37
|
+
if (hasFillType) {
|
38
|
+
path.setFillType(FillType[enumKey(fillType)]);
|
39
|
+
}
|
32
40
|
if (hasStrokeOptions) {
|
33
41
|
path.stroke(stroke);
|
34
42
|
}
|
@@ -15,8 +15,9 @@ interface ScalarCircleDef {
|
|
15
15
|
export type CircleDef = PointCircleDef | ScalarCircleDef;
|
16
16
|
|
17
17
|
const isCircleScalarDef = (def: CircleDef): def is ScalarCircleDef =>
|
18
|
+
// We have an issue to check property existence on JSI backed instances
|
18
19
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
19
|
-
(def as any).cx;
|
20
|
+
(def as any).cx !== undefined;
|
20
21
|
export const processCircle = (def: CircleDef) => {
|
21
22
|
if (isCircleScalarDef(def)) {
|
22
23
|
return { c: vec(def.cx, def.cy), r: def.r };
|
@@ -5,7 +5,7 @@ import type { FontMgr } from "../../skia/FontMgr/FontMgr";
|
|
5
5
|
export type FontDef = { font: SkFont } | { familyName: string; size: number };
|
6
6
|
|
7
7
|
export const isFont = (fontDef: FontDef): fontDef is { font: SkFont } =>
|
8
|
-
// We
|
8
|
+
// We have an issue to check property existence on JSI backed instances
|
9
9
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
10
10
|
(fontDef as any).font !== undefined;
|
11
11
|
|
@@ -32,6 +32,7 @@ export interface CustomPaintProps extends ChildrenProps {
|
|
32
32
|
strokeCap?: SkEnum<typeof StrokeCap>;
|
33
33
|
strokeMiter?: number;
|
34
34
|
opacity?: number;
|
35
|
+
antiAlias?: boolean;
|
35
36
|
}
|
36
37
|
|
37
38
|
export const enumKey = <K extends string>(k: K) =>
|
@@ -50,6 +51,7 @@ export const processPaint = (
|
|
50
51
|
strokeCap,
|
51
52
|
strokeMiter,
|
52
53
|
opacity,
|
54
|
+
antiAlias,
|
53
55
|
}: CustomPaintProps,
|
54
56
|
children: DeclarationResult[]
|
55
57
|
) => {
|
@@ -85,6 +87,9 @@ export const processPaint = (
|
|
85
87
|
if (opacity !== undefined) {
|
86
88
|
paint.setAlphaf(opacity);
|
87
89
|
}
|
90
|
+
if (antiAlias !== undefined) {
|
91
|
+
paint.setAntiAlias(antiAlias);
|
92
|
+
}
|
88
93
|
children.forEach((child) => {
|
89
94
|
if (isShader(child)) {
|
90
95
|
paint.setShader(child);
|
@@ -1,26 +1,18 @@
|
|
1
|
-
// Here we use any because hasOwnProperty doesn't work on JSI instances not does the (key in obj) syntax
|
2
|
-
// And using Object.keys for such use-case is incredibly slow
|
3
1
|
/* eslint-disable @typescript-eslint/no-explicit-any */
|
4
2
|
import type { SkRect, SkRRect } from "../../skia";
|
3
|
+
import { Skia } from "../../skia";
|
5
4
|
|
6
5
|
import { vec } from "./math/Vector";
|
7
6
|
import type { Radius } from "./Radius";
|
8
7
|
import { processRadius } from "./Radius";
|
9
8
|
|
10
|
-
export const point = (x: number, y: number) => (
|
9
|
+
export const point = (x: number, y: number) => Skia.Point(x, y);
|
11
10
|
|
12
|
-
export const rect = (x: number, y: number, width: number, height: number) =>
|
13
|
-
x,
|
14
|
-
y,
|
15
|
-
width,
|
16
|
-
height,
|
17
|
-
});
|
11
|
+
export const rect = (x: number, y: number, width: number, height: number) =>
|
12
|
+
Skia.XYWHRect(x, y, width, height);
|
18
13
|
|
19
|
-
export const rrect = (r: SkRect, rx: number, ry: number) =>
|
20
|
-
|
21
|
-
rx,
|
22
|
-
ry,
|
23
|
-
});
|
14
|
+
export const rrect = (r: SkRect, rx: number, ry: number) =>
|
15
|
+
Skia.RRectXY(r, rx, ry);
|
24
16
|
|
25
17
|
export const bounds = (rects: SkRect[]) => {
|
26
18
|
const x = Math.min(...rects.map((r) => r.x));
|
@@ -47,10 +39,13 @@ export const center = (r: SkRect | SkRRect) =>
|
|
47
39
|
? vec(r.rect.x + r.rect.width / 2, r.rect.y + r.rect.height / 2)
|
48
40
|
: vec(r.x + r.width / 2, r.y + r.height / 2);
|
49
41
|
|
42
|
+
// We have an issue to check property existence on JSI backed instances
|
50
43
|
const isRRectCtor = (def: RRectDef): def is RRectCtor =>
|
51
44
|
(def as any).rect === undefined;
|
45
|
+
// We have an issue to check property existence on JSI backed instances
|
52
46
|
const isRectCtor = (def: RectDef): def is RectCtor =>
|
53
47
|
(def as any).rect === undefined;
|
48
|
+
// We have an issue to check property existence on JSI backed instances
|
54
49
|
export const isRRect = (def: SkRect | SkRRect): def is SkRRect =>
|
55
50
|
(def as any).rect !== undefined;
|
56
51
|
|
@@ -1,9 +1,5 @@
|
|
1
1
|
import { exhaustiveCheck } from "../../typeddash";
|
2
|
-
import
|
3
|
-
|
4
|
-
export type Vec3 = readonly [number, number, number];
|
5
|
-
|
6
|
-
export type Matrix3 = readonly [Vec3, Vec3, Vec3];
|
2
|
+
import { Skia } from "../../../skia";
|
7
3
|
|
8
4
|
type Transform2dName =
|
9
5
|
| "translateX"
|
@@ -34,121 +30,44 @@ export type Transforms2d = readonly (
|
|
34
30
|
| Pick<Transformations, "rotate">
|
35
31
|
)[];
|
36
32
|
|
37
|
-
const
|
38
|
-
|
39
|
-
|
40
|
-
[0, 0, 1],
|
41
|
-
];
|
42
|
-
|
43
|
-
const translateXMatrix = (x: number): Matrix3 => [
|
44
|
-
[1, 0, x],
|
45
|
-
[0, 1, 0],
|
46
|
-
[0, 0, 1],
|
47
|
-
];
|
48
|
-
|
49
|
-
const translateYMatrix = (y: number): Matrix3 => [
|
50
|
-
[1, 0, 0],
|
51
|
-
[0, 1, y],
|
52
|
-
[0, 0, 1],
|
53
|
-
];
|
54
|
-
|
55
|
-
const scaleMatrix = (s: number): Matrix3 => [
|
56
|
-
[s, 0, 0],
|
57
|
-
[0, s, 0],
|
58
|
-
[0, 0, 1],
|
59
|
-
];
|
60
|
-
|
61
|
-
const scaleXMatrix = (s: number): Matrix3 => [
|
62
|
-
[s, 0, 0],
|
63
|
-
[0, 1, 0],
|
64
|
-
[0, 0, 1],
|
65
|
-
];
|
66
|
-
|
67
|
-
const scaleYMatrix = (s: number): Matrix3 => [
|
68
|
-
[1, 0, 0],
|
69
|
-
[0, s, 0],
|
70
|
-
[0, 0, 1],
|
71
|
-
];
|
72
|
-
|
73
|
-
const skewXMatrix = (s: number): Matrix3 => [
|
74
|
-
[1, Math.tan(s), 0],
|
75
|
-
[0, 1, 0],
|
76
|
-
[0, 0, 1],
|
77
|
-
];
|
78
|
-
|
79
|
-
const skewYMatrix = (s: number): Matrix3 => [
|
80
|
-
[1, 0, 0],
|
81
|
-
[Math.tan(s), 1, 0],
|
82
|
-
[0, 0, 1],
|
83
|
-
];
|
84
|
-
|
85
|
-
const rotateZMatrix = (r: number): Matrix3 => [
|
86
|
-
[Math.cos(r), -1 * Math.sin(r), 0],
|
87
|
-
[Math.sin(r), Math.cos(r), 0],
|
88
|
-
[0, 0, 1],
|
89
|
-
];
|
90
|
-
|
91
|
-
const dot3 = (row: Vec3, col: Vec3) =>
|
92
|
-
row[0] * col[0] + row[1] * col[1] + row[2] * col[2];
|
93
|
-
|
94
|
-
const multiply3 = (m1: Matrix3, m2: Matrix3) => {
|
95
|
-
const col0 = [m2[0][0], m2[1][0], m2[2][0]] as const;
|
96
|
-
const col1 = [m2[0][1], m2[1][1], m2[2][1]] as const;
|
97
|
-
const col2 = [m2[0][2], m2[1][2], m2[2][2]] as const;
|
98
|
-
return [
|
99
|
-
[dot3(m1[0], col0), dot3(m1[0], col1), dot3(m1[0], col2)],
|
100
|
-
[dot3(m1[1], col0), dot3(m1[1], col1), dot3(m1[1], col2)],
|
101
|
-
[dot3(m1[2], col0), dot3(m1[2], col1), dot3(m1[2], col2)],
|
102
|
-
] as const;
|
103
|
-
};
|
104
|
-
|
105
|
-
export const matrixVecMul3 = (m: Matrix3, v: Vec3) =>
|
106
|
-
[dot3(m[0], v), dot3(m[1], v), dot3(m[2], v)] as const;
|
107
|
-
|
108
|
-
const skiaMatrix3 = (m: Matrix3): SkMatrix => {
|
109
|
-
return [
|
110
|
-
m[0][0],
|
111
|
-
m[0][1],
|
112
|
-
m[0][2],
|
113
|
-
m[1][0],
|
114
|
-
m[1][1],
|
115
|
-
m[1][2],
|
116
|
-
m[2][0],
|
117
|
-
m[2][1],
|
118
|
-
m[2][2],
|
119
|
-
];
|
120
|
-
};
|
121
|
-
|
122
|
-
export const processTransform2d = (transforms: Transforms2d) =>
|
123
|
-
skiaMatrix3(processTransform(transforms));
|
124
|
-
|
125
|
-
const processTransform = (transforms: Transforms2d) =>
|
126
|
-
transforms.reduce((acc, transform) => {
|
33
|
+
export const processTransform2d = (transforms: Transforms2d) => {
|
34
|
+
const m = Skia.Matrix();
|
35
|
+
for (const transform of transforms) {
|
127
36
|
const key = Object.keys(transform)[0] as Transform2dName;
|
128
37
|
const value = (transform as Pick<Transformations, typeof key>)[key];
|
129
38
|
if (key === "translateX") {
|
130
|
-
|
39
|
+
m.preTranslate(value, 0);
|
40
|
+
continue;
|
131
41
|
}
|
132
42
|
if (key === "translateY") {
|
133
|
-
|
43
|
+
m.preTranslate(0, value);
|
44
|
+
continue;
|
134
45
|
}
|
135
46
|
if (key === "scale") {
|
136
|
-
|
47
|
+
m.preScale(value, value);
|
48
|
+
continue;
|
137
49
|
}
|
138
50
|
if (key === "scaleX") {
|
139
|
-
|
51
|
+
m.preScale(value, 0);
|
52
|
+
continue;
|
140
53
|
}
|
141
54
|
if (key === "scaleY") {
|
142
|
-
|
55
|
+
m.preScale(0, value);
|
56
|
+
continue;
|
143
57
|
}
|
144
58
|
if (key === "skewX") {
|
145
|
-
|
59
|
+
m.preSkew(value, 0);
|
60
|
+
continue;
|
146
61
|
}
|
147
62
|
if (key === "skewY") {
|
148
|
-
|
63
|
+
m.preSkew(0, value);
|
64
|
+
continue;
|
149
65
|
}
|
150
66
|
if (key === "rotate" || key === "rotateZ") {
|
151
|
-
|
67
|
+
m.preRotate((value * 180) / Math.PI);
|
68
|
+
continue;
|
152
69
|
}
|
153
|
-
|
154
|
-
}
|
70
|
+
exhaustiveCheck(key);
|
71
|
+
}
|
72
|
+
return m;
|
73
|
+
};
|
@@ -1,11 +1,12 @@
|
|
1
|
-
import { interpolate } from "../../../
|
1
|
+
import { interpolate } from "../../../animation/functions/interpolate";
|
2
|
+
import { Skia } from "../../../skia";
|
2
3
|
|
3
4
|
export interface Vector {
|
4
5
|
x: number;
|
5
6
|
y: number;
|
6
7
|
}
|
7
8
|
|
8
|
-
export const vec = (x = 0, y?: number) => (
|
9
|
+
export const vec = (x = 0, y?: number) => Skia.Point(x, y ?? x);
|
9
10
|
export const neg = (a: Vector) => vec(-a.x, -a.y);
|
10
11
|
export const add = (a: Vector, b: Vector) => vec(a.x + b.x, a.y + b.y);
|
11
12
|
export const sub = (a: Vector, b: Vector) => vec(a.x - b.x, a.y - b.y);
|
package/src/skia/Color.ts
CHANGED
@@ -1,34 +1,20 @@
|
|
1
1
|
import { Skia } from "./Skia";
|
2
2
|
|
3
|
-
// This is the JSI color
|
4
|
-
export type SkColor =
|
5
|
-
// Input colors can be string or
|
6
|
-
export type Color = string | number;
|
3
|
+
// This is the JSI color
|
4
|
+
export type SkColor = Float32Array;
|
5
|
+
// Input colors can be string, number or Float32Array
|
6
|
+
export type Color = string | Float32Array | number;
|
7
7
|
|
8
|
-
export const
|
9
|
-
export const
|
10
|
-
export const
|
11
|
-
export const
|
12
|
-
export const rgbaColor = (r: number, g: number, b: number, af: number) => {
|
13
|
-
const a = Math.round(af * 255);
|
14
|
-
return ((a << 24) | (r << 16) | (g << 8) | b) >>> 0;
|
15
|
-
};
|
8
|
+
export const RED = 0;
|
9
|
+
export const GREEN = 1;
|
10
|
+
export const BLUE = 2;
|
11
|
+
export const ALPHA = 3;
|
16
12
|
|
17
|
-
const
|
18
|
-
|
19
|
-
const r = red(icl);
|
20
|
-
const g = green(icl);
|
21
|
-
const b = blue(icl);
|
22
|
-
const a = alphaf(icl);
|
23
|
-
return [r, g, b, a] as const;
|
24
|
-
};
|
13
|
+
export const rgbaColor = (r: number, g: number, b: number, a: number) =>
|
14
|
+
new Float32Array([r, g, b, a]);
|
25
15
|
|
26
16
|
export const processColor = (cl: Color, currentOpacity: number) => {
|
27
|
-
const
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
export const processColorAsUnitArray = (cl: Color, currentOpacity: number) => {
|
32
|
-
const [r, g, b, a] = processColorAsArray(cl);
|
33
|
-
return [r / 255, g / 255, b / 255, a * currentOpacity] as const;
|
17
|
+
const color = Skia.Color(cl);
|
18
|
+
color[ALPHA] *= currentOpacity;
|
19
|
+
return color;
|
34
20
|
};
|
@@ -3,6 +3,7 @@ import type { SkColorFilter } from "../ColorFilter/ColorFilter";
|
|
3
3
|
import type { SkShader } from "../Shader/Shader";
|
4
4
|
import type { SkRect } from "../Rect";
|
5
5
|
import type { BlendMode } from "../Paint/BlendMode";
|
6
|
+
import type { SkRuntimeShaderBuilder } from "../RuntimeEffect";
|
6
7
|
|
7
8
|
import type { SkImageFilter, TileMode } from "./ImageFilter";
|
8
9
|
|
@@ -169,4 +170,23 @@ export interface ImageFilterFactory {
|
|
169
170
|
foreground: SkImageFilter | null,
|
170
171
|
cropRect?: SkRect
|
171
172
|
) => SkImageFilter;
|
173
|
+
/**
|
174
|
+
* Create a filter that fills the output with the per-pixel evaluation of the SkShader produced
|
175
|
+
* by the SkRuntimeShaderBuilder. The shader is defined in the image filter's local coordinate
|
176
|
+
* system, so it will automatically be affected by SkCanvas' transform.
|
177
|
+
*
|
178
|
+
* @param builder The builder used to produce the runtime shader, that will in turn
|
179
|
+
* fill the result image
|
180
|
+
* @param childShaderName The name of the child shader defined in the builder that will be
|
181
|
+
* bound to the input param (or the source image if the input param
|
182
|
+
* is null). If null the builder can have exactly one child shader,
|
183
|
+
* which automatically binds the input param.
|
184
|
+
* @param input The image filter that will be provided as input to the runtime
|
185
|
+
* shader. If null the implicit source image is used instead
|
186
|
+
*/
|
187
|
+
MakeRuntimeShader: (
|
188
|
+
builder: SkRuntimeShaderBuilder,
|
189
|
+
childShaderName: string | null,
|
190
|
+
input: SkImageFilter | null
|
191
|
+
) => SkImageFilter;
|
172
192
|
}
|
package/src/skia/Matrix.ts
CHANGED
@@ -1,3 +1,4 @@
|
|
1
|
+
import type { SkJSIInstance } from "./JsiInstance";
|
1
2
|
export enum MatrixIndex {
|
2
3
|
ScaleX = 0,
|
3
4
|
SkewX = 1,
|
@@ -10,7 +11,7 @@ export enum MatrixIndex {
|
|
10
11
|
persp2 = 8,
|
11
12
|
}
|
12
13
|
|
13
|
-
export interface SkMatrix {
|
14
|
+
export interface SkMatrix extends SkJSIInstance<"Matrix"> {
|
14
15
|
0: number;
|
15
16
|
1: number;
|
16
17
|
2: number;
|
@@ -20,4 +21,10 @@ export interface SkMatrix {
|
|
20
21
|
6: number;
|
21
22
|
7: number;
|
22
23
|
8: number;
|
24
|
+
|
25
|
+
preConcat: (matrix: SkMatrix) => void;
|
26
|
+
preTranslate: (x: number, y: number) => void;
|
27
|
+
preScale: (x: number, y: number) => void;
|
28
|
+
preSkew: (x: number, y: number) => void;
|
29
|
+
preRotate: (theta: number) => void;
|
23
30
|
}
|
package/src/skia/Paint/Paint.ts
CHANGED
@@ -5,6 +5,7 @@ import type { SkShader } from "../Shader";
|
|
5
5
|
import type { SkColor } from "../Color";
|
6
6
|
import type { IPathEffect } from "../PathEffect";
|
7
7
|
import type { SkJSIInstance } from "../JsiInstance";
|
8
|
+
import { Skia } from "../Skia";
|
8
9
|
|
9
10
|
import type { BlendMode } from "./BlendMode";
|
10
11
|
|
@@ -25,6 +26,12 @@ export enum StrokeJoin {
|
|
25
26
|
Round,
|
26
27
|
}
|
27
28
|
|
29
|
+
export const SkiaPaint = () => {
|
30
|
+
const paint = Skia.Paint();
|
31
|
+
paint.setAntiAlias(true);
|
32
|
+
return paint;
|
33
|
+
};
|
34
|
+
|
28
35
|
export const isPaint = (obj: SkJSIInstance<string> | null): obj is SkPaint =>
|
29
36
|
obj !== null && obj.__typename__ === "Paint";
|
30
37
|
|
@@ -1,8 +1,7 @@
|
|
1
1
|
import type { DependencyList } from "react";
|
2
2
|
import { useMemo } from "react";
|
3
3
|
|
4
|
-
import {
|
5
|
-
|
4
|
+
import { SkiaPaint } from "./Paint";
|
6
5
|
import type { SkPaint } from "./Paint";
|
7
6
|
|
8
7
|
/**
|
@@ -13,8 +12,7 @@ export const usePaint = (
|
|
13
12
|
deps?: DependencyList
|
14
13
|
) =>
|
15
14
|
useMemo(() => {
|
16
|
-
const p =
|
17
|
-
p.setAntiAlias(true);
|
15
|
+
const p = SkiaPaint();
|
18
16
|
if (initializer) {
|
19
17
|
initializer(p);
|
20
18
|
}
|
@@ -10,7 +10,9 @@ export interface SkSLUniform {
|
|
10
10
|
isInteger: boolean;
|
11
11
|
}
|
12
12
|
|
13
|
-
export
|
13
|
+
export type SkRuntimeShaderBuilder = SkJSIInstance<"RuntimeShaderBuilder">;
|
14
|
+
|
15
|
+
export interface SkRuntimeEffect extends SkJSIInstance<"RuntimeEffect"> {
|
14
16
|
/**
|
15
17
|
* Returns a shader executed using the given uniform data.
|
16
18
|
* @param uniforms
|
@@ -1,4 +1,4 @@
|
|
1
|
-
import type {
|
1
|
+
import type { SkRuntimeEffect } from "./RuntimeEffect";
|
2
2
|
|
3
3
|
export interface RuntimeEffectFactory {
|
4
4
|
/**
|
@@ -7,6 +7,6 @@ export interface RuntimeEffectFactory {
|
|
7
7
|
* @param callback - will be called with any compilation error. If not provided, errors will
|
8
8
|
* be printed to console.log().
|
9
9
|
*/
|
10
|
-
Make: (sksl: string) =>
|
10
|
+
Make: (sksl: string) => SkRuntimeEffect | null;
|
11
11
|
//Make(sksl: string, callback?: (err: string) => void): RuntimeEffect | null;
|
12
12
|
}
|
@@ -3,4 +3,7 @@ import { useMemo } from "react";
|
|
3
3
|
import { Skia } from "../Skia";
|
4
4
|
|
5
5
|
export const useShader = (sksl: string) =>
|
6
|
-
useMemo(() =>
|
6
|
+
useMemo(() => {
|
7
|
+
console.warn("Use shader will be deprecated.");
|
8
|
+
return Skia.RuntimeEffect.Make(sksl);
|
9
|
+
}, [sksl]);
|