@shopify/react-native-skia 1.8.0 → 1.8.2
Sign up to get free protection for your applications and to get access to all the features.
- package/cpp/api/JsiSkPaint.h +8 -1
- package/lib/commonjs/dom/types/Common.d.ts +6 -4
- package/lib/commonjs/dom/types/Common.js.map +1 -1
- package/lib/commonjs/dom/types/ImageFilters.d.ts +1 -1
- package/lib/commonjs/dom/types/ImageFilters.js.map +1 -1
- package/lib/commonjs/dom/types/Node.d.ts +0 -2
- package/lib/commonjs/dom/types/Node.js.map +1 -1
- package/lib/commonjs/external/reanimated/index.d.ts +0 -1
- package/lib/commonjs/external/reanimated/index.js +0 -11
- package/lib/commonjs/external/reanimated/index.js.map +1 -1
- package/lib/commonjs/external/reanimated/renderHelpers.d.ts +0 -1
- package/lib/commonjs/external/reanimated/renderHelpers.js +5 -43
- package/lib/commonjs/external/reanimated/renderHelpers.js.map +1 -1
- package/lib/commonjs/external/reanimated/useAnimatedImageValue.js +1 -8
- package/lib/commonjs/external/reanimated/useAnimatedImageValue.js.map +1 -1
- package/lib/commonjs/skia/core/AnimatedImage.d.ts +1 -1
- package/lib/commonjs/skia/core/AnimatedImage.js +1 -1
- package/lib/commonjs/skia/core/AnimatedImage.js.map +1 -1
- package/lib/commonjs/skia/core/Data.d.ts +1 -1
- package/lib/commonjs/skia/core/Data.js +2 -8
- package/lib/commonjs/skia/core/Data.js.map +1 -1
- package/lib/commonjs/skia/types/Paint/Paint.d.ts +1 -0
- package/lib/commonjs/skia/types/Paint/Paint.js.map +1 -1
- package/lib/commonjs/skia/web/JsiSkPaint.d.ts +1 -0
- package/lib/commonjs/skia/web/JsiSkPaint.js +3 -0
- package/lib/commonjs/skia/web/JsiSkPaint.js.map +1 -1
- package/lib/commonjs/sksg/Container.d.ts +3 -2
- package/lib/commonjs/sksg/Container.js +32 -26
- package/lib/commonjs/sksg/Container.js.map +1 -1
- package/lib/commonjs/sksg/HostConfig.d.ts +2 -2
- package/lib/commonjs/sksg/HostConfig.js +7 -25
- package/lib/commonjs/sksg/HostConfig.js.map +1 -1
- package/lib/commonjs/sksg/Node.d.ts +19 -0
- package/lib/commonjs/sksg/Node.js +78 -0
- package/lib/commonjs/sksg/Node.js.map +1 -0
- package/lib/commonjs/sksg/Reconciler.d.ts +1 -1
- package/lib/commonjs/sksg/Recorder/Core.d.ts +79 -0
- package/lib/commonjs/sksg/Recorder/Core.js +110 -0
- package/lib/commonjs/sksg/Recorder/Core.js.map +1 -0
- package/lib/commonjs/sksg/Recorder/DrawingContext.d.ts +18 -0
- package/lib/commonjs/sksg/Recorder/DrawingContext.js +105 -0
- package/lib/commonjs/sksg/Recorder/DrawingContext.js.map +1 -0
- package/lib/commonjs/sksg/Recorder/Player.d.ts +3 -0
- package/lib/commonjs/sksg/Recorder/Player.js +127 -0
- package/lib/commonjs/sksg/Recorder/Player.js.map +1 -0
- package/lib/commonjs/sksg/Recorder/Recorder.d.ts +50 -0
- package/lib/commonjs/sksg/Recorder/Recorder.js +288 -0
- package/lib/commonjs/sksg/Recorder/Recorder.js.map +1 -0
- package/lib/commonjs/sksg/Recorder/Recording.d.ts +7 -0
- package/lib/commonjs/sksg/Recorder/Recording.js +12 -0
- package/lib/commonjs/sksg/Recorder/Recording.js.map +1 -0
- package/lib/commonjs/sksg/Recorder/Visitor.d.ts +5 -0
- package/lib/commonjs/sksg/Recorder/Visitor.js +293 -0
- package/lib/commonjs/sksg/Recorder/Visitor.js.map +1 -0
- package/lib/commonjs/sksg/Recorder/commands/Box.d.ts +13 -0
- package/lib/commonjs/sksg/Recorder/commands/Box.js +71 -0
- package/lib/commonjs/sksg/Recorder/commands/Box.js.map +1 -0
- package/lib/commonjs/sksg/Recorder/commands/CTM.d.ts +3 -0
- package/lib/commonjs/sksg/Recorder/commands/CTM.js +79 -0
- package/lib/commonjs/sksg/Recorder/commands/CTM.js.map +1 -0
- package/lib/commonjs/sksg/Recorder/commands/ColorFilters.d.ts +6 -0
- package/lib/commonjs/sksg/Recorder/commands/ColorFilters.js +76 -0
- package/lib/commonjs/sksg/Recorder/commands/ColorFilters.js.map +1 -0
- package/lib/commonjs/sksg/Recorder/commands/Drawing.d.ts +24 -0
- package/lib/commonjs/sksg/{nodes/drawings.js → Recorder/commands/Drawing.js} +5 -5
- package/lib/commonjs/sksg/Recorder/commands/Drawing.js.map +1 -0
- package/lib/commonjs/sksg/Recorder/commands/ImageFilters.d.ts +12 -0
- package/lib/commonjs/sksg/Recorder/commands/ImageFilters.js +183 -0
- package/lib/commonjs/sksg/Recorder/commands/ImageFilters.js.map +1 -0
- package/lib/commonjs/sksg/Recorder/commands/Paint.d.ts +4 -0
- package/lib/commonjs/sksg/Recorder/commands/Paint.js +70 -0
- package/lib/commonjs/sksg/Recorder/commands/Paint.js.map +1 -0
- package/lib/commonjs/sksg/Recorder/commands/PathEffects.d.ts +6 -0
- package/lib/commonjs/sksg/Recorder/commands/PathEffects.js +137 -0
- package/lib/commonjs/sksg/Recorder/commands/PathEffects.js.map +1 -0
- package/lib/commonjs/sksg/Recorder/commands/Shaders.d.ts +5 -0
- package/lib/commonjs/sksg/{nodes/shaders.js → Recorder/commands/Shaders.js} +58 -15
- package/lib/commonjs/sksg/Recorder/commands/Shaders.js.map +1 -0
- package/lib/commonjs/sksg/{nodes/utils.d.ts → utils.d.ts} +3 -0
- package/lib/commonjs/sksg/{nodes/utils.js → utils.js} +12 -2
- package/lib/commonjs/sksg/utils.js.map +1 -0
- package/lib/module/dom/types/Common.d.ts +6 -4
- package/lib/module/dom/types/Common.js.map +1 -1
- package/lib/module/dom/types/ImageFilters.d.ts +1 -1
- package/lib/module/dom/types/ImageFilters.js.map +1 -1
- package/lib/module/dom/types/Node.d.ts +0 -2
- package/lib/module/dom/types/Node.js.map +1 -1
- package/lib/module/external/reanimated/index.d.ts +0 -1
- package/lib/module/external/reanimated/index.js +0 -1
- package/lib/module/external/reanimated/index.js.map +1 -1
- package/lib/module/external/reanimated/renderHelpers.d.ts +0 -1
- package/lib/module/external/reanimated/renderHelpers.js +4 -42
- package/lib/module/external/reanimated/renderHelpers.js.map +1 -1
- package/lib/module/external/reanimated/useAnimatedImageValue.js +1 -8
- package/lib/module/external/reanimated/useAnimatedImageValue.js.map +1 -1
- package/lib/module/skia/core/AnimatedImage.d.ts +1 -1
- package/lib/module/skia/core/AnimatedImage.js +1 -1
- package/lib/module/skia/core/AnimatedImage.js.map +1 -1
- package/lib/module/skia/core/Data.d.ts +1 -1
- package/lib/module/skia/core/Data.js +2 -8
- package/lib/module/skia/core/Data.js.map +1 -1
- package/lib/module/skia/types/Paint/Paint.d.ts +1 -0
- package/lib/module/skia/types/Paint/Paint.js.map +1 -1
- package/lib/module/skia/web/JsiSkPaint.d.ts +1 -0
- package/lib/module/skia/web/JsiSkPaint.js +3 -0
- package/lib/module/skia/web/JsiSkPaint.js.map +1 -1
- package/lib/module/sksg/Container.d.ts +3 -2
- package/lib/module/sksg/Container.js +30 -24
- package/lib/module/sksg/Container.js.map +1 -1
- package/lib/module/sksg/HostConfig.d.ts +2 -2
- package/lib/module/sksg/HostConfig.js +7 -25
- package/lib/module/sksg/HostConfig.js.map +1 -1
- package/lib/module/sksg/Node.d.ts +19 -0
- package/lib/module/sksg/Node.js +67 -0
- package/lib/module/sksg/Node.js.map +1 -0
- package/lib/module/sksg/Reconciler.d.ts +1 -1
- package/lib/module/sksg/Recorder/Core.d.ts +79 -0
- package/lib/module/sksg/Recorder/Core.js +101 -0
- package/lib/module/sksg/Recorder/Core.js.map +1 -0
- package/lib/module/sksg/Recorder/DrawingContext.d.ts +18 -0
- package/lib/module/sksg/Recorder/DrawingContext.js +98 -0
- package/lib/module/sksg/Recorder/DrawingContext.js.map +1 -0
- package/lib/module/sksg/Recorder/Player.d.ts +3 -0
- package/lib/module/sksg/Recorder/Player.js +120 -0
- package/lib/module/sksg/Recorder/Player.js.map +1 -0
- package/lib/module/sksg/Recorder/Recorder.d.ts +50 -0
- package/lib/module/sksg/Recorder/Recorder.js +281 -0
- package/lib/module/sksg/Recorder/Recorder.js.map +1 -0
- package/lib/module/sksg/Recorder/Recording.d.ts +7 -0
- package/lib/module/sksg/Recorder/Recording.js +5 -0
- package/lib/module/sksg/Recorder/Recording.js.map +1 -0
- package/lib/module/sksg/Recorder/Visitor.d.ts +5 -0
- package/lib/module/sksg/Recorder/Visitor.js +285 -0
- package/lib/module/sksg/Recorder/Visitor.js.map +1 -0
- package/lib/module/sksg/Recorder/commands/Box.d.ts +13 -0
- package/lib/module/sksg/Recorder/commands/Box.js +63 -0
- package/lib/module/sksg/Recorder/commands/Box.js.map +1 -0
- package/lib/module/sksg/Recorder/commands/CTM.d.ts +3 -0
- package/lib/module/sksg/Recorder/commands/CTM.js +72 -0
- package/lib/module/sksg/Recorder/commands/CTM.js.map +1 -0
- package/lib/module/sksg/Recorder/commands/ColorFilters.d.ts +6 -0
- package/lib/module/sksg/Recorder/commands/ColorFilters.js +67 -0
- package/lib/module/sksg/Recorder/commands/ColorFilters.js.map +1 -0
- package/lib/module/sksg/Recorder/commands/Drawing.d.ts +24 -0
- package/lib/module/sksg/{nodes/drawings.js → Recorder/commands/Drawing.js} +5 -5
- package/lib/module/sksg/Recorder/commands/Drawing.js.map +1 -0
- package/lib/module/sksg/Recorder/commands/ImageFilters.d.ts +12 -0
- package/lib/module/sksg/{nodes/imageFilters.js → Recorder/commands/ImageFilters.js} +87 -95
- package/lib/module/sksg/Recorder/commands/ImageFilters.js.map +1 -0
- package/lib/module/sksg/Recorder/commands/Paint.d.ts +4 -0
- package/lib/module/sksg/Recorder/commands/Paint.js +62 -0
- package/lib/module/sksg/Recorder/commands/Paint.js.map +1 -0
- package/lib/module/sksg/Recorder/commands/PathEffects.d.ts +6 -0
- package/lib/module/sksg/Recorder/commands/PathEffects.js +128 -0
- package/lib/module/sksg/Recorder/commands/PathEffects.js.map +1 -0
- package/lib/module/sksg/Recorder/commands/Shaders.d.ts +5 -0
- package/lib/module/sksg/{nodes/shaders.js → Recorder/commands/Shaders.js} +63 -13
- package/lib/module/sksg/Recorder/commands/Shaders.js.map +1 -0
- package/lib/module/sksg/{nodes/utils.d.ts → utils.d.ts} +3 -0
- package/lib/module/sksg/{nodes/utils.js → utils.js} +10 -1
- package/lib/module/sksg/utils.js.map +1 -0
- package/lib/typescript/lib/commonjs/external/reanimated/renderHelpers.d.ts +0 -1
- package/lib/typescript/lib/commonjs/skia/core/AnimatedImage.d.ts +1 -1
- package/lib/typescript/lib/commonjs/skia/core/Data.d.ts +1 -1
- package/lib/typescript/lib/commonjs/skia/web/JsiSkPaint.d.ts +1 -0
- package/lib/typescript/lib/commonjs/sksg/Container.d.ts +4 -0
- package/lib/typescript/lib/commonjs/sksg/HostConfig.d.ts +1 -3
- package/lib/typescript/lib/commonjs/sksg/Node.d.ts +14 -0
- package/lib/typescript/lib/commonjs/sksg/Recorder/Core.d.ts +5 -0
- package/lib/typescript/lib/commonjs/sksg/Recorder/DrawingContext.d.ts +17 -0
- package/lib/typescript/lib/commonjs/sksg/Recorder/Player.d.ts +2 -0
- package/lib/typescript/lib/commonjs/sksg/Recorder/Recorder.d.ts +45 -0
- package/lib/typescript/lib/commonjs/sksg/Recorder/Recording.d.ts +5 -0
- package/lib/typescript/lib/commonjs/sksg/Recorder/Visitor.d.ts +27 -0
- package/lib/typescript/lib/commonjs/sksg/Recorder/commands/Box.d.ts +3 -0
- package/lib/typescript/lib/commonjs/sksg/Recorder/commands/CTM.d.ts +2 -0
- package/lib/typescript/lib/commonjs/sksg/Recorder/commands/ColorFilters.d.ts +4 -0
- package/lib/typescript/lib/commonjs/sksg/Recorder/commands/ImageFilters.d.ts +6 -0
- package/lib/typescript/lib/commonjs/sksg/Recorder/commands/Paint.d.ts +14 -0
- package/lib/typescript/lib/commonjs/sksg/Recorder/commands/PathEffects.d.ts +4 -0
- package/lib/typescript/lib/commonjs/sksg/Recorder/commands/Shaders.d.ts +3 -0
- package/lib/typescript/lib/commonjs/sksg/{nodes/utils.d.ts → utils.d.ts} +1 -0
- package/lib/typescript/lib/module/external/reanimated/index.d.ts +0 -1
- package/lib/typescript/lib/module/external/reanimated/renderHelpers.d.ts +0 -1
- package/lib/typescript/lib/module/mock/index.d.ts +1 -1
- package/lib/typescript/lib/module/skia/core/AnimatedImage.d.ts +1 -1
- package/lib/typescript/lib/module/skia/core/Data.d.ts +1 -1
- package/lib/typescript/lib/module/skia/web/JsiSkPaint.d.ts +1 -0
- package/lib/typescript/lib/module/sksg/Container.d.ts +4 -0
- package/lib/typescript/lib/module/sksg/HostConfig.d.ts +1 -3
- package/lib/typescript/lib/module/sksg/Node.d.ts +13 -0
- package/lib/typescript/lib/module/sksg/Recorder/Core.d.ts +4 -0
- package/lib/typescript/lib/module/sksg/Recorder/DrawingContext.d.ts +16 -0
- package/lib/typescript/lib/module/sksg/Recorder/Player.d.ts +1 -0
- package/lib/typescript/lib/module/sksg/Recorder/Recorder.d.ts +44 -0
- package/lib/typescript/lib/module/sksg/Recorder/Recording.d.ts +4 -0
- package/lib/typescript/lib/module/sksg/Recorder/Visitor.d.ts +26 -0
- package/lib/typescript/lib/module/sksg/Recorder/commands/Box.d.ts +2 -0
- package/lib/typescript/lib/module/sksg/Recorder/commands/CTM.d.ts +1 -0
- package/lib/typescript/lib/module/sksg/Recorder/commands/ColorFilters.d.ts +3 -0
- package/lib/typescript/lib/module/sksg/Recorder/commands/ImageFilters.d.ts +5 -0
- package/lib/typescript/lib/module/sksg/Recorder/commands/Paint.d.ts +13 -0
- package/lib/typescript/lib/module/sksg/Recorder/commands/PathEffects.d.ts +3 -0
- package/lib/typescript/lib/module/sksg/Recorder/commands/Shaders.d.ts +2 -0
- package/lib/typescript/lib/module/sksg/{nodes/utils.d.ts → utils.d.ts} +1 -0
- package/lib/typescript/src/dom/types/Common.d.ts +6 -4
- package/lib/typescript/src/dom/types/ImageFilters.d.ts +1 -1
- package/lib/typescript/src/dom/types/Node.d.ts +0 -2
- package/lib/typescript/src/external/reanimated/index.d.ts +0 -1
- package/lib/typescript/src/external/reanimated/renderHelpers.d.ts +0 -1
- package/lib/typescript/src/skia/core/AnimatedImage.d.ts +1 -1
- package/lib/typescript/src/skia/core/Data.d.ts +1 -1
- package/lib/typescript/src/skia/types/Paint/Paint.d.ts +1 -0
- package/lib/typescript/src/skia/web/JsiSkPaint.d.ts +1 -0
- package/lib/typescript/src/sksg/Container.d.ts +3 -2
- package/lib/typescript/src/sksg/HostConfig.d.ts +2 -2
- package/lib/typescript/src/sksg/Node.d.ts +19 -0
- package/lib/typescript/src/sksg/Reconciler.d.ts +1 -1
- package/lib/typescript/src/sksg/Recorder/Core.d.ts +79 -0
- package/lib/typescript/src/sksg/Recorder/DrawingContext.d.ts +18 -0
- package/lib/typescript/src/sksg/Recorder/Player.d.ts +3 -0
- package/lib/typescript/src/sksg/Recorder/Recorder.d.ts +50 -0
- package/lib/typescript/src/sksg/Recorder/Recording.d.ts +7 -0
- package/lib/typescript/src/sksg/Recorder/Visitor.d.ts +5 -0
- package/lib/typescript/src/sksg/Recorder/commands/Box.d.ts +13 -0
- package/lib/typescript/src/sksg/Recorder/commands/CTM.d.ts +3 -0
- package/lib/typescript/src/sksg/Recorder/commands/ColorFilters.d.ts +6 -0
- package/lib/typescript/src/sksg/Recorder/commands/Drawing.d.ts +24 -0
- package/lib/typescript/src/sksg/Recorder/commands/ImageFilters.d.ts +12 -0
- package/lib/typescript/src/sksg/Recorder/commands/Paint.d.ts +4 -0
- package/lib/typescript/src/sksg/Recorder/commands/PathEffects.d.ts +6 -0
- package/lib/typescript/src/sksg/Recorder/commands/Shaders.d.ts +5 -0
- package/lib/typescript/src/sksg/{nodes/utils.d.ts → utils.d.ts} +3 -0
- package/package.json +1 -1
- package/src/__tests__/snapshots/image-filter/test-shadow.png +0 -0
- package/src/dom/types/Common.ts +7 -5
- package/src/dom/types/ImageFilters.ts +2 -1
- package/src/dom/types/Node.ts +0 -4
- package/src/external/reanimated/index.ts +0 -1
- package/src/external/reanimated/renderHelpers.ts +4 -44
- package/src/external/reanimated/useAnimatedImageValue.ts +4 -15
- package/src/renderer/__tests__/e2e/ColorFilters.spec.tsx +15 -0
- package/src/renderer/__tests__/e2e/Composition/ColorFilterComposition.spec.tsx +23 -2
- package/src/renderer/__tests__/e2e/ImageFilters.spec.tsx +91 -2
- package/src/renderer/__tests__/setup.tsx +1 -1
- package/src/skia/core/AnimatedImage.ts +2 -3
- package/src/skia/core/Data.ts +3 -9
- package/src/skia/types/Paint/Paint.ts +2 -0
- package/src/skia/web/JsiSkPaint.ts +4 -0
- package/src/sksg/Container.ts +35 -29
- package/src/sksg/HostConfig.ts +5 -50
- package/src/sksg/Node.ts +105 -0
- package/src/sksg/Recorder/Core.ts +171 -0
- package/src/sksg/Recorder/DrawingContext.ts +130 -0
- package/src/sksg/Recorder/Player.ts +160 -0
- package/src/sksg/Recorder/Recorder.ts +259 -0
- package/src/sksg/Recorder/Recording.ts +13 -0
- package/src/sksg/Recorder/Visitor.ts +324 -0
- package/src/sksg/Recorder/commands/Box.ts +63 -0
- package/src/sksg/Recorder/commands/CTM.ts +72 -0
- package/src/sksg/Recorder/commands/ColorFilters.ts +87 -0
- package/src/sksg/{nodes/drawings.ts → Recorder/commands/Drawing.ts} +29 -65
- package/src/sksg/Recorder/commands/ImageFilters.ts +255 -0
- package/src/sksg/Recorder/commands/Paint.ts +77 -0
- package/src/sksg/Recorder/commands/PathEffects.ts +169 -0
- package/src/sksg/{nodes/shaders.ts → Recorder/commands/Shaders.ts} +100 -26
- package/src/sksg/{nodes/utils.ts → utils.ts} +14 -1
- package/lib/commonjs/external/reanimated/useDerivedValueOnJS.d.ts +0 -1
- package/lib/commonjs/external/reanimated/useDerivedValueOnJS.js +0 -24
- package/lib/commonjs/external/reanimated/useDerivedValueOnJS.js.map +0 -1
- package/lib/commonjs/sksg/DeclarationContext.d.ts +0 -56
- package/lib/commonjs/sksg/DeclarationContext.js +0 -77
- package/lib/commonjs/sksg/DeclarationContext.js.map +0 -1
- package/lib/commonjs/sksg/DrawingContext.d.ts +0 -13
- package/lib/commonjs/sksg/DrawingContext.js +0 -172
- package/lib/commonjs/sksg/DrawingContext.js.map +0 -1
- package/lib/commonjs/sksg/__tests__/Declarations.spec.d.ts +0 -1
- package/lib/commonjs/sksg/__tests__/MockDeclaration.d.ts +0 -57
- package/lib/commonjs/sksg/nodes/Node.d.ts +0 -7
- package/lib/commonjs/sksg/nodes/Node.js +0 -6
- package/lib/commonjs/sksg/nodes/Node.js.map +0 -1
- package/lib/commonjs/sksg/nodes/colorFilters.d.ts +0 -10
- package/lib/commonjs/sksg/nodes/colorFilters.js +0 -79
- package/lib/commonjs/sksg/nodes/colorFilters.js.map +0 -1
- package/lib/commonjs/sksg/nodes/context.d.ts +0 -3
- package/lib/commonjs/sksg/nodes/context.js +0 -394
- package/lib/commonjs/sksg/nodes/context.js.map +0 -1
- package/lib/commonjs/sksg/nodes/drawings.d.ts +0 -30
- package/lib/commonjs/sksg/nodes/drawings.js.map +0 -1
- package/lib/commonjs/sksg/nodes/imageFilters.d.ts +0 -17
- package/lib/commonjs/sksg/nodes/imageFilters.js +0 -197
- package/lib/commonjs/sksg/nodes/imageFilters.js.map +0 -1
- package/lib/commonjs/sksg/nodes/index.d.ts +0 -3
- package/lib/commonjs/sksg/nodes/index.js +0 -39
- package/lib/commonjs/sksg/nodes/index.js.map +0 -1
- package/lib/commonjs/sksg/nodes/paint.d.ts +0 -3
- package/lib/commonjs/sksg/nodes/paint.js +0 -81
- package/lib/commonjs/sksg/nodes/paint.js.map +0 -1
- package/lib/commonjs/sksg/nodes/pathEffects.d.ts +0 -11
- package/lib/commonjs/sksg/nodes/pathEffects.js +0 -111
- package/lib/commonjs/sksg/nodes/pathEffects.js.map +0 -1
- package/lib/commonjs/sksg/nodes/shaders.d.ts +0 -11
- package/lib/commonjs/sksg/nodes/shaders.js.map +0 -1
- package/lib/commonjs/sksg/nodes/utils.js.map +0 -1
- package/lib/module/external/reanimated/useDerivedValueOnJS.d.ts +0 -1
- package/lib/module/external/reanimated/useDerivedValueOnJS.js +0 -16
- package/lib/module/external/reanimated/useDerivedValueOnJS.js.map +0 -1
- package/lib/module/sksg/DeclarationContext.d.ts +0 -56
- package/lib/module/sksg/DeclarationContext.js +0 -69
- package/lib/module/sksg/DeclarationContext.js.map +0 -1
- package/lib/module/sksg/DrawingContext.d.ts +0 -13
- package/lib/module/sksg/DrawingContext.js +0 -165
- package/lib/module/sksg/DrawingContext.js.map +0 -1
- package/lib/module/sksg/__tests__/Declarations.spec.d.ts +0 -1
- package/lib/module/sksg/__tests__/MockDeclaration.d.ts +0 -57
- package/lib/module/sksg/nodes/Node.d.ts +0 -7
- package/lib/module/sksg/nodes/Node.js +0 -2
- package/lib/module/sksg/nodes/Node.js.map +0 -1
- package/lib/module/sksg/nodes/colorFilters.d.ts +0 -10
- package/lib/module/sksg/nodes/colorFilters.js +0 -66
- package/lib/module/sksg/nodes/colorFilters.js.map +0 -1
- package/lib/module/sksg/nodes/context.d.ts +0 -3
- package/lib/module/sksg/nodes/context.js +0 -387
- package/lib/module/sksg/nodes/context.js.map +0 -1
- package/lib/module/sksg/nodes/drawings.d.ts +0 -30
- package/lib/module/sksg/nodes/drawings.js.map +0 -1
- package/lib/module/sksg/nodes/imageFilters.d.ts +0 -17
- package/lib/module/sksg/nodes/imageFilters.js.map +0 -1
- package/lib/module/sksg/nodes/index.d.ts +0 -3
- package/lib/module/sksg/nodes/index.js +0 -4
- package/lib/module/sksg/nodes/index.js.map +0 -1
- package/lib/module/sksg/nodes/paint.d.ts +0 -3
- package/lib/module/sksg/nodes/paint.js +0 -74
- package/lib/module/sksg/nodes/paint.js.map +0 -1
- package/lib/module/sksg/nodes/pathEffects.d.ts +0 -11
- package/lib/module/sksg/nodes/pathEffects.js +0 -97
- package/lib/module/sksg/nodes/pathEffects.js.map +0 -1
- package/lib/module/sksg/nodes/shaders.d.ts +0 -11
- package/lib/module/sksg/nodes/shaders.js.map +0 -1
- package/lib/module/sksg/nodes/utils.js.map +0 -1
- package/lib/typescript/lib/commonjs/external/reanimated/useDerivedValueOnJS.d.ts +0 -2
- package/lib/typescript/lib/commonjs/sksg/DeclarationContext.d.ts +0 -53
- package/lib/typescript/lib/commonjs/sksg/DrawingContext.d.ts +0 -22
- package/lib/typescript/lib/commonjs/sksg/nodes/Node.d.ts +0 -1
- package/lib/typescript/lib/commonjs/sksg/nodes/colorFilters.d.ts +0 -8
- package/lib/typescript/lib/commonjs/sksg/nodes/context.d.ts +0 -2
- package/lib/typescript/lib/commonjs/sksg/nodes/imageFilters.d.ts +0 -12
- package/lib/typescript/lib/commonjs/sksg/nodes/index.d.ts +0 -1
- package/lib/typescript/lib/commonjs/sksg/nodes/paint.d.ts +0 -2
- package/lib/typescript/lib/commonjs/sksg/nodes/pathEffects.d.ts +0 -9
- package/lib/typescript/lib/commonjs/sksg/nodes/shaders.d.ts +0 -10
- package/lib/typescript/lib/module/external/reanimated/useDerivedValueOnJS.d.ts +0 -1
- package/lib/typescript/lib/module/sksg/DeclarationContext.d.ts +0 -52
- package/lib/typescript/lib/module/sksg/DrawingContext.d.ts +0 -21
- package/lib/typescript/lib/module/sksg/nodes/Node.d.ts +0 -1
- package/lib/typescript/lib/module/sksg/nodes/colorFilters.d.ts +0 -7
- package/lib/typescript/lib/module/sksg/nodes/context.d.ts +0 -1
- package/lib/typescript/lib/module/sksg/nodes/imageFilters.d.ts +0 -11
- package/lib/typescript/lib/module/sksg/nodes/index.d.ts +0 -3
- package/lib/typescript/lib/module/sksg/nodes/paint.d.ts +0 -1
- package/lib/typescript/lib/module/sksg/nodes/pathEffects.d.ts +0 -8
- package/lib/typescript/lib/module/sksg/nodes/shaders.d.ts +0 -9
- package/lib/typescript/src/external/reanimated/useDerivedValueOnJS.d.ts +0 -1
- package/lib/typescript/src/sksg/DeclarationContext.d.ts +0 -56
- package/lib/typescript/src/sksg/DrawingContext.d.ts +0 -13
- package/lib/typescript/src/sksg/__tests__/Declarations.spec.d.ts +0 -1
- package/lib/typescript/src/sksg/__tests__/MockDeclaration.d.ts +0 -57
- package/lib/typescript/src/sksg/nodes/Node.d.ts +0 -7
- package/lib/typescript/src/sksg/nodes/colorFilters.d.ts +0 -10
- package/lib/typescript/src/sksg/nodes/context.d.ts +0 -3
- package/lib/typescript/src/sksg/nodes/drawings.d.ts +0 -30
- package/lib/typescript/src/sksg/nodes/imageFilters.d.ts +0 -17
- package/lib/typescript/src/sksg/nodes/index.d.ts +0 -3
- package/lib/typescript/src/sksg/nodes/paint.d.ts +0 -3
- package/lib/typescript/src/sksg/nodes/pathEffects.d.ts +0 -11
- package/lib/typescript/src/sksg/nodes/shaders.d.ts +0 -11
- package/src/external/reanimated/useDerivedValueOnJS.ts +0 -20
- package/src/sksg/DeclarationContext.ts +0 -85
- package/src/sksg/DrawingContext.ts +0 -226
- package/src/sksg/__tests__/Declarations.spec.tsx +0 -235
- package/src/sksg/__tests__/MockDeclaration.ts +0 -138
- package/src/sksg/nodes/Node.ts +0 -8
- package/src/sksg/nodes/colorFilters.ts +0 -79
- package/src/sksg/nodes/context.ts +0 -412
- package/src/sksg/nodes/imageFilters.ts +0 -235
- package/src/sksg/nodes/index.ts +0 -3
- package/src/sksg/nodes/paint.ts +0 -75
- package/src/sksg/nodes/pathEffects.ts +0 -118
- /package/lib/typescript/lib/commonjs/sksg/{nodes/drawings.d.ts → Recorder/commands/Drawing.d.ts} +0 -0
- /package/lib/typescript/lib/module/sksg/{nodes/drawings.d.ts → Recorder/commands/Drawing.d.ts} +0 -0
@@ -0,0 +1,76 @@
|
|
1
|
+
"use strict";
|
2
|
+
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
4
|
+
value: true
|
5
|
+
});
|
6
|
+
exports.pushColorFilter = exports.isPushColorFilter = exports.composeColorFilters = void 0;
|
7
|
+
var _nodes = require("../../../dom/nodes");
|
8
|
+
var _types = require("../../../dom/types");
|
9
|
+
var _types2 = require("../../../skia/types");
|
10
|
+
var _Core = require("../Core");
|
11
|
+
const isPushColorFilter = command => {
|
12
|
+
"worklet";
|
13
|
+
|
14
|
+
return command.type === _Core.CommandType.PushColorFilter;
|
15
|
+
};
|
16
|
+
exports.isPushColorFilter = isPushColorFilter;
|
17
|
+
const isColorFilter = (command, type) => {
|
18
|
+
"worklet";
|
19
|
+
|
20
|
+
return command.colorFilterType === type;
|
21
|
+
};
|
22
|
+
const composeColorFilters = ctx => {
|
23
|
+
"worklet";
|
24
|
+
|
25
|
+
if (ctx.colorFilters.length > 1) {
|
26
|
+
const outer = ctx.colorFilters.pop();
|
27
|
+
const inner = ctx.colorFilters.pop();
|
28
|
+
ctx.colorFilters.push(ctx.Skia.ColorFilter.MakeCompose(outer, inner));
|
29
|
+
}
|
30
|
+
};
|
31
|
+
exports.composeColorFilters = composeColorFilters;
|
32
|
+
const pushColorFilter = (ctx, command) => {
|
33
|
+
"worklet";
|
34
|
+
|
35
|
+
let cf;
|
36
|
+
if (isColorFilter(command, _types.NodeType.BlendColorFilter)) {
|
37
|
+
const {
|
38
|
+
props
|
39
|
+
} = command;
|
40
|
+
const {
|
41
|
+
mode
|
42
|
+
} = props;
|
43
|
+
const color = ctx.Skia.Color(props.color);
|
44
|
+
cf = ctx.Skia.ColorFilter.MakeBlend(color, _types2.BlendMode[(0, _nodes.enumKey)(mode)]);
|
45
|
+
} else if (isColorFilter(command, _types.NodeType.MatrixColorFilter)) {
|
46
|
+
const {
|
47
|
+
matrix
|
48
|
+
} = command.props;
|
49
|
+
cf = ctx.Skia.ColorFilter.MakeMatrix(matrix);
|
50
|
+
} else if (isColorFilter(command, _types.NodeType.LerpColorFilter)) {
|
51
|
+
const {
|
52
|
+
props
|
53
|
+
} = command;
|
54
|
+
const {
|
55
|
+
t
|
56
|
+
} = props;
|
57
|
+
const second = ctx.colorFilters.pop();
|
58
|
+
const first = ctx.colorFilters.pop();
|
59
|
+
if (!first || !second) {
|
60
|
+
throw new Error("LerpColorFilter requires two color filters");
|
61
|
+
}
|
62
|
+
cf = ctx.Skia.ColorFilter.MakeLerp(t, first, second);
|
63
|
+
} else if (isColorFilter(command, _types.NodeType.LumaColorFilter)) {
|
64
|
+
cf = ctx.Skia.ColorFilter.MakeLumaColorFilter();
|
65
|
+
} else if (isColorFilter(command, _types.NodeType.LinearToSRGBGammaColorFilter)) {
|
66
|
+
cf = ctx.Skia.ColorFilter.MakeLinearToSRGBGamma();
|
67
|
+
} else if (isColorFilter(command, _types.NodeType.SRGBToLinearGammaColorFilter)) {
|
68
|
+
cf = ctx.Skia.ColorFilter.MakeSRGBToLinearGamma();
|
69
|
+
}
|
70
|
+
if (!cf) {
|
71
|
+
throw new Error(`Unknown color filter type: ${command.colorFilterType}`);
|
72
|
+
}
|
73
|
+
ctx.colorFilters.push(cf);
|
74
|
+
};
|
75
|
+
exports.pushColorFilter = pushColorFilter;
|
76
|
+
//# sourceMappingURL=ColorFilters.js.map
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"names":["_nodes","require","_types","_types2","_Core","isPushColorFilter","command","type","CommandType","PushColorFilter","exports","isColorFilter","colorFilterType","composeColorFilters","ctx","colorFilters","length","outer","pop","inner","push","Skia","ColorFilter","MakeCompose","pushColorFilter","cf","NodeType","BlendColorFilter","props","mode","color","Color","MakeBlend","BlendMode","enumKey","MatrixColorFilter","matrix","MakeMatrix","LerpColorFilter","t","second","first","Error","MakeLerp","LumaColorFilter","MakeLumaColorFilter","LinearToSRGBGammaColorFilter","MakeLinearToSRGBGamma","SRGBToLinearGammaColorFilter","MakeSRGBToLinearGamma"],"sources":["ColorFilters.ts"],"sourcesContent":["import { enumKey } from \"../../../dom/nodes\";\nimport type {\n BlendColorFilterProps,\n LerpColorFilterProps,\n MatrixColorFilterProps,\n} from \"../../../dom/types\";\nimport { NodeType } from \"../../../dom/types\";\nimport type { SkColorFilter } from \"../../../skia/types\";\nimport { BlendMode } from \"../../../skia/types\";\nimport { CommandType } from \"../Core\";\nimport type { Command } from \"../Core\";\nimport type { DrawingContext } from \"../DrawingContext\";\n\nexport const isPushColorFilter = (\n command: Command\n): command is Command<CommandType.PushColorFilter> => {\n \"worklet\";\n return command.type === CommandType.PushColorFilter;\n};\n\ntype Props = {\n [NodeType.BlendColorFilter]: BlendColorFilterProps;\n [NodeType.MatrixColorFilter]: MatrixColorFilterProps;\n [NodeType.LerpColorFilter]: LerpColorFilterProps;\n [NodeType.LumaColorFilter]: Record<string, never>;\n [NodeType.LinearToSRGBGammaColorFilter]: Record<string, never>;\n [NodeType.SRGBToLinearGammaColorFilter]: Record<string, never>;\n};\n\ninterface PushColorFilter<T extends keyof Props>\n extends Command<CommandType.PushColorFilter> {\n colorFilterType: T;\n props: Props[T];\n}\n\nconst isColorFilter = <T extends keyof Props>(\n command: Command<CommandType.PushColorFilter>,\n type: T\n): command is PushColorFilter<T> => {\n \"worklet\";\n return command.colorFilterType === type;\n};\n\nexport const composeColorFilters = (ctx: DrawingContext) => {\n \"worklet\";\n if (ctx.colorFilters.length > 1) {\n const outer = ctx.colorFilters.pop()!;\n const inner = ctx.colorFilters.pop()!;\n ctx.colorFilters.push(ctx.Skia.ColorFilter.MakeCompose(outer, inner));\n }\n};\n\nexport const pushColorFilter = (\n ctx: DrawingContext,\n command: Command<CommandType.PushColorFilter>\n) => {\n \"worklet\";\n let cf: SkColorFilter | undefined;\n if (isColorFilter(command, NodeType.BlendColorFilter)) {\n const { props } = command;\n const { mode } = props;\n const color = ctx.Skia.Color(props.color);\n cf = ctx.Skia.ColorFilter.MakeBlend(color, BlendMode[enumKey(mode)]);\n } else if (isColorFilter(command, NodeType.MatrixColorFilter)) {\n const { matrix } = command.props;\n cf = ctx.Skia.ColorFilter.MakeMatrix(matrix);\n } else if (isColorFilter(command, NodeType.LerpColorFilter)) {\n const { props } = command;\n const { t } = props;\n const second = ctx.colorFilters.pop();\n const first = ctx.colorFilters.pop();\n if (!first || !second) {\n throw new Error(\"LerpColorFilter requires two color filters\");\n }\n cf = ctx.Skia.ColorFilter.MakeLerp(t, first, second);\n } else if (isColorFilter(command, NodeType.LumaColorFilter)) {\n cf = ctx.Skia.ColorFilter.MakeLumaColorFilter();\n } else if (isColorFilter(command, NodeType.LinearToSRGBGammaColorFilter)) {\n cf = ctx.Skia.ColorFilter.MakeLinearToSRGBGamma();\n } else if (isColorFilter(command, NodeType.SRGBToLinearGammaColorFilter)) {\n cf = ctx.Skia.ColorFilter.MakeSRGBToLinearGamma();\n }\n if (!cf) {\n throw new Error(`Unknown color filter type: ${command.colorFilterType}`);\n }\n ctx.colorFilters.push(cf);\n};\n"],"mappings":";;;;;;AAAA,IAAAA,MAAA,GAAAC,OAAA;AAMA,IAAAC,MAAA,GAAAD,OAAA;AAEA,IAAAE,OAAA,GAAAF,OAAA;AACA,IAAAG,KAAA,GAAAH,OAAA;AAIO,MAAMI,iBAAiB,GAC5BC,OAAgB,IACoC;EACpD,SAAS;;EACT,OAAOA,OAAO,CAACC,IAAI,KAAKC,iBAAW,CAACC,eAAe;AACrD,CAAC;AAACC,OAAA,CAAAL,iBAAA,GAAAA,iBAAA;AAiBF,MAAMM,aAAa,GAAGA,CACpBL,OAA6C,EAC7CC,IAAO,KAC2B;EAClC,SAAS;;EACT,OAAOD,OAAO,CAACM,eAAe,KAAKL,IAAI;AACzC,CAAC;AAEM,MAAMM,mBAAmB,GAAIC,GAAmB,IAAK;EAC1D,SAAS;;EACT,IAAIA,GAAG,CAACC,YAAY,CAACC,MAAM,GAAG,CAAC,EAAE;IAC/B,MAAMC,KAAK,GAAGH,GAAG,CAACC,YAAY,CAACG,GAAG,CAAC,CAAE;IACrC,MAAMC,KAAK,GAAGL,GAAG,CAACC,YAAY,CAACG,GAAG,CAAC,CAAE;IACrCJ,GAAG,CAACC,YAAY,CAACK,IAAI,CAACN,GAAG,CAACO,IAAI,CAACC,WAAW,CAACC,WAAW,CAACN,KAAK,EAAEE,KAAK,CAAC,CAAC;EACvE;AACF,CAAC;AAACT,OAAA,CAAAG,mBAAA,GAAAA,mBAAA;AAEK,MAAMW,eAAe,GAAGA,CAC7BV,GAAmB,EACnBR,OAA6C,KAC1C;EACH,SAAS;;EACT,IAAImB,EAA6B;EACjC,IAAId,aAAa,CAACL,OAAO,EAAEoB,eAAQ,CAACC,gBAAgB,CAA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AmB,CAAC,CAAC;EACjD,CAAC,MAAM,IAAIlC,aAAa,CAACL,OAAO,EAAEoB,eAAQ,CAACoB,4BAA4B,CAAC,EAAE;IACxErB,EAAE,GAAGX,GAAG,CAACO,IAAI,CAACC,WAAW,CAACyB,qBAAqB,CAAC,CAAC;EACnD,CAAC,MAAM,IAAIpC,aAAa,CAACL,OAAO,EAAEoB,eAAQ,CAACsB,4BAA4B,CAAC,EAAE;IACxEvB,EAAE,GAAGX,GAAG,CAACO,IAAI,CAACC,WAAW,CAAC2B,qBAAqB,CAAC,CAAC;EACnD;EACA,IAAI,CAACxB,EAAE,EAAE;IACP,MAAM,IAAIiB,KAAK,CAAC,8BAA8BpC,OAAO,CAACM,eAAe,EAAE,CAAC;EAC1E;EACAE,GAAG,CAACC,YAAY,CAACK,IAAI,CAACK,EAAE,CAAC;AAC3B,CAAC;AAACf,OAAA,CAAAc,eAAA,GAAAA,eAAA","ignoreList":[]}
|
@@ -0,0 +1,24 @@
|
|
1
|
+
import type { AtlasProps, BoxProps, CircleProps, DiffRectProps, DrawingNodeProps, GlyphsProps, ImageProps, ImageSVGProps, LineProps, OvalProps, ParagraphProps, PatchProps, PathProps, PictureProps, PointsProps, RectProps, RoundedRectProps, TextBlobProps, TextPathProps, TextProps, VerticesProps } from "../../../dom/types";
|
2
|
+
import type { Node } from "../../Node";
|
3
|
+
import type { DrawingContext } from "../DrawingContext";
|
4
|
+
export declare const drawLine: (ctx: DrawingContext, props: LineProps) => void;
|
5
|
+
export declare const drawOval: (ctx: DrawingContext, props: OvalProps) => void;
|
6
|
+
export declare const drawBox: (ctx: DrawingContext, props: BoxProps, children: Node<any>[]) => void;
|
7
|
+
export declare const drawImage: (ctx: DrawingContext, props: ImageProps) => void;
|
8
|
+
export declare const drawPoints: (ctx: DrawingContext, props: PointsProps) => void;
|
9
|
+
export declare const drawVertices: (ctx: DrawingContext, props: VerticesProps) => void;
|
10
|
+
export declare const drawDiffRect: (ctx: DrawingContext, props: DiffRectProps) => void;
|
11
|
+
export declare const drawTextPath: (ctx: DrawingContext, props: TextPathProps) => void;
|
12
|
+
export declare const drawText: (ctx: DrawingContext, props: TextProps) => void;
|
13
|
+
export declare const drawPatch: (ctx: DrawingContext, props: PatchProps) => void;
|
14
|
+
export declare const drawPath: (ctx: DrawingContext, props: PathProps) => void;
|
15
|
+
export declare const drawRect: (ctx: DrawingContext, props: RectProps) => void;
|
16
|
+
export declare const drawRRect: (ctx: DrawingContext, props: RoundedRectProps) => void;
|
17
|
+
export declare const drawTextBlob: (ctx: DrawingContext, props: TextBlobProps) => void;
|
18
|
+
export declare const drawGlyphs: (ctx: DrawingContext, props: GlyphsProps) => void;
|
19
|
+
export declare const drawImageSVG: (ctx: DrawingContext, props: ImageSVGProps) => void;
|
20
|
+
export declare const drawParagraph: (ctx: DrawingContext, props: ParagraphProps) => void;
|
21
|
+
export declare const drawPicture: (ctx: DrawingContext, props: PictureProps) => void;
|
22
|
+
export declare const drawAtlas: (ctx: DrawingContext, props: AtlasProps) => void;
|
23
|
+
export declare const drawCircle: (ctx: DrawingContext, props: CircleProps) => void;
|
24
|
+
export declare const drawFill: (ctx: DrawingContext, _props: DrawingNodeProps) => void;
|
@@ -4,10 +4,10 @@ Object.defineProperty(exports, "__esModule", {
|
|
4
4
|
value: true
|
5
5
|
});
|
6
6
|
exports.drawVertices = exports.drawTextPath = exports.drawTextBlob = exports.drawText = exports.drawRect = exports.drawRRect = exports.drawPoints = exports.drawPicture = exports.drawPath = exports.drawPatch = exports.drawParagraph = exports.drawOval = exports.drawLine = exports.drawImageSVG = exports.drawImage = exports.drawGlyphs = exports.drawFill = exports.drawDiffRect = exports.drawCircle = exports.drawBox = exports.drawAtlas = void 0;
|
7
|
-
var _nodes = require("
|
8
|
-
var _processors = require("
|
9
|
-
var _types = require("
|
10
|
-
var _utils = require("
|
7
|
+
var _nodes = require("../../../dom/nodes");
|
8
|
+
var _processors = require("../../../renderer/processors");
|
9
|
+
var _types = require("../../../skia/types");
|
10
|
+
var _utils = require("../../utils");
|
11
11
|
const drawLine = (ctx, props) => {
|
12
12
|
"worklet";
|
13
13
|
|
@@ -395,4 +395,4 @@ const drawFill = (ctx, _props) => {
|
|
395
395
|
ctx.canvas.drawPaint(ctx.paint);
|
396
396
|
};
|
397
397
|
exports.drawFill = drawFill;
|
398
|
-
//# sourceMappingURL=
|
398
|
+
//# sourceMappingURL=Drawing.js.map
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"names":["_nodes","require","_processors","_types","_utils","drawLine","ctx","props","p1","p2","canvas","x","y","paint","exports","drawOval","rect","processRect","Skia","drawBox","children","box","defaultBox","opacity","getAlphaf","isRRect","RRectXY","shadows","map","node","type","NodeType","BoxShadow","materialize","filter","n","shadow","inner","color","blur","spread","dx","dy","lPaint","Paint","setColor","Color","setAlphaf","setMaskFilter","MaskFilter","MakeBlur","BlurStyle","Normal","drawRRect","inflate","delta","Point","Math","abs","save","clipRRect","ClipOp","Intersect","deflate","outer","drawDRRect","restore","drawImage","image","_props$fit","fit","src","dst","fitRects","width","height","drawImageRect","drawPoints","points","mode","PointMode","enumKey","drawVertices","textures","colors","indices","blendMode","vertexMode","VertexMode","Triangles","vertices","MakeVertices","c","undefined","defaultBlendMode","BlendMode","DstOver","SrcOver","blend","drawDiffRect","drawTextPath","path","processPath","font","initialOffset","text","ids","getGlyphIDs","widths","getGlyphWidths","rsx","meas","ContourMeasureIter","cont","next","dist","i","length","substring","p","t","getPosTan","adjustedX","adjustedY","push","RSXform","derived","TextBlob","MakeFromRSXform","drawTextBlob","drawText","drawPatch","texture","patch","pos","c2","c1","drawPath","start","trimStart","end","trimEnd","fillType","stroke","pathProps","saturate","hasStartOffset","hasEndOffset","hasStrokeOptions","hasFillType","willMutatePath","pristinePath","copy","setFillType","FillType","trim","drawRect","processRRect","blob","drawGlyphs","glyphs","reduce","acc","glyph","id","positions","drawImageSVG","svg","translate","drawSvg","drawParagraph","paragraph","layout","drawPicture","picture","drawAtlas","sprites","transforms","drawCircle","processCircle","r","drawFill","_props","drawPaint"],"sources":["Drawing.ts"],"sourcesContent":["import {\n deflate,\n enumKey,\n fitRects,\n inflate,\n NodeType,\n processCircle,\n processPath,\n processRect,\n processRRect,\n} from \"../../../dom/nodes\";\nimport type {\n AtlasProps,\n BoxProps,\n BoxShadowProps,\n CircleProps,\n DiffRectProps,\n DrawingNodeProps,\n GlyphsProps,\n ImageProps,\n ImageSVGProps,\n LineProps,\n OvalProps,\n ParagraphProps,\n PatchProps,\n PathProps,\n PictureProps,\n PointsProps,\n RectProps,\n RoundedRectProps,\n TextBlobProps,\n TextPathProps,\n TextProps,\n VerticesProps,\n} from \"../../../dom/types\";\nimport { saturate } from \"../../../renderer/processors\";\nimport type { SkPoint, SkRSXform } from \"../../../skia/types\";\nimport {\n BlendMode,\n BlurStyle,\n ClipOp,\n FillType,\n isRRect,\n PointMode,\n VertexMode,\n} from \"../../../skia/types\";\nimport type { Node } from \"../../Node\";\nimport { materialize } from \"../../utils\";\nimport type { DrawingContext } from \"../DrawingContext\";\n\nexport const drawLine = (ctx: DrawingContext, props: LineProps) => {\n \"worklet\";\n const { p1, p2 } = props;\n ctx.canvas.drawLine(p1.x, p1.y, p2.x, p2.y, ctx.paint);\n};\n\nexport const drawOval = (ctx: DrawingContext, props: OvalProps) => {\n \"worklet\";\n const rect = processRect(ctx.Skia, props);\n ctx.canvas.drawOval(rect, ctx.paint);\n};\n\nexport const drawBox = (\n ctx: DrawingContext,\n props: BoxProps,\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n children: Node<any>[]\n) => {\n \"worklet\";\n const { paint, Skia, canvas } = ctx;\n const { box: defaultBox } = props;\n const opacity = paint.getAlphaf();\n const box = isRRect(defaultBox) ? defaultBox : Skia.RRectXY(defaultBox, 0, 0);\n const shadows = children\n .map((node) => {\n if (node.type === NodeType.BoxShadow) {\n return materialize(node.props);\n }\n return null;\n })\n .filter((n): n is BoxShadowProps => n !== null);\n shadows\n .filter((shadow) => !shadow.inner)\n .map((shadow) => {\n const { color = \"black\", blur, spread = 0, dx = 0, dy = 0 } = shadow;\n const lPaint = Skia.Paint();\n lPaint.setColor(Skia.Color(color));\n lPaint.setAlphaf(paint.getAlphaf() * opacity);\n lPaint.setMaskFilter(\n Skia.MaskFilter.MakeBlur(BlurStyle.Normal, blur, true)\n );\n canvas.drawRRect(inflate(Skia, box, spread, spread, dx, dy), lPaint);\n });\n\n canvas.drawRRect(box, paint);\n\n shadows\n .filter((shadow) => shadow.inner)\n .map((shadow) => {\n const { color = \"black\", blur, spread = 0, dx = 0, dy = 0 } = shadow;\n const delta = Skia.Point(10 + Math.abs(dx), 10 + Math.abs(dy));\n canvas.save();\n canvas.clipRRect(box, ClipOp.Intersect, false);\n const lPaint = Skia.Paint();\n lPaint.setColor(Skia.Color(color));\n lPaint.setAlphaf(paint.getAlphaf() * opacity);\n\n lPaint.setMaskFilter(\n Skia.MaskFilter.MakeBlur(BlurStyle.Normal, blur, true)\n );\n const inner = deflate(Skia, box, spread, spread, dx, dy);\n const outer = inflate(Skia, box, delta.x, delta.y);\n canvas.drawDRRect(outer, inner, lPaint);\n canvas.restore();\n });\n};\n\nexport const drawImage = (ctx: DrawingContext, props: ImageProps) => {\n \"worklet\";\n const { image } = props;\n if (image) {\n const fit = props.fit ?? \"contain\";\n const rect = processRect(ctx.Skia, props);\n const { src, dst } = fitRects(\n fit,\n {\n x: 0,\n y: 0,\n width: image.width(),\n height: image.height(),\n },\n rect\n );\n ctx.canvas.drawImageRect(image, src, dst, ctx.paint);\n }\n};\n\nexport const drawPoints = (ctx: DrawingContext, props: PointsProps) => {\n \"worklet\";\n const { points, mode } = props;\n ctx.canvas.drawPoints(PointMode[enumKey(mode)], points, ctx.paint);\n};\n\nexport const drawVertices = (ctx: DrawingContext, props: VerticesProps) => {\n \"worklet\";\n const { mode, textures, colors, indices, blendMode } = props;\n const vertexMode = mode ? VertexMode[enumKey(mode)] : VertexMode.Triangles;\n const vertices = ctx.Skia.MakeVertices(\n vertexMode,\n props.vertices,\n textures,\n colors ? colors.map((c) => ctx.Skia.Color(c)) : undefined,\n indices\n );\n const defaultBlendMode = colors ? BlendMode.DstOver : BlendMode.SrcOver;\n const blend = blendMode ? BlendMode[enumKey(blendMode)] : defaultBlendMode;\n\n ctx.canvas.drawVertices(vertices, blend, ctx.paint);\n};\n\nexport const drawDiffRect = (ctx: DrawingContext, props: DiffRectProps) => {\n \"worklet\";\n const { outer, inner } = props;\n ctx.canvas.drawDRRect(outer, inner, ctx.paint);\n};\n\nexport const drawTextPath = (ctx: DrawingContext, props: TextPathProps) => {\n \"worklet\";\n const path = processPath(ctx.Skia, props.path);\n const { font, initialOffset } = props;\n if (font) {\n let { text } = props;\n const ids = font.getGlyphIDs(text);\n const widths = font.getGlyphWidths(ids);\n const rsx: SkRSXform[] = [];\n const meas = ctx.Skia.ContourMeasureIter(path, false, 1);\n let cont = meas.next();\n let dist = initialOffset;\n for (let i = 0; i < text.length && cont; i++) {\n const width = widths[i];\n dist += width / 2;\n if (dist > cont.length()) {\n // jump to next contour\n cont = meas.next();\n if (!cont) {\n // We have come to the end of the path - terminate the string\n // right here.\n text = text.substring(0, i);\n break;\n }\n dist = width / 2;\n }\n // Gives us the (x, y) coordinates as well as the cos/sin of the tangent\n // line at that position.\n const [p, t] = cont.getPosTan(dist);\n const adjustedX = p.x - (width / 2) * t.x;\n const adjustedY = p.y - (width / 2) * t.y;\n rsx.push(ctx.Skia.RSXform(t.x, t.y, adjustedX, adjustedY));\n dist += width / 2;\n }\n const derived = ctx.Skia.TextBlob.MakeFromRSXform(text, rsx, font);\n ctx.canvas.drawTextBlob(derived, 0, 0, ctx.paint);\n }\n};\n\nexport const drawText = (ctx: DrawingContext, props: TextProps) => {\n \"worklet\";\n const { text, x, y, font } = props;\n if (font != null) {\n ctx.canvas.drawText(text, x, y, ctx.paint, font);\n }\n};\n\nexport const drawPatch = (ctx: DrawingContext, props: PatchProps) => {\n \"worklet\";\n const { texture, blendMode, patch } = props;\n const defaultBlendMode = props.colors ? BlendMode.DstOver : BlendMode.SrcOver;\n const mode = blendMode ? BlendMode[enumKey(blendMode)] : defaultBlendMode;\n // Patch requires a path with the following constraints:\n // M tl\n // C c1 c2 br\n // C c1 c2 bl\n // C c1 c2 tl (the redundant point in the last command is removed)\n\n const points = [\n patch[0].pos,\n patch[0].c2,\n patch[1].c1,\n patch[1].pos,\n patch[1].c2,\n patch[2].c1,\n patch[2].pos,\n patch[2].c2,\n patch[3].c1,\n patch[3].pos,\n patch[3].c2,\n patch[0].c1,\n ];\n const colors = props.colors\n ? props.colors.map((c) => ctx.Skia.Color(c))\n : undefined;\n ctx.canvas.drawPatch(points, colors, texture, mode, ctx.paint);\n};\n\nexport const drawPath = (ctx: DrawingContext, props: PathProps) => {\n \"worklet\";\n const {\n start: trimStart,\n end: trimEnd,\n fillType,\n stroke,\n ...pathProps\n } = props;\n const start = saturate(trimStart);\n const end = saturate(trimEnd);\n const hasStartOffset = start !== 0;\n const hasEndOffset = end !== 1;\n const hasStrokeOptions = stroke !== undefined;\n const hasFillType = !!fillType;\n const willMutatePath =\n hasStartOffset || hasEndOffset || hasStrokeOptions || hasFillType;\n const pristinePath = processPath(ctx.Skia, pathProps.path);\n const path = willMutatePath ? pristinePath.copy() : pristinePath;\n if (hasFillType) {\n path.setFillType(FillType[enumKey(fillType)]);\n }\n if (hasStrokeOptions) {\n path.stroke(stroke);\n }\n if (hasStartOffset || hasEndOffset) {\n path.trim(start, end, false);\n }\n ctx.canvas.drawPath(path, ctx.paint);\n};\n\nexport const drawRect = (ctx: DrawingContext, props: RectProps) => {\n \"worklet\";\n const derived = processRect(ctx.Skia, props);\n ctx.canvas.drawRect(derived, ctx.paint);\n};\n\nexport const drawRRect = (ctx: DrawingContext, props: RoundedRectProps) => {\n \"worklet\";\n const derived = processRRect(ctx.Skia, props);\n ctx.canvas.drawRRect(derived, ctx.paint);\n};\n\nexport const drawTextBlob = (ctx: DrawingContext, props: TextBlobProps) => {\n \"worklet\";\n const { blob, x, y } = props;\n ctx.canvas.drawTextBlob(blob, x, y, ctx.paint);\n};\n\ninterface ProcessedGlyphs {\n glyphs: number[];\n positions: SkPoint[];\n}\n\nexport const drawGlyphs = (ctx: DrawingContext, props: GlyphsProps) => {\n \"worklet\";\n const derived = props.glyphs.reduce<ProcessedGlyphs>(\n (acc, glyph) => {\n const { id, pos } = glyph;\n acc.glyphs.push(id);\n acc.positions.push(pos);\n return acc;\n },\n { glyphs: [], positions: [] }\n );\n const { glyphs, positions } = derived;\n const { x, y, font } = props;\n if (font) {\n ctx.canvas.drawGlyphs(glyphs, positions, x, y, font, ctx.paint);\n }\n};\n\nexport const drawImageSVG = (ctx: DrawingContext, props: ImageSVGProps) => {\n \"worklet\";\n const { canvas } = ctx;\n const { svg } = props;\n const { x, y, width, height } = props.rect\n ? props.rect\n : { x: props.x, y: props.y, width: props.width, height: props.height };\n if (svg === null) {\n return;\n }\n canvas.save();\n if (x && y) {\n canvas.translate(x, y);\n }\n canvas.drawSvg(svg, width, height);\n canvas.restore();\n};\n\nexport const drawParagraph = (ctx: DrawingContext, props: ParagraphProps) => {\n \"worklet\";\n const { paragraph, x, y, width } = props;\n if (paragraph) {\n paragraph.layout(width);\n paragraph.paint(ctx.canvas, x, y);\n }\n};\n\nexport const drawPicture = (ctx: DrawingContext, props: PictureProps) => {\n \"worklet\";\n const { picture } = props;\n ctx.canvas.drawPicture(picture);\n};\n\nexport const drawAtlas = (ctx: DrawingContext, props: AtlasProps) => {\n \"worklet\";\n const { image, sprites, transforms, colors, blendMode } = props;\n const blend = blendMode ? BlendMode[enumKey(blendMode)] : undefined;\n if (image) {\n ctx.canvas.drawAtlas(image, sprites, transforms, ctx.paint, blend, colors);\n }\n};\n\nexport const drawCircle = (ctx: DrawingContext, props: CircleProps) => {\n \"worklet\";\n const { c } = processCircle(props);\n const { r } = props;\n ctx.canvas.drawCircle(c.x, c.y, r, ctx.paint);\n};\n\nexport const drawFill = (ctx: DrawingContext, _props: DrawingNodeProps) => {\n \"worklet\";\n ct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AC,EAAEiF,CAAC,CAAChF,CAAC,EAAEwK,CAAC,EAAE9K,GAAG,CAACO,KAAK,CAAC;AAC/C,CAAC;AAACC,OAAA,CAAAoK,UAAA,GAAAA,UAAA;AAEK,MAAMG,QAAQ,GAAGA,CAAC/K,GAAmB,EAAEgL,MAAwB,KAAK;EACzE,SAAS;;EACThL,GAAG,CAACI,MAAM,CAAC6K,SAAS,CAACjL,GAAG,CAACO,KAAK,CAAC;AACjC,CAAC;AAACC,OAAA,CAAAuK,QAAA,GAAAA,QAAA","ignoreList":[]}
|
@@ -0,0 +1,12 @@
|
|
1
|
+
import type { BlurMaskFilterProps } from "../../../dom/types";
|
2
|
+
import type { Command } from "../Core";
|
3
|
+
import { CommandType } from "../Core";
|
4
|
+
import type { DrawingContext } from "../DrawingContext";
|
5
|
+
export declare enum MorphologyOperator {
|
6
|
+
Erode = 0,
|
7
|
+
Dilate = 1
|
8
|
+
}
|
9
|
+
export declare const composeImageFilters: (ctx: DrawingContext) => void;
|
10
|
+
export declare const setBlurMaskFilter: (ctx: DrawingContext, props: BlurMaskFilterProps) => void;
|
11
|
+
export declare const isPushImageFilter: (command: Command) => command is Command<CommandType.PushImageFilter>;
|
12
|
+
export declare const pushImageFilter: (ctx: DrawingContext, command: Command<CommandType.PushImageFilter>) => void;
|
@@ -0,0 +1,183 @@
|
|
1
|
+
"use strict";
|
2
|
+
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
4
|
+
value: true
|
5
|
+
});
|
6
|
+
exports.setBlurMaskFilter = exports.pushImageFilter = exports.isPushImageFilter = exports.composeImageFilters = exports.MorphologyOperator = void 0;
|
7
|
+
var _nodes = require("../../../dom/nodes");
|
8
|
+
var _types = require("../../../dom/types");
|
9
|
+
var _types2 = require("../../../skia/types");
|
10
|
+
var _utils = require("../../utils");
|
11
|
+
var _Core = require("../Core");
|
12
|
+
let MorphologyOperator = exports.MorphologyOperator = /*#__PURE__*/function (MorphologyOperator) {
|
13
|
+
MorphologyOperator[MorphologyOperator["Erode"] = 0] = "Erode";
|
14
|
+
MorphologyOperator[MorphologyOperator["Dilate"] = 1] = "Dilate";
|
15
|
+
return MorphologyOperator;
|
16
|
+
}({});
|
17
|
+
const Black = Float32Array.of(0, 0, 0, 1);
|
18
|
+
const MakeInnerShadow = (Skia, shadowOnly, dx, dy, sigmaX, sigmaY, color, input) => {
|
19
|
+
"worklet";
|
20
|
+
|
21
|
+
const sourceGraphic = Skia.ImageFilter.MakeColorFilter(Skia.ColorFilter.MakeBlend(Black, _types2.BlendMode.Dst), null);
|
22
|
+
const sourceAlpha = Skia.ImageFilter.MakeColorFilter(Skia.ColorFilter.MakeBlend(Black, _types2.BlendMode.SrcIn), null);
|
23
|
+
const f1 = Skia.ImageFilter.MakeColorFilter(Skia.ColorFilter.MakeBlend(color, _types2.BlendMode.SrcOut), null);
|
24
|
+
const f2 = Skia.ImageFilter.MakeOffset(dx, dy, f1);
|
25
|
+
const f3 = Skia.ImageFilter.MakeBlur(sigmaX, sigmaY, _types2.TileMode.Decal, f2);
|
26
|
+
const f4 = Skia.ImageFilter.MakeBlend(_types2.BlendMode.SrcIn, sourceAlpha, f3);
|
27
|
+
if (shadowOnly) {
|
28
|
+
return f4;
|
29
|
+
}
|
30
|
+
return Skia.ImageFilter.MakeCompose(input, Skia.ImageFilter.MakeBlend(_types2.BlendMode.SrcOver, sourceGraphic, f4));
|
31
|
+
};
|
32
|
+
const declareBlurImageFilter = (ctx, props) => {
|
33
|
+
"worklet";
|
34
|
+
|
35
|
+
const {
|
36
|
+
mode,
|
37
|
+
blur
|
38
|
+
} = props;
|
39
|
+
const sigma = (0, _nodes.processRadius)(ctx.Skia, blur);
|
40
|
+
const imgf = ctx.Skia.ImageFilter.MakeBlur(sigma.x, sigma.y, _types2.TileMode[(0, _nodes.enumKey)(mode)], null);
|
41
|
+
ctx.imageFilters.push(imgf);
|
42
|
+
};
|
43
|
+
const declareMorphologyImageFilter = (ctx, props) => {
|
44
|
+
"worklet";
|
45
|
+
|
46
|
+
const {
|
47
|
+
operator
|
48
|
+
} = props;
|
49
|
+
const r = (0, _nodes.processRadius)(ctx.Skia, props.radius);
|
50
|
+
let imgf;
|
51
|
+
if (MorphologyOperator[(0, _nodes.enumKey)(operator)] === MorphologyOperator.Erode) {
|
52
|
+
imgf = ctx.Skia.ImageFilter.MakeErode(r.x, r.y, null);
|
53
|
+
} else {
|
54
|
+
imgf = ctx.Skia.ImageFilter.MakeDilate(r.x, r.y, null);
|
55
|
+
}
|
56
|
+
ctx.imageFilters.push(imgf);
|
57
|
+
};
|
58
|
+
const declareOffsetImageFilter = (ctx, props) => {
|
59
|
+
"worklet";
|
60
|
+
|
61
|
+
const {
|
62
|
+
x,
|
63
|
+
y
|
64
|
+
} = props;
|
65
|
+
const imgf = ctx.Skia.ImageFilter.MakeOffset(x, y, null);
|
66
|
+
ctx.imageFilters.push(imgf);
|
67
|
+
};
|
68
|
+
const declareDropShadowImageFilter = (ctx, props) => {
|
69
|
+
"worklet";
|
70
|
+
|
71
|
+
const {
|
72
|
+
dx,
|
73
|
+
dy,
|
74
|
+
blur,
|
75
|
+
shadowOnly,
|
76
|
+
color: cl,
|
77
|
+
inner
|
78
|
+
} = props;
|
79
|
+
const color = ctx.Skia.Color(cl);
|
80
|
+
let factory;
|
81
|
+
if (inner) {
|
82
|
+
factory = MakeInnerShadow.bind(null, ctx.Skia, shadowOnly);
|
83
|
+
} else {
|
84
|
+
factory = shadowOnly ? ctx.Skia.ImageFilter.MakeDropShadowOnly.bind(ctx.Skia.ImageFilter) : ctx.Skia.ImageFilter.MakeDropShadow.bind(ctx.Skia.ImageFilter);
|
85
|
+
}
|
86
|
+
const imgf = factory(dx, dy, blur, blur, color, null);
|
87
|
+
ctx.imageFilters.push(imgf);
|
88
|
+
};
|
89
|
+
const declareBlendImageFilter = (ctx, props) => {
|
90
|
+
"worklet";
|
91
|
+
|
92
|
+
const blend = _types2.BlendMode[(0, _nodes.enumKey)(props.mode)];
|
93
|
+
// Blend ImageFilters
|
94
|
+
const imageFilters = ctx.imageFilters.splice(0, ctx.imageFilters.length);
|
95
|
+
const composer = ctx.Skia.ImageFilter.MakeBlend.bind(ctx.Skia.ImageFilter, blend);
|
96
|
+
ctx.imageFilters.push((0, _utils.composeDeclarations)(imageFilters, composer));
|
97
|
+
};
|
98
|
+
const declareDisplacementMapImageFilter = (ctx, props) => {
|
99
|
+
"worklet";
|
100
|
+
|
101
|
+
const {
|
102
|
+
channelX,
|
103
|
+
channelY,
|
104
|
+
scale
|
105
|
+
} = props;
|
106
|
+
const shader = ctx.shaders.pop();
|
107
|
+
if (!shader) {
|
108
|
+
throw new Error("DisplacementMap expects a shader as child");
|
109
|
+
}
|
110
|
+
const map = ctx.Skia.ImageFilter.MakeShader(shader, null);
|
111
|
+
const imgf = ctx.Skia.ImageFilter.MakeDisplacementMap(_types2.ColorChannel[(0, _nodes.enumKey)(channelX)], _types2.ColorChannel[(0, _nodes.enumKey)(channelY)], scale, map, null);
|
112
|
+
ctx.imageFilters.push(imgf);
|
113
|
+
};
|
114
|
+
const declareRuntimeShaderImageFilter = (ctx, props) => {
|
115
|
+
"worklet";
|
116
|
+
|
117
|
+
const {
|
118
|
+
source,
|
119
|
+
uniforms
|
120
|
+
} = props;
|
121
|
+
const rtb = ctx.Skia.RuntimeShaderBuilder(source);
|
122
|
+
if (uniforms) {
|
123
|
+
(0, _types2.processUniforms)(source, uniforms, rtb);
|
124
|
+
}
|
125
|
+
const imgf = ctx.Skia.ImageFilter.MakeRuntimeShader(rtb, null, null);
|
126
|
+
ctx.imageFilters.push(imgf);
|
127
|
+
};
|
128
|
+
const composeImageFilters = ctx => {
|
129
|
+
"worklet";
|
130
|
+
|
131
|
+
if (ctx.imageFilters.length > 1) {
|
132
|
+
const outer = ctx.imageFilters.pop();
|
133
|
+
const inner = ctx.imageFilters.pop();
|
134
|
+
ctx.imageFilters.push(ctx.Skia.ImageFilter.MakeCompose(outer, inner));
|
135
|
+
}
|
136
|
+
};
|
137
|
+
exports.composeImageFilters = composeImageFilters;
|
138
|
+
const setBlurMaskFilter = (ctx, props) => {
|
139
|
+
"worklet";
|
140
|
+
|
141
|
+
const {
|
142
|
+
blur,
|
143
|
+
style,
|
144
|
+
respectCTM
|
145
|
+
} = props;
|
146
|
+
const mf = ctx.Skia.MaskFilter.MakeBlur(_types2.BlurStyle[(0, _nodes.enumKey)(style)], blur, respectCTM);
|
147
|
+
ctx.paint.setMaskFilter(mf);
|
148
|
+
};
|
149
|
+
exports.setBlurMaskFilter = setBlurMaskFilter;
|
150
|
+
const isPushImageFilter = command => {
|
151
|
+
"worklet";
|
152
|
+
|
153
|
+
return command.type === _Core.CommandType.PushImageFilter;
|
154
|
+
};
|
155
|
+
exports.isPushImageFilter = isPushImageFilter;
|
156
|
+
const isImageFilter = (command, type) => {
|
157
|
+
"worklet";
|
158
|
+
|
159
|
+
return command.imageFilterType === type;
|
160
|
+
};
|
161
|
+
const pushImageFilter = (ctx, command) => {
|
162
|
+
"worklet";
|
163
|
+
|
164
|
+
if (isImageFilter(command, _types.NodeType.BlurImageFilter)) {
|
165
|
+
declareBlurImageFilter(ctx, command.props);
|
166
|
+
} else if (isImageFilter(command, _types.NodeType.MorphologyImageFilter)) {
|
167
|
+
declareMorphologyImageFilter(ctx, command.props);
|
168
|
+
} else if (isImageFilter(command, _types.NodeType.BlendImageFilter)) {
|
169
|
+
declareBlendImageFilter(ctx, command.props);
|
170
|
+
} else if (isImageFilter(command, _types.NodeType.DisplacementMapImageFilter)) {
|
171
|
+
declareDisplacementMapImageFilter(ctx, command.props);
|
172
|
+
} else if (isImageFilter(command, _types.NodeType.DropShadowImageFilter)) {
|
173
|
+
declareDropShadowImageFilter(ctx, command.props);
|
174
|
+
} else if (isImageFilter(command, _types.NodeType.OffsetImageFilter)) {
|
175
|
+
declareOffsetImageFilter(ctx, command.props);
|
176
|
+
} else if (isImageFilter(command, _types.NodeType.RuntimeShaderImageFilter)) {
|
177
|
+
declareRuntimeShaderImageFilter(ctx, command.props);
|
178
|
+
} else {
|
179
|
+
throw new Error("Invalid image filter type: " + command.imageFilterType);
|
180
|
+
}
|
181
|
+
};
|
182
|
+
exports.pushImageFilter = pushImageFilter;
|
183
|
+
//# sourceMappingURL=ImageFilters.js.map
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"names":["_nodes","require","_types","_types2","_utils","_Core","MorphologyOperator","exports","Black","Float32Array","of","MakeInnerShadow","Skia","shadowOnly","dx","dy","sigmaX","sigmaY","color","input","sourceGraphic","ImageFilter","MakeColorFilter","ColorFilter","MakeBlend","BlendMode","Dst","sourceAlpha","SrcIn","f1","SrcOut","f2","MakeOffset","f3","MakeBlur","TileMode","Decal","f4","MakeCompose","SrcOver","declareBlurImageFilter","ctx","props","mode","blur","sigma","processRadius","imgf","x","y","enumKey","imageFilters","push","declareMorphologyImageFilter","operator","r","radius","Erode","MakeErode","MakeDilate","declareOffsetImageFilter","declareDropShadowImageFilter","cl","inner","Color","factory","bind","MakeDropShadowOnly","MakeDropShadow","declareBlendImageFilter","blend","splice","length","composer","composeDeclarations","declareDisplacementMapImageFilter","channelX","channelY","scale","shader","shaders","pop","Error","map","MakeShader","MakeDisplacementMap","ColorChannel","declareRuntimeShaderImageFilter","source","uniforms","rtb","RuntimeShaderBuilder","processUniforms","MakeRuntimeShader","composeImageFilters","outer","setBlurMaskFilter","style","respectCTM","mf","MaskFilter","BlurStyle","paint","setMaskFilter","isPushImageFilter","command","type","CommandType","PushImageFilter","isImageFilter","imageFilterType","pushImageFilter","NodeType","BlurImageFilter","MorphologyImageFilter","BlendImageFilter","DisplacementMapImageFilter","DropShadowImageFilter","OffsetImageFilter","RuntimeShaderImageFilter"],"sources":["ImageFilters.ts"],"sourcesContent":["import { enumKey, processRadius } from \"../../../dom/nodes\";\nimport type {\n BlendImageFilterProps,\n BlurImageFilterProps,\n BlurMaskFilterProps,\n DisplacementMapImageFilterProps,\n DropShadowImageFilterProps,\n MorphologyImageFilterProps,\n OffsetImageFilterProps,\n RuntimeShaderImageFilterProps,\n} from \"../../../dom/types\";\nimport { NodeType } from \"../../../dom/types\";\nimport type { SkColor, SkImageFilter, Skia } from \"../../../skia/types\";\nimport {\n BlendMode,\n BlurStyle,\n ColorChannel,\n processUniforms,\n TileMode,\n} from \"../../../skia/types\";\nimport { composeDeclarations } from \"../../utils\";\nimport type { Command } from \"../Core\";\nimport { CommandType } from \"../Core\";\nimport type { DrawingContext } from \"../DrawingContext\";\n\nexport enum MorphologyOperator {\n Erode,\n Dilate,\n}\n\nconst Black = Float32Array.of(0, 0, 0, 1);\n\nconst MakeInnerShadow = (\n Skia: Skia,\n shadowOnly: boolean | undefined,\n dx: number,\n dy: number,\n sigmaX: number,\n sigmaY: number,\n color: SkColor,\n input: SkImageFilter | null\n) => {\n \"worklet\";\n const sourceGraphic = Skia.ImageFilter.MakeColorFilter(\n Skia.ColorFilter.MakeBlend(Black, BlendMode.Dst),\n null\n );\n const sourceAlpha = Skia.ImageFilter.MakeColorFilter(\n Skia.ColorFilter.MakeBlend(Black, BlendMode.SrcIn),\n null\n );\n const f1 = Skia.ImageFilter.MakeColorFilter(\n Skia.ColorFilter.MakeBlend(color, BlendMode.SrcOut),\n null\n );\n const f2 = Skia.ImageFilter.MakeOffset(dx, dy, f1);\n const f3 = Skia.ImageFilter.MakeBlur(sigmaX, sigmaY, TileMode.Decal, f2);\n const f4 = Skia.ImageFilter.MakeBlend(BlendMode.SrcIn, sourceAlpha, f3);\n if (shadowOnly) {\n return f4;\n }\n return Skia.ImageFilter.MakeCompose(\n input,\n Skia.ImageFilter.MakeBlend(BlendMode.SrcOver, sourceGraphic, f4)\n );\n};\n\nconst declareBlurImageFilter = (\n ctx: DrawingContext,\n props: BlurImageFilterProps\n) => {\n \"worklet\";\n const { mode, blur } = props;\n const sigma = processRadius(ctx.Skia, blur);\n const imgf = ctx.Skia.ImageFilter.MakeBlur(\n sigma.x,\n sigma.y,\n TileMode[enumKey(mode)],\n null\n );\n ctx.imageFilters.push(imgf);\n};\n\nconst declareMorphologyImageFilter = (\n ctx: DrawingContext,\n props: MorphologyImageFilterProps\n) => {\n \"worklet\";\n const { operator } = props;\n const r = processRadius(ctx.Skia, props.radius);\n let imgf;\n if (MorphologyOperator[enumKey(operator)] === MorphologyOperator.Erode) {\n imgf = ctx.Skia.ImageFilter.MakeErode(r.x, r.y, null);\n } else {\n imgf = ctx.Skia.ImageFilter.MakeDilate(r.x, r.y, null);\n }\n ctx.imageFilters.push(imgf);\n};\n\nconst declareOffsetImageFilter = (\n ctx: DrawingContext,\n props: OffsetImageFilterProps\n) => {\n \"worklet\";\n const { x, y } = props;\n const imgf = ctx.Skia.ImageFilter.MakeOffset(x, y, null);\n ctx.imageFilters.push(imgf);\n};\n\nconst declareDropShadowImageFilter = (\n ctx: DrawingContext,\n props: DropShadowImageFilterProps\n) => {\n \"worklet\";\n const { dx, dy, blur, shadowOnly, color: cl, inner } = props;\n const color = ctx.Skia.Color(cl);\n let factory;\n if (inner) {\n factory = MakeInnerShadow.bind(null, ctx.Skia, shadowOnly);\n } else {\n factory = shadowOnly\n ? ctx.Skia.ImageFilter.MakeDropShadowOnly.bind(ctx.Skia.ImageFilter)\n : ctx.Skia.ImageFilter.MakeDropShadow.bind(ctx.Skia.ImageFilter);\n }\n const imgf = factory(dx, dy, blur, blur, color, null);\n ctx.imageFilters.push(imgf);\n};\n\nconst declareBlendImageFilter = (\n ctx: DrawingContext,\n props: BlendImageFilterProps\n) => {\n \"worklet\";\n const blend = BlendMode[enumKey(props.mode)];\n // Blend ImageFilters\n const imageFilters = ctx.imageFilters.splice(0, ctx.imageFilters.length);\n const composer = ctx.Skia.ImageFilter.MakeBlend.bind(\n ctx.Skia.ImageFilter,\n blend\n );\n ctx.imageFilters.push(composeDeclarations(imageFilters, composer));\n};\n\nconst declareDisplacementMapImageFilter = (\n ctx: DrawingContext,\n props: DisplacementMapImageFilterProps\n) => {\n \"worklet\";\n const { channelX, channelY, scale } = props;\n const shader = ctx.shaders.pop();\n if (!shader) {\n throw new Error(\"DisplacementMap expects a shader as child\");\n }\n const map = ctx.Skia.ImageFilter.MakeShader(shader, null);\n const imgf = ctx.Skia.ImageFilter.MakeDisplacementMap(\n ColorChannel[enumKey(channelX)],\n ColorChannel[enumKey(channelY)],\n scale,\n map,\n null\n );\n ctx.imageFilters.push(imgf);\n};\n\nconst declareRuntimeShaderImageFilter = (\n ctx: DrawingContext,\n props: RuntimeShaderImageFilterProps\n) => {\n \"worklet\";\n const { source, uniforms } = props;\n const rtb = ctx.Skia.RuntimeShaderBuilder(source);\n if (uniforms) {\n processUniforms(source, uniforms, rtb);\n }\n const imgf = ctx.Skia.ImageFilter.MakeRuntimeShader(rtb, null, null);\n ctx.imageFilters.push(imgf);\n};\n\nexport const composeImageFilters = (ctx: DrawingContext) => {\n \"worklet\";\n if (ctx.imageFilters.length > 1) {\n const outer = ctx.imageFilters.pop()!;\n const inner = ctx.imageFilters.pop()!;\n ctx.imageFilters.push(ctx.Skia.ImageFilter.MakeCompose(outer, inner));\n }\n};\n\nexport const setBlurMaskFilter = (\n ctx: DrawingContext,\n props: BlurMaskFilterProps\n) => {\n \"worklet\";\n const { blur, style, respectCTM } = props;\n const mf = ctx.Skia.MaskFilter.MakeBlur(\n BlurStyle[enumKey(style)],\n blur,\n respectCTM\n );\n ctx.paint.setMaskFilter(mf);\n};\n\nexport const isPushImageFilter = (\n command: Command\n): command is Command<CommandType.PushImageFilter> => {\n \"worklet\";\n return command.type === CommandType.PushImageFilter;\n};\n\ntype Props = {\n [NodeType.OffsetImageFilter]: OffsetImageFilterProps;\n [NodeType.DisplacementMapImageFilter]: DisplacementMapImageFilterProps;\n [NodeType.BlurImageFilter]: BlurImageFilterProps;\n [NodeType.DropShadowImageFilter]: DropShadowImageFilterProps;\n [NodeType.MorphologyImageFilter]: MorphologyImageFilterProps;\n [NodeType.BlendImageFilter]: BlendImageFilterProps;\n [NodeType.RuntimeShaderImageFilter]: RuntimeShaderImageFilterProps;\n};\n\ninterface PushImageFilter<T extends keyof Props>\n extends Command<CommandType.PushImageFilter> {\n imageFilterType: T;\n props: Props[T];\n}\n\nconst isImageFilter = <T extends keyof Props>(\n command: Command<CommandType.PushImageFilter>,\n type: T\n): command is PushImageFilter<T> => {\n \"worklet\";\n return command.imageFilterType === type;\n};\n\nexport const pushImageFilter = (\n ctx: DrawingContext,\n command: Command<CommandType.PushImageFilter>\n) => {\n \"worklet\";\n if (isImageFilter(command, NodeType.BlurImageFilter)) {\n declareBlurImageFilter(ctx, command.props);\n } else if (isImageFilter(command, NodeType.MorphologyImageFilter)) {\n declareMorphologyImageFilter(ctx, command.props);\n } else if (isImageFilter(command, NodeType.BlendImageFilter)) {\n declareBlendImageFilter(ctx, command.props);\n } else if (isImageFilter(command, NodeType.DisplacementMapImageFilter)) {\n declareDisplacementMapImageFilter(ctx, command.props);\n } else if (isImageFilter(command, NodeType.DropShadowImageFilter)) {\n declareDropShadowImageFilter(ctx, command.props);\n } else if (isImageFilter(command, NodeType.OffsetImageFilter)) {\n declareOffsetImageFilter(ctx, command.props);\n } else if (isImageFilter(command, NodeType.RuntimeShaderImageFilter)) {\n declareRuntimeShaderImageFilter(ctx, command.props);\n } else {\n throw new Error(\"Invalid image filter type: \" + command.imageFilterType);\n }\n};\n"],"mappings":";;;;;;AAAA,IAAAA,MAAA,GAAAC,OAAA;AAWA,IAAAC,MAAA,GAAAD,OAAA;AAEA,IAAAE,OAAA,GAAAF,OAAA;AAOA,IAAAG,MAAA,GAAAH,OAAA;AAEA,IAAAI,KAAA,GAAAJ,OAAA;AAAsC,IAG1BK,kBAAkB,GAAAC,OAAA,CAAAD,kBAAA,0BAAlBA,kBAAkB;EAAlBA,kBAAkB,CAAlBA,kBAAkB;EAAlBA,kBAAkB,CAAlBA,kBAAkB;EAAA,OAAlBA,kBAAkB;AAAA;AAK9B,MAAME,KAAK,GAAGC,YAAY,CAACC,EAAE,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC,CAAC;AAEzC,MAAMC,eAAe,GAAGA,CACtBC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ACJ,OAAO,EAAEO,eAAQ,CAACM,iBAAiB,CAAC,EAAE;IAC7D1D,wBAAwB,CAACnB,GAAG,EAAEgE,OAAO,CAAC/D,KAAK,CAAC;EAC9C,CAAC,MAAM,IAAImE,aAAa,CAACJ,OAAO,EAAEO,eAAQ,CAACO,wBAAwB,CAAC,EAAE;IACpEhC,+BAA+B,CAAC9C,GAAG,EAAEgE,OAAO,CAAC/D,KAAK,CAAC;EACrD,CAAC,MAAM;IACL,MAAM,IAAIwC,KAAK,CAAC,6BAA6B,GAAGuB,OAAO,CAACK,eAAe,CAAC;EAC1E;AACF,CAAC;AAACvG,OAAA,CAAAwG,eAAA,GAAAA,eAAA","ignoreList":[]}
|
@@ -0,0 +1,4 @@
|
|
1
|
+
import type { PaintProps } from "../../../dom/types";
|
2
|
+
import type { SkPaint, Skia } from "../../../skia/types";
|
3
|
+
export declare const processColor: (Skia: Skia, color: number | string | Float32Array | number[]) => Float32Array;
|
4
|
+
export declare const setPaintProperties: (Skia: Skia, paint: SkPaint, { opacity, color, blendMode, strokeWidth, style, strokeJoin, strokeCap, strokeMiter, antiAlias, dither, }: PaintProps) => void;
|
@@ -0,0 +1,70 @@
|
|
1
|
+
"use strict";
|
2
|
+
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
4
|
+
value: true
|
5
|
+
});
|
6
|
+
exports.setPaintProperties = exports.processColor = void 0;
|
7
|
+
var _nodes = require("../../../dom/nodes");
|
8
|
+
var _types = require("../../../skia/types");
|
9
|
+
const processColor = (Skia, color) => {
|
10
|
+
"worklet";
|
11
|
+
|
12
|
+
if (typeof color === "string" || typeof color === "number") {
|
13
|
+
return Skia.Color(color);
|
14
|
+
} else if (Array.isArray(color) || color instanceof Float32Array) {
|
15
|
+
return color instanceof Float32Array ? color : new Float32Array(color);
|
16
|
+
} else {
|
17
|
+
throw new Error(`Invalid color type: ${typeof color}. Expected number, string, or array.`);
|
18
|
+
}
|
19
|
+
};
|
20
|
+
exports.processColor = processColor;
|
21
|
+
const setPaintProperties = (Skia, paint, {
|
22
|
+
opacity,
|
23
|
+
color,
|
24
|
+
blendMode,
|
25
|
+
strokeWidth,
|
26
|
+
style,
|
27
|
+
strokeJoin,
|
28
|
+
strokeCap,
|
29
|
+
strokeMiter,
|
30
|
+
antiAlias,
|
31
|
+
dither
|
32
|
+
}) => {
|
33
|
+
"worklet";
|
34
|
+
|
35
|
+
if (opacity !== undefined) {
|
36
|
+
paint.setAlphaf(paint.getAlphaf() * opacity);
|
37
|
+
}
|
38
|
+
if (color !== undefined) {
|
39
|
+
const currentOpacity = paint.getAlphaf();
|
40
|
+
paint.setShader(null);
|
41
|
+
paint.setColor(processColor(Skia, color));
|
42
|
+
paint.setAlphaf(currentOpacity * paint.getAlphaf());
|
43
|
+
}
|
44
|
+
if (blendMode !== undefined) {
|
45
|
+
paint.setBlendMode(_types.BlendMode[(0, _nodes.enumKey)(blendMode)]);
|
46
|
+
}
|
47
|
+
if (strokeWidth !== undefined) {
|
48
|
+
paint.setStrokeWidth(strokeWidth);
|
49
|
+
}
|
50
|
+
if (style !== undefined) {
|
51
|
+
paint.setStyle(_types.PaintStyle[(0, _nodes.enumKey)(style)]);
|
52
|
+
}
|
53
|
+
if (strokeJoin !== undefined) {
|
54
|
+
paint.setStrokeJoin(_types.StrokeJoin[(0, _nodes.enumKey)(strokeJoin)]);
|
55
|
+
}
|
56
|
+
if (strokeCap !== undefined) {
|
57
|
+
paint.setStrokeCap(_types.StrokeCap[(0, _nodes.enumKey)(strokeCap)]);
|
58
|
+
}
|
59
|
+
if (strokeMiter !== undefined) {
|
60
|
+
paint.setStrokeMiter(strokeMiter);
|
61
|
+
}
|
62
|
+
if (antiAlias !== undefined) {
|
63
|
+
paint.setAntiAlias(antiAlias);
|
64
|
+
}
|
65
|
+
if (dither !== undefined) {
|
66
|
+
paint.setDither(dither);
|
67
|
+
}
|
68
|
+
};
|
69
|
+
exports.setPaintProperties = setPaintProperties;
|
70
|
+
//# sourceMappingURL=Paint.js.map
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"names":["_nodes","require","_types","processColor","Skia","color","Color","Array","isArray","Float32Array","Error","exports","setPaintProperties","paint","opacity","blendMode","strokeWidth","style","strokeJoin","strokeCap","strokeMiter","antiAlias","dither","undefined","setAlphaf","getAlphaf","currentOpacity","setShader","setColor","setBlendMode","BlendMode","enumKey","setStrokeWidth","setStyle","PaintStyle","setStrokeJoin","StrokeJoin","setStrokeCap","StrokeCap","setStrokeMiter","setAntiAlias","setDither"],"sources":["Paint.ts"],"sourcesContent":["import { enumKey } from \"../../../dom/nodes\";\nimport type { PaintProps } from \"../../../dom/types\";\nimport {\n BlendMode,\n PaintStyle,\n StrokeCap,\n StrokeJoin,\n} from \"../../../skia/types\";\nimport type { SkPaint, Skia } from \"../../../skia/types\";\n\nexport const processColor = (\n Skia: Skia,\n color: number | string | Float32Array | number[]\n) => {\n \"worklet\";\n if (typeof color === \"string\" || typeof color === \"number\") {\n return Skia.Color(color);\n } else if (Array.isArray(color) || color instanceof Float32Array) {\n return color instanceof Float32Array ? color : new Float32Array(color);\n } else {\n throw new Error(\n `Invalid color type: ${typeof color}. Expected number, string, or array.`\n );\n }\n};\n\nexport const setPaintProperties = (\n Skia: Skia,\n paint: SkPaint,\n {\n opacity,\n color,\n blendMode,\n strokeWidth,\n style,\n strokeJoin,\n strokeCap,\n strokeMiter,\n antiAlias,\n dither,\n }: PaintProps\n) => {\n \"worklet\";\n if (opacity !== undefined) {\n paint.setAlphaf(paint.getAlphaf() * opacity);\n }\n if (color !== undefined) {\n const currentOpacity = paint.getAlphaf();\n paint.setShader(null);\n paint.setColor(processColor(Skia, color));\n paint.setAlphaf(currentOpacity * paint.getAlphaf());\n }\n if (blendMode !== undefined) {\n paint.setBlendMode(BlendMode[enumKey(blendMode)]);\n }\n if (strokeWidth !== undefined) {\n paint.setStrokeWidth(strokeWidth);\n }\n if (style !== undefined) {\n paint.setStyle(PaintStyle[enumKey(style)]);\n }\n if (strokeJoin !== undefined) {\n paint.setStrokeJoin(StrokeJoin[enumKey(strokeJoin)]);\n }\n if (strokeCap !== undefined) {\n paint.setStrokeCap(StrokeCap[enumKey(strokeCap)]);\n }\n if (strokeMiter !== undefined) {\n paint.setStrokeMiter(strokeMiter);\n }\n if (antiAlias !== undefined) {\n paint.setAntiAlias(antiAlias);\n }\n if (dither !== undefined) {\n paint.setDither(dither);\n }\n};\n"],"mappings":";;;;;;AAAA,IAAAA,MAAA,GAAAC,OAAA;AAEA,IAAAC,MAAA,GAAAD,OAAA;AAQO,MAAME,YAAY,GAAGA,CAC1BC,IAAU,EACVC,KAAgD,KAC7C;EACH,SAAS;;EACT,IAAI,OAAOA,KAAK,KAAK,QAAQ,IAAI,OAAOA,KAAK,KAAK,QAAQ,EAAE;IAC1D,OAAOD,IAAI,CAACE,KAAK,CAACD,KAAK,CAAC;EAC1B,CAAC,MAAM,IAAIE,KAAK,CAACC,OAAO,CAACH,KAAK,CAAC,IAAIA,KAAK,YAAYI,YAAY,EAAE;IAChE,OAAOJ,KAAK,YAAYI,YAAY,GAAGJ,KAAK,GAAG,IAAII,YAAY,CAACJ,KAAK,CAAC;EACxE,CAAC,MAAM;IACL,MAAM,IAAIK,KAAK,CACb,uBAAuB,OAAOL,KAAK,sCACrC,CAAC;EACH;AACF,CAAC;AAACM,OAAA,CAAAR,YAAA,GAAAA,YAAA;AAEK,MAAMS,kBAAkB,GAAGA,CAChCR,IAAU,EACVS,KAAc,EACd;EACEC,OAAO;EACPT,KAAK;EACLU,SAAS;EACTC,WAAW;EACXC,KAAK;EACLC,UAAU;EACVC,SAAS;EACTC,WAAW;EACXC,SAAS;EACTC;AACU,CAAC,KACV;EACH,SAAS;;EACT,IAAIR,OAAO,KAAKS,SAAS,EAAE;IACzBV,KAAK,CAACW,SAAS,CAACX,KAAK,CAACY,SAAS,CAAC,CAAC,GAAGX,OAAO,CAAC;EAC9C;EACA,IAAIT,KAAK,KAAKkB,SAAS,EAAE;IACvB,MAAMG,cAAc,GAAGb,KAA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|
+
import type { Command } from "../Core";
|
2
|
+
import { CommandType } from "../Core";
|
3
|
+
import type { DrawingContext } from "../DrawingContext";
|
4
|
+
export declare const isPushPathEffect: (command: Command) => command is Command<CommandType.PushPathEffect>;
|
5
|
+
export declare const composePathEffects: (ctx: DrawingContext) => void;
|
6
|
+
export declare const pushPathEffect: (ctx: DrawingContext, command: Command<CommandType.PushPathEffect>) => void;
|