@shopify/react-native-skia 0.1.162 → 0.1.164

Sign up to get free protection for your applications and to get access to all the features.
Files changed (194) hide show
  1. package/android/cpp/rnskia-android/RNSkAndroidPlatformContext.h +2 -0
  2. package/android/cpp/rnskia-android/RNSkOpenGLCanvasProvider.cpp +2 -2
  3. package/android/cpp/rnskia-android/RNSkOpenGLCanvasProvider.h +2 -2
  4. package/android/cpp/rnskia-android/SkiaOpenGLRenderer.h +5 -5
  5. package/cpp/api/JsiSkCanvas.h +8 -8
  6. package/cpp/api/JsiSkColor.h +1 -1
  7. package/cpp/api/JsiSkColorFilter.h +1 -1
  8. package/cpp/api/JsiSkColorFilterFactory.h +2 -2
  9. package/cpp/api/JsiSkContourMeasure.h +1 -1
  10. package/cpp/api/JsiSkContourMeasureIter.h +2 -2
  11. package/cpp/api/JsiSkData.h +2 -2
  12. package/cpp/api/JsiSkDataFactory.h +1 -1
  13. package/cpp/api/JsiSkFont.h +2 -2
  14. package/cpp/api/JsiSkImage.h +3 -3
  15. package/cpp/api/JsiSkImageFilter.h +1 -1
  16. package/cpp/api/JsiSkImageFilterFactory.h +1 -1
  17. package/cpp/api/JsiSkImageInfo.h +1 -1
  18. package/cpp/api/JsiSkMaskFilter.h +1 -1
  19. package/cpp/api/JsiSkMaskFilterFactory.h +1 -1
  20. package/cpp/api/JsiSkMatrix.h +1 -1
  21. package/cpp/api/JsiSkPaint.h +7 -1
  22. package/cpp/api/JsiSkPath.h +15 -15
  23. package/cpp/api/JsiSkPathEffect.h +1 -1
  24. package/cpp/api/JsiSkPathEffectFactory.h +4 -4
  25. package/cpp/api/JsiSkPathFactory.h +2 -2
  26. package/cpp/api/JsiSkPicture.h +1 -1
  27. package/cpp/api/JsiSkPictureFactory.h +2 -2
  28. package/cpp/api/JsiSkPictureRecorder.h +2 -2
  29. package/cpp/api/JsiSkPoint.h +1 -1
  30. package/cpp/api/JsiSkRRect.h +1 -1
  31. package/cpp/api/JsiSkRSXform.h +1 -1
  32. package/cpp/api/JsiSkRect.h +1 -1
  33. package/cpp/api/JsiSkRuntimeEffect.h +1 -1
  34. package/cpp/api/JsiSkRuntimeShaderBuilder.h +1 -1
  35. package/cpp/api/JsiSkSVGFactory.h +1 -1
  36. package/cpp/api/JsiSkShader.h +2 -2
  37. package/cpp/api/JsiSkShaderFactory.h +3 -3
  38. package/cpp/api/JsiSkSurface.h +1 -1
  39. package/cpp/api/JsiSkSurfaceFactory.h +2 -2
  40. package/cpp/api/JsiSkTextBlob.h +1 -1
  41. package/cpp/api/JsiSkTextBlobFactory.h +1 -1
  42. package/cpp/api/JsiSkTypeface.h +2 -2
  43. package/cpp/api/JsiSkVertices.h +1 -1
  44. package/cpp/jsi/JsiHostObject.h +25 -25
  45. package/cpp/rnskia/RNSkJsView.h +3 -3
  46. package/cpp/rnskia/RNSkPictureView.h +3 -3
  47. package/cpp/rnskia/RNSkPlatformContext.h +5 -3
  48. package/cpp/rnskia/RNSkView.h +2 -2
  49. package/cpp/rnskia/dom/base/DrawingContext.cpp +24 -9
  50. package/cpp/rnskia/dom/base/DrawingContext.h +3 -2
  51. package/cpp/rnskia/dom/base/JsiDomDeclarationNode.h +12 -2
  52. package/cpp/rnskia/dom/base/JsiDomDrawingNode.h +4 -4
  53. package/cpp/rnskia/dom/base/JsiDomNode.h +68 -10
  54. package/cpp/rnskia/dom/base/JsiDomRenderNode.h +26 -61
  55. package/cpp/rnskia/dom/base/NodeProp.h +2 -1
  56. package/cpp/rnskia/dom/base/NodePropsContainer.h +10 -0
  57. package/cpp/rnskia/dom/nodes/JsiBlendNode.h +7 -9
  58. package/cpp/rnskia/dom/nodes/JsiBlurMaskNode.h +3 -6
  59. package/cpp/rnskia/dom/nodes/JsiBoxNode.h +2 -4
  60. package/cpp/rnskia/dom/nodes/JsiBoxShadowNode.h +1 -2
  61. package/cpp/rnskia/dom/nodes/JsiCircleNode.h +2 -3
  62. package/cpp/rnskia/dom/nodes/JsiColorFilterNodes.h +4 -8
  63. package/cpp/rnskia/dom/nodes/JsiCustomDrawingNode.h +1 -2
  64. package/cpp/rnskia/dom/nodes/JsiDiffRectNode.h +2 -7
  65. package/cpp/rnskia/dom/nodes/JsiGlyphsNode.h +4 -8
  66. package/cpp/rnskia/dom/nodes/JsiImageFilterNodes.h +19 -37
  67. package/cpp/rnskia/dom/nodes/JsiImageNode.h +1 -1
  68. package/cpp/rnskia/dom/nodes/JsiImageSvgNode.h +2 -4
  69. package/cpp/rnskia/dom/nodes/JsiLineNode.h +2 -7
  70. package/cpp/rnskia/dom/nodes/JsiOvalNode.h +1 -3
  71. package/cpp/rnskia/dom/nodes/JsiPaintNode.h +2 -3
  72. package/cpp/rnskia/dom/nodes/JsiPatchNode.h +4 -8
  73. package/cpp/rnskia/dom/nodes/JsiPathEffectNodes.h +14 -28
  74. package/cpp/rnskia/dom/nodes/JsiPathNode.h +16 -24
  75. package/cpp/rnskia/dom/nodes/JsiPictureNode.h +1 -2
  76. package/cpp/rnskia/dom/nodes/JsiPointsNode.h +2 -5
  77. package/cpp/rnskia/dom/nodes/JsiRRectNode.h +1 -2
  78. package/cpp/rnskia/dom/nodes/JsiRectNode.h +1 -2
  79. package/cpp/rnskia/dom/nodes/JsiShaderNodes.h +37 -69
  80. package/cpp/rnskia/dom/nodes/JsiTextBlobNode.h +3 -6
  81. package/cpp/rnskia/dom/nodes/JsiTextNode.h +4 -8
  82. package/cpp/rnskia/dom/nodes/JsiTextPathNode.h +1 -2
  83. package/cpp/rnskia/dom/nodes/JsiVerticesNode.h +2 -4
  84. package/cpp/rnskia/dom/props/BlendModeProp.h +2 -2
  85. package/cpp/rnskia/dom/props/PaintProps.h +3 -0
  86. package/cpp/rnskia/dom/props/TransformProp.h +0 -2
  87. package/cpp/utils/RNSkLog.h +1 -1
  88. package/ios/RNSkia-iOS/RNSkMetalCanvasProvider.mm +8 -7
  89. package/ios/RNSkia-iOS/RNSkiOSPlatformContext.h +2 -1
  90. package/ios/RNSkia-iOS/SkiaDrawViewManager.mm +4 -4
  91. package/ios/RNSkia-iOS/SkiaManager.mm +5 -5
  92. package/ios/RNSkia-iOS/SkiaPictureViewManager.mm +3 -3
  93. package/ios/RNSkia-iOS/SkiaUIView.mm +10 -10
  94. package/lib/commonjs/dom/nodes/RenderNode.js +12 -16
  95. package/lib/commonjs/dom/nodes/RenderNode.js.map +1 -1
  96. package/lib/commonjs/dom/nodes/datatypes/index.js +0 -13
  97. package/lib/commonjs/dom/nodes/datatypes/index.js.map +1 -1
  98. package/lib/commonjs/dom/nodes/drawings/Box.js +6 -6
  99. package/lib/commonjs/dom/nodes/drawings/Box.js.map +1 -1
  100. package/lib/commonjs/dom/nodes/drawings/PatchNode.js +3 -7
  101. package/lib/commonjs/dom/nodes/drawings/PatchNode.js.map +1 -1
  102. package/lib/commonjs/dom/nodes/drawings/VerticesNode.js +1 -1
  103. package/lib/commonjs/dom/nodes/drawings/VerticesNode.js.map +1 -1
  104. package/lib/commonjs/dom/nodes/paint/ColorFilters.js +1 -3
  105. package/lib/commonjs/dom/nodes/paint/ColorFilters.js.map +1 -1
  106. package/lib/commonjs/dom/nodes/paint/ImageFilters.js +1 -1
  107. package/lib/commonjs/dom/nodes/paint/ImageFilters.js.map +1 -1
  108. package/lib/commonjs/dom/nodes/paint/Shaders.js +1 -3
  109. package/lib/commonjs/dom/nodes/paint/Shaders.js.map +1 -1
  110. package/lib/commonjs/dom/types/DrawingContext.js.map +1 -1
  111. package/lib/commonjs/renderer/Canvas.js +2 -11
  112. package/lib/commonjs/renderer/Canvas.js.map +1 -1
  113. package/lib/commonjs/renderer/Container.js +2 -1
  114. package/lib/commonjs/renderer/Container.js.map +1 -1
  115. package/lib/commonjs/renderer/DrawingContext.js.map +1 -1
  116. package/lib/commonjs/renderer/components/Mask.js +11 -25
  117. package/lib/commonjs/renderer/components/Mask.js.map +1 -1
  118. package/lib/commonjs/renderer/index.js +0 -13
  119. package/lib/commonjs/renderer/index.js.map +1 -1
  120. package/lib/commonjs/skia/types/Paint/Paint.js.map +1 -1
  121. package/lib/commonjs/skia/web/JsiSkPaint.js +4 -0
  122. package/lib/commonjs/skia/web/JsiSkPaint.js.map +1 -1
  123. package/lib/commonjs/web/LoadSkiaWeb.js +1 -1
  124. package/lib/commonjs/web/LoadSkiaWeb.js.map +1 -1
  125. package/lib/module/dom/nodes/RenderNode.js +12 -16
  126. package/lib/module/dom/nodes/RenderNode.js.map +1 -1
  127. package/lib/module/dom/nodes/datatypes/index.js +0 -1
  128. package/lib/module/dom/nodes/datatypes/index.js.map +1 -1
  129. package/lib/module/dom/nodes/drawings/Box.js +6 -5
  130. package/lib/module/dom/nodes/drawings/Box.js.map +1 -1
  131. package/lib/module/dom/nodes/drawings/PatchNode.js +4 -8
  132. package/lib/module/dom/nodes/drawings/PatchNode.js.map +1 -1
  133. package/lib/module/dom/nodes/drawings/VerticesNode.js +2 -2
  134. package/lib/module/dom/nodes/drawings/VerticesNode.js.map +1 -1
  135. package/lib/module/dom/nodes/paint/ColorFilters.js +1 -2
  136. package/lib/module/dom/nodes/paint/ColorFilters.js.map +1 -1
  137. package/lib/module/dom/nodes/paint/ImageFilters.js +2 -2
  138. package/lib/module/dom/nodes/paint/ImageFilters.js.map +1 -1
  139. package/lib/module/dom/nodes/paint/Shaders.js +1 -2
  140. package/lib/module/dom/nodes/paint/Shaders.js.map +1 -1
  141. package/lib/module/dom/types/DrawingContext.js.map +1 -1
  142. package/lib/module/renderer/Canvas.js +3 -10
  143. package/lib/module/renderer/Canvas.js.map +1 -1
  144. package/lib/module/renderer/Container.js +2 -1
  145. package/lib/module/renderer/Container.js.map +1 -1
  146. package/lib/module/renderer/DrawingContext.js.map +1 -1
  147. package/lib/module/renderer/components/Mask.js +9 -21
  148. package/lib/module/renderer/components/Mask.js.map +1 -1
  149. package/lib/module/renderer/index.js +0 -1
  150. package/lib/module/renderer/index.js.map +1 -1
  151. package/lib/module/skia/types/Paint/Paint.js.map +1 -1
  152. package/lib/module/skia/web/JsiSkPaint.js +4 -0
  153. package/lib/module/skia/web/JsiSkPaint.js.map +1 -1
  154. package/lib/module/web/LoadSkiaWeb.js +1 -1
  155. package/lib/module/web/LoadSkiaWeb.js.map +1 -1
  156. package/lib/typescript/src/dom/nodes/datatypes/index.d.ts +0 -1
  157. package/lib/typescript/src/dom/nodes/drawings/Box.d.ts +1 -1
  158. package/lib/typescript/src/dom/nodes/drawings/PatchNode.d.ts +1 -1
  159. package/lib/typescript/src/dom/types/DrawingContext.d.ts +0 -1
  160. package/lib/typescript/src/renderer/Container.d.ts +1 -1
  161. package/lib/typescript/src/renderer/DrawingContext.d.ts +3 -5
  162. package/lib/typescript/src/renderer/index.d.ts +0 -1
  163. package/lib/typescript/src/skia/types/Paint/Paint.d.ts +4 -0
  164. package/lib/typescript/src/skia/web/JsiSkPaint.d.ts +1 -0
  165. package/package.json +1 -1
  166. package/src/dom/nodes/RenderNode.ts +11 -21
  167. package/src/dom/nodes/datatypes/index.ts +0 -1
  168. package/src/dom/nodes/drawings/Box.ts +7 -4
  169. package/src/dom/nodes/drawings/PatchNode.ts +4 -18
  170. package/src/dom/nodes/drawings/VerticesNode.ts +2 -2
  171. package/src/dom/nodes/paint/ColorFilters.ts +1 -2
  172. package/src/dom/nodes/paint/ImageFilters.ts +2 -2
  173. package/src/dom/nodes/paint/Shaders.ts +1 -2
  174. package/src/dom/types/DrawingContext.ts +0 -1
  175. package/src/renderer/Canvas.tsx +2 -12
  176. package/src/renderer/Container.tsx +1 -1
  177. package/src/renderer/DrawingContext.ts +5 -5
  178. package/src/renderer/components/Mask.tsx +11 -20
  179. package/src/renderer/index.ts +0 -1
  180. package/src/skia/types/Paint/Paint.ts +5 -0
  181. package/src/skia/web/JsiSkPaint.ts +4 -0
  182. package/src/web/LoadSkiaWeb.tsx +1 -1
  183. package/lib/commonjs/dom/nodes/datatypes/Color.js +0 -27
  184. package/lib/commonjs/dom/nodes/datatypes/Color.js.map +0 -1
  185. package/lib/commonjs/renderer/useCanvas.js +0 -32
  186. package/lib/commonjs/renderer/useCanvas.js.map +0 -1
  187. package/lib/module/dom/nodes/datatypes/Color.js +0 -11
  188. package/lib/module/dom/nodes/datatypes/Color.js.map +0 -1
  189. package/lib/module/renderer/useCanvas.js +0 -15
  190. package/lib/module/renderer/useCanvas.js.map +0 -1
  191. package/lib/typescript/src/dom/nodes/datatypes/Color.d.ts +0 -7
  192. package/lib/typescript/src/renderer/useCanvas.d.ts +0 -9
  193. package/src/dom/nodes/datatypes/Color.ts +0 -15
  194. package/src/renderer/useCanvas.ts +0 -21
@@ -1 +1 @@
1
- {"version":3,"names":["skiaReconciler","ReactReconciler","skHostConfig","injectIntoDevTools","bundleType","version","rendererPackageName","render","element","root","container","updateContainer","hostDebug","depMgr","update","useCanvasRef","useRef","createDependencyManager","registerValues","global","SkiaDomApi","DependencyManager","Canvas","forwardRef","forwardedRef","children","style","debug","mode","onTouch","onSize","props","innerRef","ref","useCombinedRefs","setTick","useState","redraw","useCallback","Platform","OS","tick","current","values","Error","useMemo","Container","Skia","createContainer","console","error","useEffect","remove","refs","targetRef","React","forEach"],"sources":["Canvas.tsx"],"sourcesContent":["import React, {\n useEffect,\n useCallback,\n useMemo,\n forwardRef,\n useRef,\n useState,\n} from \"react\";\nimport type {\n RefObject,\n ReactNode,\n ComponentProps,\n MutableRefObject,\n ForwardedRef,\n} from \"react\";\nimport type { OpaqueRoot } from \"react-reconciler\";\nimport ReactReconciler from \"react-reconciler\";\nimport { Platform } from \"react-native\";\n\nimport { SkiaDomView } from \"../views\";\nimport type { TouchHandler } from \"../views\";\nimport { Skia } from \"../skia/Skia\";\nimport type { SkiaValue } from \"../values\";\n\nimport { debug as hostDebug, skHostConfig } from \"./HostConfig\";\n// import { debugTree } from \"./nodes\";\nimport { Container } from \"./Container\";\nimport { DependencyManager } from \"./DependencyManager\";\nimport { CanvasProvider } from \"./useCanvas\";\n\nexport const skiaReconciler = ReactReconciler(skHostConfig);\n\nskiaReconciler.injectIntoDevTools({\n bundleType: 1,\n version: \"0.0.1\",\n rendererPackageName: \"react-native-skia\",\n});\n\nconst render = (element: ReactNode, root: OpaqueRoot, container: Container) => {\n skiaReconciler.updateContainer(element, root, null, () => {\n hostDebug(\"updateContainer\");\n container.depMgr.update();\n });\n};\n\nexport const useCanvasRef = () => useRef<SkiaDomView>(null);\n\nconst createDependencyManager = (\n registerValues: (values: Array<SkiaValue<unknown>>) => () => void\n) =>\n global.SkiaDomApi && global.SkiaDomApi.DependencyManager\n ? global.SkiaDomApi.DependencyManager(registerValues)\n : new DependencyManager(registerValues);\n\nexport interface CanvasProps extends ComponentProps<typeof SkiaDomView> {\n ref?: RefObject<SkiaDomView>;\n children: ReactNode;\n onTouch?: TouchHandler;\n}\n\nexport const Canvas = forwardRef<SkiaDomView, CanvasProps>(\n (\n { children, style, debug, mode, onTouch, onSize, ...props },\n forwardedRef\n ) => {\n const innerRef = useCanvasRef();\n const ref = useCombinedRefs(forwardedRef, innerRef);\n const [, setTick] = useState(0);\n const redraw = useCallback(() => {\n Platform.OS === \"web\"\n ? setTick((tick) => tick + 1)\n : innerRef.current?.redraw();\n }, [innerRef]);\n\n const registerValues = useCallback(\n (values: Array<SkiaValue<unknown>>) => {\n if (ref.current === null) {\n throw new Error(\"Canvas ref is not set\");\n }\n return ref.current.registerValues(values);\n },\n [ref]\n );\n\n const container = useMemo(() => {\n return new Container(\n Skia,\n createDependencyManager(registerValues),\n redraw\n );\n }, [redraw, registerValues]);\n\n const root = useMemo(\n () =>\n skiaReconciler.createContainer(\n container,\n 0,\n null,\n true,\n null,\n \"\",\n console.error,\n null\n ),\n [container]\n );\n\n // Render effect\n useEffect(() => {\n render(\n <CanvasProvider value={{ Skia }}>{children}</CanvasProvider>,\n root,\n container\n );\n }, [children, root, redraw, container]);\n\n useEffect(() => {\n return () => {\n skiaReconciler.updateContainer(null, root, null, () => {\n container.depMgr.remove();\n });\n };\n }, [container, root]);\n\n return (\n <SkiaDomView\n ref={ref}\n style={style}\n root={container.root}\n onTouch={onTouch}\n onSize={onSize}\n mode={mode}\n debug={debug}\n {...props}\n />\n );\n }\n);\n\n/**\n * Combines a list of refs into a single ref. This can be used to provide\n * both a forwarded ref and an internal ref keeping the same functionality\n * on both of the refs.\n * @param refs Array of refs to combine\n * @returns A single ref that can be used in a ref prop.\n */\nconst useCombinedRefs = <T,>(\n ...refs: Array<MutableRefObject<T> | ForwardedRef<T>>\n) => {\n const targetRef = React.useRef<T>(null);\n React.useEffect(() => {\n refs.forEach((ref) => {\n if (ref) {\n if (typeof ref === \"function\") {\n ref(targetRef.current);\n } else {\n ref.current = targetRef.current;\n }\n }\n });\n }, [refs]);\n return targetRef;\n};\n"],"mappings":";;;;;;;AAAA;;AAgBA;;AACA;;AAEA;;AAEA;;AAGA;;AAEA;;AACA;;AACA;;;;;;;;;;AAEO,MAAMA,cAAc,GAAG,IAAAC,wBAAA,EAAgBC,wBAAhB,CAAvB;;AAEPF,cAAc,CAACG,kBAAf,CAAkC;EAChCC,UAAU,EAAE,CADoB;EAEhCC,OAAO,EAAE,OAFuB;EAGhCC,mBAAmB,EAAE;AAHW,CAAlC;;AAMA,MAAMC,MAAM,GAAG,CAACC,OAAD,EAAqBC,IAArB,EAAuCC,SAAvC,KAAgE;EAC7EV,cAAc,CAACW,eAAf,CAA+BH,OAA/B,EAAwCC,IAAxC,EAA8C,IAA9C,EAAoD,MAAM;IACxD,IAAAG,iBAAA,EAAU,iBAAV;IACAF,SAAS,CAACG,MAAV,CAAiBC,MAAjB;EACD,CAHD;AAID,CALD;;AAOO,MAAMC,YAAY,GAAG,MAAM,IAAAC,aAAA,EAAoB,IAApB,CAA3B;;;;AAEP,MAAMC,uBAAuB,GAC3BC,cAD8B,IAG9BC,MAAM,CAACC,UAAP,IAAqBD,MAAM,CAACC,UAAP,CAAkBC,iBAAvC,GACIF,MAAM,CAACC,UAAP,CAAkBC,iBAAlB,CAAoCH,cAApC,CADJ,GAEI,IAAIG,oCAAJ,CAAsBH,cAAtB,CALN;;AAaO,MAAMI,MAAM,gBAAG,IAAAC,iBAAA,EACpB,OAEEC,YAFF,KAGK;EAAA,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,OAAxB;QACD;MACF;IACF,CARD;EASD,CAVD,EAUG,CAACW,IAAD,CAVH;;EAWA,OAAOC,SAAP;AACD,CAhBD"}
1
+ {"version":3,"names":["skiaReconciler","ReactReconciler","skHostConfig","injectIntoDevTools","bundleType","version","rendererPackageName","render","element","root","container","updateContainer","hostDebug","depMgr","update","useCanvasRef","useRef","createDependencyManager","registerValues","global","SkiaDomApi","DependencyManager","Canvas","forwardRef","forwardedRef","children","style","debug","mode","onTouch","onSize","props","innerRef","ref","useCombinedRefs","redraw","useCallback","current","values","Error","useMemo","Container","Skia","createContainer","console","error","useEffect","remove","refs","targetRef","React","forEach"],"sources":["Canvas.tsx"],"sourcesContent":["import React, {\n useEffect,\n useCallback,\n useMemo,\n forwardRef,\n useRef,\n} from \"react\";\nimport type {\n RefObject,\n ReactNode,\n ComponentProps,\n MutableRefObject,\n ForwardedRef,\n} from \"react\";\nimport type { OpaqueRoot } from \"react-reconciler\";\nimport ReactReconciler from \"react-reconciler\";\n\nimport { SkiaDomView } from \"../views\";\nimport type { TouchHandler } from \"../views\";\nimport { Skia } from \"../skia/Skia\";\nimport type { SkiaValue } from \"../values\";\n\nimport { debug as hostDebug, skHostConfig } from \"./HostConfig\";\n// import { debugTree } from \"./nodes\";\nimport { Container } from \"./Container\";\nimport { DependencyManager } from \"./DependencyManager\";\n\nexport const skiaReconciler = ReactReconciler(skHostConfig);\n\nskiaReconciler.injectIntoDevTools({\n bundleType: 1,\n version: \"0.0.1\",\n rendererPackageName: \"react-native-skia\",\n});\n\nconst render = (element: ReactNode, root: OpaqueRoot, container: Container) => {\n skiaReconciler.updateContainer(element, root, null, () => {\n hostDebug(\"updateContainer\");\n container.depMgr.update();\n });\n};\n\nexport const useCanvasRef = () => useRef<SkiaDomView>(null);\n\nconst createDependencyManager = (\n registerValues: (values: Array<SkiaValue<unknown>>) => () => void\n) =>\n global.SkiaDomApi && global.SkiaDomApi.DependencyManager\n ? global.SkiaDomApi.DependencyManager(registerValues)\n : new DependencyManager(registerValues);\n\nexport interface CanvasProps extends ComponentProps<typeof SkiaDomView> {\n ref?: RefObject<SkiaDomView>;\n children: ReactNode;\n onTouch?: TouchHandler;\n}\n\nexport const Canvas = forwardRef<SkiaDomView, CanvasProps>(\n (\n { children, style, debug, mode, onTouch, onSize, ...props },\n forwardedRef\n ) => {\n const innerRef = useCanvasRef();\n const ref = useCombinedRefs(forwardedRef, innerRef);\n const redraw = useCallback(() => {\n innerRef.current?.redraw();\n }, [innerRef]);\n\n const registerValues = useCallback(\n (values: Array<SkiaValue<unknown>>) => {\n if (ref.current === null) {\n throw new Error(\"Canvas ref is not set\");\n }\n return ref.current.registerValues(values);\n },\n [ref]\n );\n\n const container = useMemo(() => {\n return new Container(\n Skia,\n createDependencyManager(registerValues),\n redraw\n );\n }, [redraw, registerValues]);\n\n const root = useMemo(\n () =>\n skiaReconciler.createContainer(\n container,\n 0,\n null,\n true,\n null,\n \"\",\n console.error,\n null\n ),\n [container]\n );\n\n // Render effect\n useEffect(() => {\n render(children, root, container);\n }, [children, root, redraw, container]);\n\n useEffect(() => {\n return () => {\n skiaReconciler.updateContainer(null, root, null, () => {\n container.depMgr.remove();\n });\n };\n }, [container, root]);\n\n return (\n <SkiaDomView\n ref={ref}\n style={style}\n root={container.root}\n onTouch={onTouch}\n onSize={onSize}\n mode={mode}\n debug={debug}\n {...props}\n />\n );\n }\n);\n\n/**\n * Combines a list of refs into a single ref. This can be used to provide\n * both a forwarded ref and an internal ref keeping the same functionality\n * on both of the refs.\n * @param refs Array of refs to combine\n * @returns A single ref that can be used in a ref prop.\n */\nconst useCombinedRefs = <T,>(\n ...refs: Array<MutableRefObject<T> | ForwardedRef<T>>\n) => {\n const targetRef = React.useRef<T>(null);\n React.useEffect(() => {\n refs.forEach((ref) => {\n if (ref) {\n if (typeof ref === \"function\") {\n ref(targetRef.current);\n } else {\n ref.current = targetRef.current;\n }\n }\n });\n }, [refs]);\n return targetRef;\n};\n"],"mappings":";;;;;;;AAAA;;AAeA;;A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AACD,IAHlB;IAIE,OAAO,EAAEoB,OAJX;IAKE,MAAM,EAAEC,MALV;IAME,IAAI,EAAEF,IANR;IAOE,KAAK,EAAED;EAPT,GAQMI,KARN,EADF;AAYD,CArEmB,CAAf;AAwEP;AACA;AACA;AACA;AACA;AACA;AACA;;;;AACA,MAAMG,eAAe,GAAG,YAEnB;EAAA,kCADAc,IACA;IADAA,IACA;EAAA;;EACH,MAAMC,SAAS,GAAGC,cAAA,CAAMlC,MAAN,CAAgB,IAAhB,CAAlB;;EACAkC,cAAA,CAAMJ,SAAN,CAAgB,MAAM;IACpBE,IAAI,CAACG,OAAL,CAAclB,GAAD,IAAS;MACpB,IAAIA,GAAJ,EAAS;QACP,IAAI,OAAOA,GAAP,KAAe,UAAnB,EAA+B;UAC7BA,GAAG,CAACgB,SAAS,CAACZ,OAAX,CAAH;QACD,CAFD,MAEO;UACLJ,GAAG,CAACI,OAAJ,GAAcY,SAAS,CAACZ,OAAxB;QACD;MACF;IACF,CARD;EASD,CAVD,EAUG,CAACW,IAAD,CAVH;;EAWA,OAAOC,SAAP;AACD,CAhBD"}
@@ -10,7 +10,8 @@ var _nodes = require("../dom/nodes");
10
10
  function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
11
11
 
12
12
  class Container {
13
- constructor(Skia, depMgr, redraw) {
13
+ constructor(Skia, depMgr) {
14
+ let redraw = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : () => {};
14
15
  this.depMgr = depMgr;
15
16
  this.redraw = redraw;
16
17
 
@@ -1 +1 @@
1
- {"version":3,"names":["Container","constructor","Skia","depMgr","redraw","Sk","JsiSkDOM","_root","Group","draw","ctx","render","root"],"sources":["Container.tsx"],"sourcesContent":["import { JsiSkDOM } from \"../dom/nodes\";\nimport type {\n GroupProps,\n DrawingContext,\n RenderNode,\n SkDOM,\n} from \"../dom/types\";\nimport type { Skia } from \"../skia/types\";\n\nimport type { DependencyManager } from \"./DependencyManager\";\n\nexport class Container {\n private _root: RenderNode<GroupProps>;\n public Sk: SkDOM;\n constructor(\n Skia: Skia,\n public depMgr: DependencyManager,\n public redraw: () => void\n ) {\n this.Sk = new JsiSkDOM({ Skia, depMgr });\n this._root = this.Sk.Group();\n }\n\n draw(ctx: DrawingContext) {\n this._root.render(ctx);\n }\n\n get root() {\n return this._root;\n }\n}\n"],"mappings":";;;;;;;AAAA;;;;AAWO,MAAMA,SAAN,CAAgB;EAGrBC,WAAW,CACTC,IADS,EAEFC,MAFE,EAGFC,MAHE,EAIT;IAAA,KAFOD,MAEP,GAFOA,MAEP;IAAA,KADOC,MACP,GADOA,MACP;;IAAA;;IAAA;;IACA,KAAKC,EAAL,GAAU,IAAIC,eAAJ,CAAa;MAAEJ,IAAF;MAAQC;IAAR,CAAb,CAAV;IACA,KAAKI,KAAL,GAAa,KAAKF,EAAL,CAAQG,KAAR,EAAb;EACD;;EAEDC,IAAI,CAACC,GAAD,EAAsB;IACxB,KAAKH,KAAL,CAAWI,MAAX,CAAkBD,GAAlB;EACD;;EAEO,IAAJE,IAAI,GAAG;IACT,OAAO,KAAKL,KAAZ;EACD;;AAlBoB"}
1
+ {"version":3,"names":["Container","constructor","Skia","depMgr","redraw","Sk","JsiSkDOM","_root","Group","draw","ctx","render","root"],"sources":["Container.tsx"],"sourcesContent":["import { JsiSkDOM } from \"../dom/nodes\";\nimport type {\n GroupProps,\n DrawingContext,\n RenderNode,\n SkDOM,\n} from \"../dom/types\";\nimport type { Skia } from \"../skia/types\";\n\nimport type { DependencyManager } from \"./DependencyManager\";\n\nexport class Container {\n private _root: RenderNode<GroupProps>;\n public Sk: SkDOM;\n constructor(\n Skia: Skia,\n public depMgr: DependencyManager,\n public redraw: () => void = () => {}\n ) {\n this.Sk = new JsiSkDOM({ Skia, depMgr });\n this._root = this.Sk.Group();\n }\n\n draw(ctx: DrawingContext) {\n this._root.render(ctx);\n }\n\n get root() {\n return this._root;\n }\n}\n"],"mappings":";;;;;;;AAAA;;;;AAWO,MAAMA,SAAN,CAAgB;EAGrBC,WAAW,CACTC,IADS,EAEFC,MAFE,EAIT;IAAA,IADOC,MACP,uEAD4B,MAAM,CAAE,CACpC;IAAA,KAFOD,MAEP,GAFOA,MAEP;IAAA,KADOC,MACP,GADOA,MACP;;IAAA;;IAAA;;IACA,KAAKC,EAAL,GAAU,IAAIC,eAAJ,CAAa;MAAEJ,IAAF;MAAQC;IAAR,CAAb,CAAV;IACA,KAAKI,KAAL,GAAa,KAAKF,EAAL,CAAQG,KAAR,EAAb;EACD;;EAEDC,IAAI,CAACC,GAAD,EAAsB;IACxB,KAAKH,KAAL,CAAWI,MAAX,CAAkBD,GAAlB;EACD;;EAEO,IAAJE,IAAI,GAAG;IACT,OAAO,KAAKL,KAAZ;EACD;;AAlBoB"}
@@ -1 +1 @@
1
- {"version":3,"names":[],"sources":["DrawingContext.ts"],"sourcesContent":["import type { RefObject } from \"react\";\n\nimport type { DrawingInfo, SkiaView } from \"../views\";\nimport type { SkCanvas, SkPaint, Skia, Vector } from \"../skia/types\";\n\nexport interface DrawingContext extends Omit<DrawingInfo, \"touches\"> {\n canvas: SkCanvas;\n paint: SkPaint;\n opacity: number;\n center: Vector;\n ref: RefObject<SkiaView>;\n Skia: Skia;\n}\n"],"mappings":""}
1
+ {"version":3,"names":[],"sources":["DrawingContext.ts"],"sourcesContent":["import type { RefObject } from \"react\";\n\nimport type { DrawingInfo, SkiaView } from \"../views\";\nimport type { Skia, Vector } from \"../skia/types\";\nimport type { DrawingContext as DOMDrawingContext } from \"../dom/types\";\n\nexport interface DrawingContext\n extends Omit<DrawingInfo, \"touches\">,\n DOMDrawingContext {\n center: Vector;\n ref: RefObject<SkiaView>;\n Skia: Skia;\n}\n"],"mappings":""}
@@ -5,17 +5,15 @@ Object.defineProperty(exports, "__esModule", {
5
5
  });
6
6
  exports.Mask = void 0;
7
7
 
8
- var _react = _interopRequireWildcard(require("react"));
9
-
10
- var _types = require("../../skia/types");
11
-
12
- var _useCanvas = require("../useCanvas");
8
+ var _react = _interopRequireDefault(require("react"));
13
9
 
14
10
  var _Group = require("./Group");
15
11
 
16
- function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function (nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
12
+ var _LumaColorFilter = require("./colorFilters/LumaColorFilter");
13
+
14
+ var _Paint = require("./Paint");
17
15
 
18
- function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || typeof obj !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
16
+ function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
19
17
 
20
18
  const Mask = _ref => {
21
19
  let {
@@ -24,28 +22,16 @@ const Mask = _ref => {
24
22
  mode,
25
23
  clip
26
24
  } = _ref;
27
- const Skia = (0, _useCanvas.useSkiaPrivate)();
28
- const maskPaint = (0, _react.useMemo)(() => {
29
- const paint = Skia.Paint();
30
- paint.setBlendMode(_types.BlendMode.Src);
31
-
32
- if (mode === "luminance") {
33
- paint.setColorFilter(Skia.ColorFilter.MakeLumaColorFilter());
34
- }
35
-
36
- return paint;
37
- }, [Skia, mode]);
38
- const clippingPaint = (0, _react.useMemo)(() => {
39
- const paint = Skia.Paint();
40
- paint.setBlendMode(_types.BlendMode.DstIn);
41
- return paint;
42
- }, [Skia]);
43
25
  return /*#__PURE__*/_react.default.createElement(_Group.Group, {
44
26
  layer: true
45
27
  }, /*#__PURE__*/_react.default.createElement(_Group.Group, {
46
- layer: maskPaint
28
+ layer: /*#__PURE__*/_react.default.createElement(_Paint.Paint, {
29
+ blendMode: "src"
30
+ }, mode === "luminance" && /*#__PURE__*/_react.default.createElement(_LumaColorFilter.LumaColorFilter, null))
47
31
  }, mask, clip && /*#__PURE__*/_react.default.createElement(_Group.Group, {
48
- layer: clippingPaint
32
+ layer: /*#__PURE__*/_react.default.createElement(_Paint.Paint, {
33
+ blendMode: "dstIn"
34
+ })
49
35
  }, children)), /*#__PURE__*/_react.default.createElement(_Group.Group, {
50
36
  blendMode: "srcIn"
51
37
  }, children));
@@ -1 +1 @@
1
- {"version":3,"names":["Mask","children","mask","mode","clip","Skia","useSkiaPrivate","maskPaint","useMemo","paint","Paint","setBlendMode","BlendMode","Src","setColorFilter","ColorFilter","MakeLumaColorFilter","clippingPaint","DstIn","defaultProps"],"sources":["Mask.tsx"],"sourcesContent":["import type { ReactNode } from \"react\";\nimport React, { useMemo } from \"react\";\n\nimport { BlendMode } from \"../../skia/types\";\nimport { useSkiaPrivate } from \"../useCanvas\";\n\nimport { Group } from \"./Group\";\n\ninterface MaskProps {\n mode: \"luminance\" | \"alpha\";\n clip: boolean;\n mask: ReactNode | ReactNode[];\n children: ReactNode | ReactNode[];\n}\n\nexport const Mask = ({ children, mask, mode, clip }: MaskProps) => {\n const Skia = useSkiaPrivate();\n const maskPaint = useMemo(() => {\n const paint = Skia.Paint();\n paint.setBlendMode(BlendMode.Src);\n if (mode === \"luminance\") {\n paint.setColorFilter(Skia.ColorFilter.MakeLumaColorFilter());\n }\n return paint;\n }, [Skia, mode]);\n const clippingPaint = useMemo(() => {\n const paint = Skia.Paint();\n paint.setBlendMode(BlendMode.DstIn);\n return paint;\n }, [Skia]);\n return (\n <Group layer>\n <Group layer={maskPaint}>\n {mask}\n {clip && <Group layer={clippingPaint}>{children}</Group>}\n </Group>\n <Group blendMode=\"srcIn\">{children}</Group>\n </Group>\n );\n};\n\nMask.defaultProps = {\n mode: \"alpha\",\n clip: true,\n};\n"],"mappings":";;;;;;;AACA;;AAEA;;AACA;;AAEA;;;;;;AASO,MAAMA,IAAI,GAAG,QAA+C;EAAA,IAA9C;IAAEC,QAAF;IAAYC,IAAZ;IAAkBC,IAAlB;IAAwBC;EAAxB,CAA8C;EACjE,MAAMC,IAAI,GAAG,IAAAC,yBAAA,GAAb;EACA,MAAMC,SAAS,GAAG,IAAAC,cAAA,EAAQ,MAAM;IAC9B,MAAMC,KAAK,GAAGJ,IAAI,CAACK,KAAL,EAAd;IACAD,KAAK,CAACE,YAAN,CAAmBC,gBAAA,CAAUC,GAA7B;;IACA,IAAIV,IAAI,KAAK,WAAb,EAA0B;MACxBM,KAAK,CAACK,cAAN,CAAqBT,IAAI,CAACU,WAAL,CAAiBC,mBAAjB,EAArB;IACD;;IACD,OAAOP,KAAP;EACD,CAPiB,EAOf,CAACJ,IAAD,EAAOF,IAAP,CAPe,CAAlB;EAQA,MAAMc,aAAa,GAAG,IAAAT,cAAA,EAAQ,MAAM;IAClC,MAAMC,KAAK,GAAGJ,IAAI,CAACK,KAAL,EAAd;IACAD,KAAK,CAACE,YAAN,CAAmBC,gBAAA,CAAUM,KAA7B;IACA,OAAOT,KAAP;EACD,CAJqB,EAInB,CAACJ,IAAD,CAJmB,CAAtB;EAKA,oBACE,6BAAC,YAAD;IAAO,KAAK;EAAZ,gBACE,6BAAC,YAAD;IAAO,KAAK,EAAEE;EAAd,GACGL,IADH,EAEGE,IAAI,iBAAI,6BAAC,YAAD;IAAO,KAAK,EAAEa;EAAd,GAA8BhB,QAA9B,CAFX,CADF,eAKE,6BAAC,YAAD;IAAO,SAAS,EAAC;EAAjB,GAA0BA,QAA1B,CALF,CADF;AASD,CAxBM;;;AA0BPD,IAAI,CAACmB,YAAL,GAAoB;EAClBhB,IAAI,EAAE,OADY;EAElBC,IAAI,EAAE;AAFY,CAApB"}
1
+ {"version":3,"names":["Mask","children","mask","mode","clip","defaultProps"],"sources":["Mask.tsx"],"sourcesContent":["import type { ReactNode } from \"react\";\nimport React from \"react\";\n\nimport { Group } from \"./Group\";\nimport { LumaColorFilter } from \"./colorFilters/LumaColorFilter\";\nimport { Paint } from \"./Paint\";\n\ninterface MaskProps {\n mode: \"luminance\" | \"alpha\";\n clip: boolean;\n mask: ReactNode | ReactNode[];\n children: ReactNode | ReactNode[];\n}\n\nexport const Mask = ({ children, mask, mode, clip }: MaskProps) => {\n return (\n <Group layer>\n <Group\n layer={\n <Paint blendMode=\"src\">\n {mode === \"luminance\" && <LumaColorFilter />}\n </Paint>\n }\n >\n {mask}\n {clip && <Group layer={<Paint blendMode=\"dstIn\" />}>{children}</Group>}\n </Group>\n <Group blendMode=\"srcIn\">{children}</Group>\n </Group>\n );\n};\n\nMask.defaultProps = {\n mode: \"alpha\",\n clip: true,\n};\n"],"mappings":";;;;;;;AACA;;AAEA;;AACA;;AACA;;;;AASO,MAAMA,IAAI,GAAG,QAA+C;EAAA,IAA9C;IAAEC,QAAF;IAAYC,IAAZ;IAAkBC,IAAlB;IAAwBC;EAAxB,CAA8C;EACjE,oBACE,6BAAC,YAAD;IAAO,KAAK;EAAZ,gBACE,6BAAC,YAAD;IACE,KAAK,eACH,6BAAC,YAAD;MAAO,SAAS,EAAC;IAAjB,GACGD,IAAI,KAAK,WAAT,iBAAwB,6BAAC,gCAAD,OAD3B;EAFJ,GAOGD,IAPH,EAQGE,IAAI,iBAAI,6BAAC,YAAD;IAAO,KAAK,eAAE,6BAAC,YAAD;MAAO,SAAS,EAAC;IAAjB;EAAd,GAA4CH,QAA5C,CARX,CADF,eAWE,6BAAC,YAAD;IAAO,SAAS,EAAC;EAAjB,GAA0BA,QAA1B,CAXF,CADF;AAeD,CAhBM;;;AAkBPD,IAAI,CAACK,YAAL,GAAoB;EAClBF,IAAI,EAAE,OADY;EAElBC,IAAI,EAAE;AAFY,CAApB"}
@@ -42,17 +42,4 @@ Object.keys(_DependencyManager).forEach(function (key) {
42
42
  }
43
43
  });
44
44
  });
45
-
46
- var _useCanvas = require("./useCanvas");
47
-
48
- Object.keys(_useCanvas).forEach(function (key) {
49
- if (key === "default" || key === "__esModule") return;
50
- if (key in exports && exports[key] === _useCanvas[key]) return;
51
- Object.defineProperty(exports, key, {
52
- enumerable: true,
53
- get: function () {
54
- return _useCanvas[key];
55
- }
56
- });
57
- });
58
45
  //# sourceMappingURL=index.js.map
@@ -1 +1 @@
1
- {"version":3,"names":[],"sources":["index.ts"],"sourcesContent":["export * from \"./components\";\nexport * from \"./useContextBridge\";\nexport * from \"./DependencyManager\";\nexport * from \"./useCanvas\";\n"],"mappings":";;;;;;AAAA;;AAAA;EAAA;EAAA;EAAA;IAAA;IAAA;MAAA;IAAA;EAAA;AAAA;;AACA;;AAAA;EAAA;EAAA;EAAA;IAAA;IAAA;MAAA;IAAA;EAAA;AAAA;;AACA;;AAAA;EAAA;EAAA;EAAA;IAAA;IAAA;MAAA;IAAA;EAAA;AAAA;;AACA;;AAAA;EAAA;EAAA;EAAA;IAAA;IAAA;MAAA;IAAA;EAAA;AAAA"}
1
+ {"version":3,"names":[],"sources":["index.ts"],"sourcesContent":["export * from \"./components\";\nexport * from \"./useContextBridge\";\nexport * from \"./DependencyManager\";\n"],"mappings":";;;;;;AAAA;;AAAA;EAAA;EAAA;EAAA;IAAA;IAAA;MAAA;IAAA;EAAA;AAAA;;AACA;;AAAA;EAAA;EAAA;EAAA;IAAA;IAAA;MAAA;IAAA;EAAA;AAAA;;AACA;;AAAA;EAAA;EAAA;EAAA;IAAA;IAAA;MAAA;IAAA;EAAA;AAAA"}
@@ -1 +1 @@
1
- {"version":3,"names":["PaintStyle","StrokeCap","StrokeJoin","isPaint","obj","__typename__"],"sources":["Paint.ts"],"sourcesContent":["import type { SkImageFilter } from \"../ImageFilter\";\nimport type { SkMaskFilter } from \"../MaskFilter\";\nimport type { SkColorFilter } from \"../ColorFilter\";\nimport type { SkColor } from \"../Color\";\nimport type { SkPathEffect } from \"../PathEffect\";\nimport type { SkJSIInstance } from \"../JsiInstance\";\nimport type { SkShader } from \"../Shader\";\n\nimport type { BlendMode } from \"./BlendMode\";\n\nexport enum PaintStyle {\n Fill,\n Stroke,\n}\n\nexport enum StrokeCap {\n Butt,\n Round,\n Square,\n}\n\nexport enum StrokeJoin {\n Miter,\n Round,\n Bevel,\n}\n\nexport const isPaint = (obj: SkJSIInstance<string> | null): obj is SkPaint =>\n obj !== null && obj.__typename__ === \"Paint\";\n\nexport interface SkPaint extends SkJSIInstance<\"Paint\"> {\n /**\n * Returns a copy of this paint.\n */\n copy(): SkPaint;\n\n /**\n * Sets all SkPaint contents to their initial values. This is equivalent to replacing\n SkPaint with the result of SkPaint().\n */\n reset(): void;\n\n /**\n * Retrieves the alpha and RGB unpremultiplied. RGB are extended sRGB values\n * (sRGB gamut, and encoded with the sRGB transfer function).\n */\n getColor(): SkColor;\n\n /**\n * Returns the geometry drawn at the beginning and end of strokes.\n */\n getStrokeCap(): StrokeCap;\n\n /**\n * Returns the geometry drawn at the corners of strokes.\n */\n getStrokeJoin(): StrokeJoin;\n\n /**\n * Returns the limit at which a sharp corner is drawn beveled.\n */\n getStrokeMiter(): number;\n\n /**\n * Returns the thickness of the pen used to outline the shape.\n */\n getStrokeWidth(): number;\n\n /**\n * Replaces alpha, leaving RGBA unchanged. 0 means fully transparent, 1.0 means opaque.\n * @param alpha\n */\n setAlphaf(alpha: number): void;\n\n /**\n * Requests, but does not require, that edge pixels draw opaque or with\n * partial transparency.\n * @param aa\n */\n setAntiAlias: (aa: boolean) => void;\n\n /**\n * Sets the blend mode that is, the mode used to combine source color\n * with destination color.\n * @param mode\n */\n setBlendMode: (blendMode: BlendMode) => void;\n\n /**\n * Sets alpha and RGB used when stroking and filling. The color is a 32-bit\n * value, unpremultiplied, packing 8-bit components for alpha, red, blue,\n * and green.\n *\n * @param color unpremultiplied ARGB\n *\n * example: https://fiddle.skia.org/c/@Paint_setColor\n */\n setColor(color: SkColor): void;\n\n /**\n * Sets the current color filter, replacing the existing one if there was one.\n * @param filter\n */\n setColorFilter(filter: SkColorFilter | null): void;\n\n /**\n * Sets the current image filter, replacing the existing one if there was one.\n * @param filter\n */\n setImageFilter(filter: SkImageFilter | null): void;\n\n /**\n * Sets the current mask filter, replacing the existing one if there was one.\n * @param filter\n */\n setMaskFilter(filter: SkMaskFilter | null): void;\n\n /**\n * Sets the current path effect, replacing the existing one if there was one.\n * @param effect\n */\n setPathEffect(effect: SkPathEffect | null): void;\n\n /**\n * Sets the current shader, replacing the existing one if there was one.\n * @param shader\n */\n setShader(shader: SkShader | null): void;\n\n /**\n * Sets the geometry drawn at the beginning and end of strokes.\n * @param cap\n */\n setStrokeCap(cap: StrokeCap): void;\n\n /**\n * Sets the geometry drawn at the corners of strokes.\n * @param join\n */\n setStrokeJoin(join: StrokeJoin): void;\n\n /**\n * Sets the limit at which a sharp corner is drawn beveled.\n * @param limit\n */\n setStrokeMiter(limit: number): void;\n\n /**\n * Sets the thickness of the pen used to outline the shape.\n * @param width\n */\n setStrokeWidth(width: number): void;\n\n /**\n * Sets whether the geometry is filled or stroked.\n * @param style\n */\n setStyle(style: PaintStyle): void;\n}\n"],"mappings":";;;;;;IAUYA,U;;;WAAAA,U;EAAAA,U,CAAAA,U;EAAAA,U,CAAAA,U;GAAAA,U,0BAAAA,U;;IAKAC,S;;;WAAAA,S;EAAAA,S,CAAAA,S;EAAAA,S,CAAAA,S;EAAAA,S,CAAAA,S;GAAAA,S,yBAAAA,S;;IAMAC,U;;;WAAAA,U;EAAAA,U,CAAAA,U;EAAAA,U,CAAAA,U;EAAAA,U,CAAAA,U;GAAAA,U,0BAAAA,U;;AAML,MAAMC,OAAO,GAAIC,GAAD,IACrBA,GAAG,KAAK,IAAR,IAAgBA,GAAG,CAACC,YAAJ,KAAqB,OADhC"}
1
+ {"version":3,"names":["PaintStyle","StrokeCap","StrokeJoin","isPaint","obj","__typename__"],"sources":["Paint.ts"],"sourcesContent":["import type { SkImageFilter } from \"../ImageFilter\";\nimport type { SkMaskFilter } from \"../MaskFilter\";\nimport type { SkColorFilter } from \"../ColorFilter\";\nimport type { SkColor } from \"../Color\";\nimport type { SkPathEffect } from \"../PathEffect\";\nimport type { SkJSIInstance } from \"../JsiInstance\";\nimport type { SkShader } from \"../Shader\";\n\nimport type { BlendMode } from \"./BlendMode\";\n\nexport enum PaintStyle {\n Fill,\n Stroke,\n}\n\nexport enum StrokeCap {\n Butt,\n Round,\n Square,\n}\n\nexport enum StrokeJoin {\n Miter,\n Round,\n Bevel,\n}\n\nexport const isPaint = (obj: SkJSIInstance<string> | null): obj is SkPaint =>\n obj !== null && obj.__typename__ === \"Paint\";\n\nexport interface SkPaint extends SkJSIInstance<\"Paint\"> {\n /**\n * Retrieves alpha from the color used when stroking and filling.\n */\n getAlphaf(): number;\n\n /**\n * Returns a copy of this paint.\n */\n copy(): SkPaint;\n\n /**\n * Sets all SkPaint contents to their initial values. This is equivalent to replacing\n SkPaint with the result of SkPaint().\n */\n reset(): void;\n\n /**\n * Retrieves the alpha and RGB unpremultiplied. RGB are extended sRGB values\n * (sRGB gamut, and encoded with the sRGB transfer function).\n */\n getColor(): SkColor;\n\n /**\n * Returns the geometry drawn at the beginning and end of strokes.\n */\n getStrokeCap(): StrokeCap;\n\n /**\n * Returns the geometry drawn at the corners of strokes.\n */\n getStrokeJoin(): StrokeJoin;\n\n /**\n * Returns the limit at which a sharp corner is drawn beveled.\n */\n getStrokeMiter(): number;\n\n /**\n * Returns the thickness of the pen used to outline the shape.\n */\n getStrokeWidth(): number;\n\n /**\n * Replaces alpha, leaving RGBA unchanged. 0 means fully transparent, 1.0 means opaque.\n * @param alpha\n */\n setAlphaf(alpha: number): void;\n\n /**\n * Requests, but does not require, that edge pixels draw opaque or with\n * partial transparency.\n * @param aa\n */\n setAntiAlias: (aa: boolean) => void;\n\n /**\n * Sets the blend mode that is, the mode used to combine source color\n * with destination color.\n * @param mode\n */\n setBlendMode: (blendMode: BlendMode) => void;\n\n /**\n * Sets alpha and RGB used when stroking and filling. The color is a 32-bit\n * value, unpremultiplied, packing 8-bit components for alpha, red, blue,\n * and green.\n *\n * @param color unpremultiplied ARGB\n *\n * example: https://fiddle.skia.org/c/@Paint_setColor\n */\n setColor(color: SkColor): void;\n\n /**\n * Sets the current color filter, replacing the existing one if there was one.\n * @param filter\n */\n setColorFilter(filter: SkColorFilter | null): void;\n\n /**\n * Sets the current image filter, replacing the existing one if there was one.\n * @param filter\n */\n setImageFilter(filter: SkImageFilter | null): void;\n\n /**\n * Sets the current mask filter, replacing the existing one if there was one.\n * @param filter\n */\n setMaskFilter(filter: SkMaskFilter | null): void;\n\n /**\n * Sets the current path effect, replacing the existing one if there was one.\n * @param effect\n */\n setPathEffect(effect: SkPathEffect | null): void;\n\n /**\n * Sets the current shader, replacing the existing one if there was one.\n * @param shader\n */\n setShader(shader: SkShader | null): void;\n\n /**\n * Sets the geometry drawn at the beginning and end of strokes.\n * @param cap\n */\n setStrokeCap(cap: StrokeCap): void;\n\n /**\n * Sets the geometry drawn at the corners of strokes.\n * @param join\n */\n setStrokeJoin(join: StrokeJoin): void;\n\n /**\n * Sets the limit at which a sharp corner is drawn beveled.\n * @param limit\n */\n setStrokeMiter(limit: number): void;\n\n /**\n * Sets the thickness of the pen used to outline the shape.\n * @param width\n */\n setStrokeWidth(width: number): void;\n\n /**\n * Sets whether the geometry is filled or stroked.\n * @param style\n */\n setStyle(style: PaintStyle): void;\n}\n"],"mappings":";;;;;;IAUYA,U;;;WAAAA,U;EAAAA,U,CAAAA,U;EAAAA,U,CAAAA,U;GAAAA,U,0BAAAA,U;;IAKAC,S;;;WAAAA,S;EAAAA,S,CAAAA,S;EAAAA,S,CAAAA,S;EAAAA,S,CAAAA,S;GAAAA,S,yBAAAA,S;;IAMAC,U;;;WAAAA,U;EAAAA,U,CAAAA,U;EAAAA,U,CAAAA,U;EAAAA,U,CAAAA,U;GAAAA,U,0BAAAA,U;;AAML,MAAMC,OAAO,GAAIC,GAAD,IACrBA,GAAG,KAAK,IAAR,IAAgBA,GAAG,CAACC,YAAJ,KAAqB,OADhC"}
@@ -30,6 +30,10 @@ class JsiSkPaint extends _Host.HostObject {
30
30
  this.ref = new this.CanvasKit.Paint();
31
31
  }
32
32
 
33
+ getAlphaf() {
34
+ return this.getColor()[3];
35
+ }
36
+
33
37
  getColor() {
34
38
  return this.ref.getColor();
35
39
  }
@@ -1 +1 @@
1
- {"version":3,"names":["JsiSkPaint","HostObject","constructor","CanvasKit","ref","copy","reset","Paint","getColor","getStrokeCap","value","getStrokeJoin","getStrokeMiter","getStrokeWidth","setAlphaf","alpha","setAntiAlias","aa","setBlendMode","blendMode","ckEnum","setColor","color","setColorFilter","filter","JsiSkColorFilter","fromValue","setImageFilter","JsiSkImageFilter","setMaskFilter","JsiSkMaskFilter","setPathEffect","effect","JsiSkPathEffect","setShader","shader","JsiSkShader","setStrokeCap","cap","setStrokeJoin","join","setStrokeMiter","limit","setStrokeWidth","width","setStyle","style"],"sources":["JsiSkPaint.ts"],"sourcesContent":["import type { CanvasKit, Paint } from \"canvaskit-wasm\";\n\nimport type {\n StrokeJoin,\n BlendMode,\n SkColor,\n SkColorFilter,\n SkImageFilter,\n SkPaint,\n SkShader,\n StrokeCap,\n PaintStyle,\n SkMaskFilter,\n SkPathEffect,\n} from \"../types\";\n\nimport { HostObject, ckEnum } from \"./Host\";\nimport { JsiSkColorFilter } from \"./JsiSkColorFilter\";\nimport { JsiSkImageFilter } from \"./JsiSkImageFilter\";\nimport { JsiSkMaskFilter } from \"./JsiSkMaskFilter\";\nimport { JsiSkPathEffect } from \"./JsiSkPathEffect\";\nimport { JsiSkShader } from \"./JsiSkShader\";\n\nexport class JsiSkPaint extends HostObject<Paint, \"Paint\"> implements SkPaint {\n constructor(CanvasKit: CanvasKit, ref: Paint) {\n super(CanvasKit, ref, \"Paint\");\n }\n\n copy() {\n return new JsiSkPaint(this.CanvasKit, this.ref.copy());\n }\n\n reset() {\n this.ref = new this.CanvasKit.Paint();\n }\n\n getColor() {\n return this.ref.getColor();\n }\n\n getStrokeCap() {\n return this.ref.getStrokeCap().value;\n }\n\n getStrokeJoin() {\n return this.ref.getStrokeJoin().value;\n }\n\n getStrokeMiter() {\n return this.ref.getStrokeMiter();\n }\n\n getStrokeWidth() {\n return this.ref.getStrokeWidth();\n }\n\n setAlphaf(alpha: number) {\n this.ref.setAlphaf(alpha);\n }\n\n setAntiAlias(aa: boolean) {\n this.ref.setAntiAlias(aa);\n }\n\n setBlendMode(blendMode: BlendMode) {\n this.ref.setBlendMode(ckEnum(blendMode));\n }\n\n setColor(color: SkColor) {\n this.ref.setColor(color);\n }\n\n setColorFilter(filter: SkColorFilter | null) {\n this.ref.setColorFilter(filter ? JsiSkColorFilter.fromValue(filter) : null);\n }\n\n setImageFilter(filter: SkImageFilter | null) {\n this.ref.setImageFilter(filter ? JsiSkImageFilter.fromValue(filter) : null);\n }\n\n setMaskFilter(filter: SkMaskFilter | null) {\n this.ref.setMaskFilter(filter ? JsiSkMaskFilter.fromValue(filter) : null);\n }\n\n setPathEffect(effect: SkPathEffect | null) {\n this.ref.setPathEffect(effect ? JsiSkPathEffect.fromValue(effect) : null);\n }\n\n setShader(shader: SkShader | null) {\n this.ref.setShader(shader ? JsiSkShader.fromValue(shader) : null);\n }\n\n setStrokeCap(cap: StrokeCap) {\n this.ref.setStrokeCap(ckEnum(cap));\n }\n\n setStrokeJoin(join: StrokeJoin) {\n this.ref.setStrokeJoin(ckEnum(join));\n }\n\n setStrokeMiter(limit: number) {\n this.ref.setStrokeMiter(limit);\n }\n\n setStrokeWidth(width: number) {\n this.ref.setStrokeWidth(width);\n }\n\n setStyle(style: PaintStyle) {\n this.ref.setStyle({ value: style });\n }\n}\n"],"mappings":";;;;;;;AAgBA;;AACA;;AACA;;AACA;;AACA;;AACA;;AAEO,MAAMA,UAAN,SAAyBC,gBAAzB,CAAuE;EAC5EC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B,GAAL,CAASuB,cAAT,CAAwBH,MAAM,GAAGI,kCAAA,CAAiBF,SAAjB,CAA2BF,MAA3B,CAAH,GAAwC,IAAtE;EACD;;EAEDK,aAAa,CAACL,MAAD,EAA8B;IACzC,KAAKpB,GAAL,CAASyB,aAAT,CAAuBL,MAAM,GAAGM,gCAAA,CAAgBJ,SAAhB,CAA0BF,MAA1B,CAAH,GAAuC,IAApE;EACD;;EAEDO,aAAa,CAACC,MAAD,EAA8B;IACzC,KAAK5B,GAAL,CAAS2B,aAAT,CAAuBC,MAAM,GAAGC,gCAAA,CAAgBP,SAAhB,CAA0BM,MAA1B,CAAH,GAAuC,IAApE;EACD;;EAEDE,SAAS,CAACC,MAAD,EAA0B;IACjC,KAAK/B,GAAL,CAAS8B,SAAT,CAAmBC,MAAM,GAAGC,wBAAA,CAAYV,SAAZ,CAAsBS,MAAtB,CAAH,GAAmC,IAA5D;EACD;;EAEDE,YAAY,CAACC,GAAD,EAAiB;IAC3B,KAAKlC,GAAL,CAASiC,YAAT,CAAsB,IAAAjB,YAAA,EAAOkB,GAAP,CAAtB;EACD;;EAEDC,aAAa,CAACC,IAAD,EAAmB;IAC9B,KAAKpC,GAAL,CAASmC,aAAT,CAAuB,IAAAnB,YAAA,EAAOoB,IAAP,CAAvB;EACD;;EAEDC,cAAc,CAACC,KAAD,EAAgB;IAC5B,KAAKtC,GAAL,CAASqC,cAAT,CAAwBC,KAAxB;EACD;;EAEDC,cAAc,CAACC,KAAD,EAAgB;IAC5B,KAAKxC,GAAL,CAASuC,cAAT,CAAwBC,KAAxB;EACD;;EAEDC,QAAQ,CAACC,KAAD,EAAoB;IAC1B,KAAK1C,GAAL,CAASyC,QAAT,CAAkB;MAAEnC,KAAK,EAAEoC;IAAT,CAAlB;EACD;;AAvF2E"}
1
+ {"version":3,"names":["JsiSkPaint","HostObject","constructor","CanvasKit","ref","copy","reset","Paint","getAlphaf","getColor","getStrokeCap","value","getStrokeJoin","getStrokeMiter","getStrokeWidth","setAlphaf","alpha","setAntiAlias","aa","setBlendMode","blendMode","ckEnum","setColor","color","setColorFilter","filter","JsiSkColorFilter","fromValue","setImageFilter","JsiSkImageFilter","setMaskFilter","JsiSkMaskFilter","setPathEffect","effect","JsiSkPathEffect","setShader","shader","JsiSkShader","setStrokeCap","cap","setStrokeJoin","join","setStrokeMiter","limit","setStrokeWidth","width","setStyle","style"],"sources":["JsiSkPaint.ts"],"sourcesContent":["import type { CanvasKit, Paint } from \"canvaskit-wasm\";\n\nimport type {\n StrokeJoin,\n BlendMode,\n SkColor,\n SkColorFilter,\n SkImageFilter,\n SkPaint,\n SkShader,\n StrokeCap,\n PaintStyle,\n SkMaskFilter,\n SkPathEffect,\n} from \"../types\";\n\nimport { HostObject, ckEnum } from \"./Host\";\nimport { JsiSkColorFilter } from \"./JsiSkColorFilter\";\nimport { JsiSkImageFilter } from \"./JsiSkImageFilter\";\nimport { JsiSkMaskFilter } from \"./JsiSkMaskFilter\";\nimport { JsiSkPathEffect } from \"./JsiSkPathEffect\";\nimport { JsiSkShader } from \"./JsiSkShader\";\n\nexport class JsiSkPaint extends HostObject<Paint, \"Paint\"> implements SkPaint {\n constructor(CanvasKit: CanvasKit, ref: Paint) {\n super(CanvasKit, ref, \"Paint\");\n }\n\n copy() {\n return new JsiSkPaint(this.CanvasKit, this.ref.copy());\n }\n\n reset() {\n this.ref = new this.CanvasKit.Paint();\n }\n\n getAlphaf() {\n return this.getColor()[3];\n }\n\n getColor() {\n return this.ref.getColor();\n }\n\n getStrokeCap() {\n return this.ref.getStrokeCap().value;\n }\n\n getStrokeJoin() {\n return this.ref.getStrokeJoin().value;\n }\n\n getStrokeMiter() {\n return this.ref.getStrokeMiter();\n }\n\n getStrokeWidth() {\n return this.ref.getStrokeWidth();\n }\n\n setAlphaf(alpha: number) {\n this.ref.setAlphaf(alpha);\n }\n\n setAntiAlias(aa: boolean) {\n this.ref.setAntiAlias(aa);\n }\n\n setBlendMode(blendMode: BlendMode) {\n this.ref.setBlendMode(ckEnum(blendMode));\n }\n\n setColor(color: SkColor) {\n this.ref.setColor(color);\n }\n\n setColorFilter(filter: SkColorFilter | null) {\n this.ref.setColorFilter(filter ? JsiSkColorFilter.fromValue(filter) : null);\n }\n\n setImageFilter(filter: SkImageFilter | null) {\n this.ref.setImageFilter(filter ? JsiSkImageFilter.fromValue(filter) : null);\n }\n\n setMaskFilter(filter: SkMaskFilter | null) {\n this.ref.setMaskFilter(filter ? JsiSkMaskFilter.fromValue(filter) : null);\n }\n\n setPathEffect(effect: SkPathEffect | null) {\n this.ref.setPathEffect(effect ? JsiSkPathEffect.fromValue(effect) : null);\n }\n\n setShader(shader: SkShader | null) {\n this.ref.setShader(shader ? JsiSkShader.fromValue(shader) : null);\n }\n\n setStrokeCap(cap: StrokeCap) {\n this.ref.setStrokeCap(ckEnum(cap));\n }\n\n setStrokeJoin(join: StrokeJoin) {\n this.ref.setStrokeJoin(ckEnum(join));\n }\n\n setStrokeMiter(limit: number) {\n this.ref.setStrokeMiter(limit);\n }\n\n setStrokeWidth(width: number) {\n this.ref.setStrokeWidth(width);\n }\n\n setStyle(style: PaintStyle) {\n this.ref.setStyle({ value: style });\n }\n}\n"],"mappings":";;;;;;;AAgBA;;AACA;;AACA;;AACA;;AACA;;AACA;;AAEO,MAAMA,UAAN,SAAyBC,gBAAzB,CAAuE;EAC5EC,WAAW,CAACC,SAAD,EAAuBC,GAAvB,EAAmC;IAC5C,MAAMD,SAAN,EAAiBC,GAAjB,EAAsB,OAAtB;EACD;;EAEDC,IAAI,GAAG;IACL,OAAO,IAAIL,UAAJ,CAAe,KAAKG,SAApB,EAA+B,KAAKC,GAAL,CAASC,IAAT,EAA/B,CAAP;EACD;;EAEDC,KAAK,GAAG;IACN,KAAKF,GAAL,GAAW,IAAI,KAAKD,SAAL,CAAeI,KAAnB,EAAX;EACD;;EAEDC,SAAS,GAAG;IACV,OAAO,KAAKC,QAAL,GAAgB,CAAhB,CAAP;EACD;;EAEDA,QAAQ,GAAG;IACT,OAAO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AuBC,MAAM,GAAGC,gCAAA,CAAgBP,SAAhB,CAA0BM,MAA1B,CAAH,GAAuC,IAApE;EACD;;EAEDE,SAAS,CAACC,MAAD,EAA0B;IACjC,KAAKhC,GAAL,CAAS+B,SAAT,CAAmBC,MAAM,GAAGC,wBAAA,CAAYV,SAAZ,CAAsBS,MAAtB,CAAH,GAAmC,IAA5D;EACD;;EAEDE,YAAY,CAACC,GAAD,EAAiB;IAC3B,KAAKnC,GAAL,CAASkC,YAAT,CAAsB,IAAAjB,YAAA,EAAOkB,GAAP,CAAtB;EACD;;EAEDC,aAAa,CAACC,IAAD,EAAmB;IAC9B,KAAKrC,GAAL,CAASoC,aAAT,CAAuB,IAAAnB,YAAA,EAAOoB,IAAP,CAAvB;EACD;;EAEDC,cAAc,CAACC,KAAD,EAAgB;IAC5B,KAAKvC,GAAL,CAASsC,cAAT,CAAwBC,KAAxB;EACD;;EAEDC,cAAc,CAACC,KAAD,EAAgB;IAC5B,KAAKzC,GAAL,CAASwC,cAAT,CAAwBC,KAAxB;EACD;;EAEDC,QAAQ,CAACC,KAAD,EAAoB;IAC1B,KAAK3C,GAAL,CAAS0C,QAAT,CAAkB;MAAEnC,KAAK,EAAEoC;IAAT,CAAlB;EACD;;AA3F2E"}
@@ -10,7 +10,7 @@ var _canvaskit = _interopRequireDefault(require("canvaskit-wasm/bin/full/canvask
10
10
  function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
11
11
 
12
12
  // eslint-disable-next-line @typescript-eslint/ban-ts-comment
13
- // @ts-expect-error
13
+ // @ts-ignore
14
14
  const LoadSkiaWeb = async opts => {
15
15
  if (global.CanvasKit !== undefined) {
16
16
  return;
@@ -1 +1 @@
1
- {"version":3,"names":["LoadSkiaWeb","opts","global","CanvasKit","undefined","CanvasKitInit","LoadSkia"],"sources":["LoadSkiaWeb.tsx"],"sourcesContent":["// eslint-disable-next-line @typescript-eslint/ban-ts-comment\n// @ts-expect-error\nimport CanvasKitInit from \"canvaskit-wasm/bin/full/canvaskit\";\nimport type {\n CanvasKit as CanvasKitType,\n CanvasKitInitOptions,\n} from \"canvaskit-wasm\";\n\ndeclare global {\n var CanvasKit: CanvasKitType;\n}\n\nexport const LoadSkiaWeb = async (opts?: CanvasKitInitOptions) => {\n if (global.CanvasKit !== undefined) {\n return;\n }\n const CanvasKit = await CanvasKitInit(opts);\n // The CanvasKit API is stored on the global object and used\n // to create the JsiSKApi in the Skia.web.ts file.\n global.CanvasKit = CanvasKit;\n};\n\n// We keep this function for backward compatibility\nexport const LoadSkia = LoadSkiaWeb;\n"],"mappings":";;;;;;;AAEA;;;;AAFA;AACA;AAWO,MAAMA,WAAW,GAAG,MAAOC,IAAP,IAAuC;EAChE,IAAIC,MAAM,CAACC,SAAP,KAAqBC,SAAzB,EAAoC;IAClC;EACD;;EACD,MAAMD,SAAS,GAAG,MAAM,IAAAE,kBAAA,EAAcJ,IAAd,CAAxB,CAJgE,CAKhE;EACA;;EACAC,MAAM,CAACC,SAAP,GAAmBA,SAAnB;AACD,CARM,C,CAUP;;;;AACO,MAAMG,QAAQ,GAAGN,WAAjB"}
1
+ {"version":3,"names":["LoadSkiaWeb","opts","global","CanvasKit","undefined","CanvasKitInit","LoadSkia"],"sources":["LoadSkiaWeb.tsx"],"sourcesContent":["// eslint-disable-next-line @typescript-eslint/ban-ts-comment\n// @ts-ignore\nimport CanvasKitInit from \"canvaskit-wasm/bin/full/canvaskit\";\nimport type {\n CanvasKit as CanvasKitType,\n CanvasKitInitOptions,\n} from \"canvaskit-wasm\";\n\ndeclare global {\n var CanvasKit: CanvasKitType;\n}\n\nexport const LoadSkiaWeb = async (opts?: CanvasKitInitOptions) => {\n if (global.CanvasKit !== undefined) {\n return;\n }\n const CanvasKit = await CanvasKitInit(opts);\n // The CanvasKit API is stored on the global object and used\n // to create the JsiSKApi in the Skia.web.ts file.\n global.CanvasKit = CanvasKit;\n};\n\n// We keep this function for backward compatibility\nexport const LoadSkia = LoadSkiaWeb;\n"],"mappings":";;;;;;;AAEA;;;;AAFA;AACA;AAWO,MAAMA,WAAW,GAAG,MAAOC,IAAP,IAAuC;EAChE,IAAIC,MAAM,CAACC,SAAP,KAAqBC,SAAzB,EAAoC;IAClC;EACD;;EACD,MAAMD,SAAS,GAAG,MAAM,IAAAE,kBAAA,EAAcJ,IAAd,CAAxB,CAJgE,CAKhE;EACA;;EACAC,MAAM,CAACC,SAAP,GAAmBA,SAAnB;AACD,CARM,C,CAUP;;;;AACO,MAAMG,QAAQ,GAAGN,WAAjB"}
@@ -103,7 +103,9 @@ export class JsiRenderNode extends JsiNode {
103
103
  } = this.props;
104
104
 
105
105
  if (color !== undefined || strokeWidth !== undefined || blendMode !== undefined || style !== undefined || strokeJoin !== undefined || strokeCap !== undefined || strokeMiter !== undefined || opacity !== undefined || antiAlias !== undefined) {
106
- ctx = {};
106
+ ctx = {
107
+ opacity: 1
108
+ };
107
109
 
108
110
  if (color !== undefined) {
109
111
  ctx.color = this.Skia.Color(color);
@@ -181,11 +183,10 @@ export class JsiRenderNode extends JsiNode {
181
183
  const {
182
184
  canvas
183
185
  } = parentCtx;
184
- const opacity = this.props.opacity !== undefined ? parentCtx.opacity * this.props.opacity : parentCtx.opacity;
185
186
 
186
187
  if (this.paintCache === null || this.paintCache.parent !== parentCtx.paint) {
187
188
  const paintCtx = this.getPaintCtx();
188
- const child = paintCtx ? concatPaint(parentCtx.paint, paintCtx, parentCtx.opacity) : parentCtx.paint;
189
+ const child = paintCtx ? concatPaint(parentCtx.paint.copy(), paintCtx) : parentCtx.paint;
189
190
  this.paintCache = {
190
191
  parent: parentCtx.paint,
191
192
  child
@@ -195,7 +196,6 @@ export class JsiRenderNode extends JsiNode {
195
196
  const paint = this.paintCache.child; // TODO: can we only recreate a new context here if needed?
196
197
 
197
198
  const ctx = { ...parentCtx,
198
- opacity,
199
199
  paint
200
200
  };
201
201
  const hasTransform = matrix !== undefined || transform !== undefined;
@@ -236,7 +236,7 @@ export class JsiRenderNode extends JsiNode {
236
236
 
237
237
  }
238
238
 
239
- const concatPaint = (parent, _ref, opacity) => {
239
+ const concatPaint = (paint, _ref) => {
240
240
  let {
241
241
  color,
242
242
  strokeWidth,
@@ -247,22 +247,22 @@ const concatPaint = (parent, _ref, opacity) => {
247
247
  imageFilter,
248
248
  maskFilter,
249
249
  pathEffect,
250
- opacity: alpha,
250
+ opacity,
251
251
  strokeCap,
252
252
  strokeJoin,
253
253
  strokeMiter,
254
254
  style
255
255
  } = _ref;
256
- const paint = parent.copy();
256
+
257
+ if (opacity !== undefined) {
258
+ paint.setAlphaf(paint.getAlphaf() * opacity);
259
+ }
257
260
 
258
261
  if (color !== undefined) {
262
+ const currentOpacity = paint.getAlphaf();
259
263
  paint.setShader(null);
260
- color[3] *= opacity;
261
264
  paint.setColor(color);
262
- } else {
263
- const cl = paint.getColor();
264
- cl[3] = opacity;
265
- paint.setColor(cl);
265
+ paint.setAlphaf(currentOpacity * paint.getAlphaf());
266
266
  }
267
267
 
268
268
  if (strokeWidth !== undefined) {
@@ -297,10 +297,6 @@ const concatPaint = (parent, _ref, opacity) => {
297
297
  paint.setPathEffect(pathEffect);
298
298
  }
299
299
 
300
- if (alpha !== undefined) {
301
- paint.setAlphaf(alpha * opacity);
302
- }
303
-
304
300
  if (strokeCap !== undefined) {
305
301
  paint.setStrokeCap(strokeCap);
306
302
  }
@@ -1 +1 @@
1
- {"version":3,"names":["StrokeCap","StrokeJoin","PaintStyle","BlendMode","ClipOp","isRRect","isPathDef","processPath","processTransformProps","JsiNode","JsiDeclarationNode","enumKey","paintProps","JsiRenderNode","constructor","ctx","type","props","matrix","Skia","Matrix","onPropChange","setProps","paintCache","setProp","key","value","hasChanged","includes","identity","clipPath","undefined","clipRect","clipRRect","computeMatrix","computeClip","addChild","child","setInvalidate","insertChildBefore","before","clip","getPaintCtx","color","strokeWidth","blendMode","style","strokeJoin","strokeCap","strokeMiter","opacity","antiAlias","Color","_children","forEach","isColorFilter","cf","materialize","colorFilter","ColorFilter","MakeCompose","isShader","shader","isPathEffect","pe","pathEffect","PathEffect","isImageFilter","filter","imageFilter","ImageFilter","isMaskFilter","maskFilter","render","parentCtx","invertClip","layer","transform","canvas","parent","paint","paintCtx","concatPaint","hasTransform","hasClip","shouldSave","op","Difference","Intersect","saveLayer","save","concat","renderNode","restore","alpha","copy","setShader","setColor","cl","getColor","setStrokeWidth","setAntiAlias","setBlendMode","setColorFilter","setImageFilter","setMaskFilter","setPathEffect","setAlphaf","setStrokeCap","setStrokeJoin","setStrokeMiter","setStyle"],"sources":["RenderNode.ts"],"sourcesContent":["import type {\n SkMatrix,\n SkRect,\n SkRRect,\n SkPath,\n SkPaint,\n} from \"../../skia/types\";\nimport {\n StrokeCap,\n StrokeJoin,\n PaintStyle,\n BlendMode,\n ClipOp,\n isRRect,\n} from \"../../skia/types\";\nimport type {\n RenderNode,\n GroupProps,\n DrawingContext,\n NodeType,\n Node,\n} from \"../types\";\n\nimport { isPathDef, processPath, processTransformProps } from \"./datatypes\";\nimport type { NodeContext } from \"./Node\";\nimport { JsiNode, JsiDeclarationNode } from \"./Node\";\nimport type { PaintContext } from \"./PaintContext\";\nimport { enumKey } from \"./datatypes/Enum\";\n\nconst paintProps = [\n \"color\",\n \"strokeWidth\",\n \"blendMode\",\n \"strokeCap\",\n \"strokeJoin\",\n \"strokeMiter\",\n \"style\",\n \"antiAlias\",\n \"opacity\",\n];\n\ninterface PaintCache {\n parent: SkPaint;\n child: SkPaint;\n}\n\nexport abstract class JsiRenderNode<P extends GroupProps>\n extends JsiNode<P>\n implements RenderNode<P>\n{\n paintCache: PaintCache | null = null;\n matrix: SkMatrix;\n clipRect?: SkRect;\n clipRRect?: SkRRect;\n clipPath?: SkPath;\n\n constructor(ctx: NodeContext, type: NodeType, props: P) {\n super(ctx, type, props);\n this.matrix = this.Skia.Matrix();\n this.onPropChange();\n }\n\n setProps(props: P) {\n super.setProps(props);\n this.onPropChange();\n this.paintCache = null;\n }\n\n setProp<K extends keyof P>(key: K, value: P[K]) {\n const hasChanged = super.setProp(key, value);\n if (hasChanged) {\n this.onPropChange();\n if (paintProps.includes(key as string)) {\n this.paintCache = null;\n }\n }\n return hasChanged;\n }\n\n protected onPropChange() {\n this.matrix.identity();\n this.clipPath = undefined;\n this.clipRect = undefined;\n this.clipRRect = undefined;\n this.computeMatrix();\n this.computeClip();\n }\n\n addChild(child: Node<unknown>) {\n if (child instanceof JsiDeclarationNode) {\n child.setInvalidate(() => (this.paintCache = null));\n }\n super.addChild(child);\n }\n\n insertChildBefore(child: Node<unknown>, before: Node<unknown>) {\n if (child instanceof JsiDeclarationNode) {\n child.setInvalidate(() => (this.paintCache = null));\n }\n super.insertChildBefore(child, before);\n }\n\n private computeClip() {\n const { clip } = this.props;\n if (clip) {\n if (isPathDef(clip)) {\n this.clipPath = processPath(this.Skia, clip);\n } else if (isRRect(clip)) {\n this.clipRRect = clip;\n } else {\n this.clipRect = clip;\n }\n }\n }\n\n private computeMatrix() {\n processTransformProps(this.matrix, this.props);\n }\n\n private getPaintCtx() {\n let ctx: PaintContext | undefined;\n const {\n color,\n strokeWidth,\n blendMode,\n style,\n strokeJoin,\n strokeCap,\n strokeMiter,\n opacity,\n antiAlias,\n } = this.props;\n if (\n color !== undefined ||\n strokeWidth !== undefined ||\n blendMode !== undefined ||\n style !== undefined ||\n strokeJoin !== undefined ||\n strokeCap !== undefined ||\n strokeMiter !== undefined ||\n opacity !== undefined ||\n antiAlias !== undefined\n ) {\n ctx = {};\n if (color !== undefined) {\n ctx.color = this.Skia.Color(color);\n }\n if (strokeWidth !== undefined) {\n ctx.strokeWidth = strokeWidth;\n }\n if (blendMode !== undefined) {\n ctx.blendMode = BlendMode[enumKey(blendMode)];\n }\n if (style !== undefined) {\n ctx.style = PaintStyle[enumKey(style)];\n }\n if (strokeJoin !== undefined) {\n ctx.strokeJoin = StrokeJoin[enumKey(strokeJoin)];\n }\n if (strokeCap !== undefined) {\n ctx.strokeCap = StrokeCap[enumKey(strokeCap)];\n }\n if (strokeMiter !== undefined) {\n ctx.strokeMiter = strokeMiter;\n }\n if (opacity !== undefined) {\n ctx.opacity = opacity;\n }\n if (antiAlias !== undefined) {\n ctx.antiAlias = antiAlias;\n }\n }\n this._children.forEach((child) => {\n if (child instanceof JsiDeclarationNode) {\n if (child.isColorFilter()) {\n ctx = ctx || {};\n const cf = child.materialize();\n ctx.colorFilter = ctx.colorFilter\n ? this.Skia.ColorFilter.MakeCompose(cf, ctx.colorFilter)\n : cf;\n } else if (child.isShader()) {\n ctx = ctx || {};\n const shader = child.materialize();\n ctx.shader = shader;\n } else if (child.isPathEffect()) {\n ctx = ctx || {};\n const pe = child.materialize();\n ctx.pathEffect = ctx.pathEffect\n ? this.Skia.PathEffect.MakeCompose(pe, ctx.pathEffect)\n : pe;\n } else if (child.isImageFilter()) {\n ctx = ctx || {};\n const filter = child.materialize();\n ctx.imageFilter = ctx.imageFilter\n ? this.Skia.ImageFilter.MakeCompose(filter, ctx.imageFilter)\n : filter;\n } else if (child.isMaskFilter()) {\n ctx = ctx || {};\n const filter = child.materialize();\n ctx.maskFilter = filter;\n }\n }\n });\n return ctx;\n }\n\n render(parentCtx: DrawingContext) {\n const { invertClip, layer, matrix, transform } = this.props;\n const { canvas } = parentCtx;\n\n const opacity =\n this.props.opacity !== undefined\n ? parentCtx.opacity * this.props.opacity\n : parentCtx.opacity;\n\n if (\n this.paintCache === null ||\n this.paintCache.parent !== parentCtx.paint\n ) {\n const paintCtx = this.getPaintCtx();\n const child = paintCtx\n ? concatPaint(parentCtx.paint, paintCtx, parentCtx.opacity)\n : parentCtx.paint;\n this.paintCache = { parent: parentCtx.paint, child };\n }\n const paint = this.paintCache.child;\n // TODO: can we only recreate a new context here if needed?\n const ctx = { ...parentCtx, opacity, paint };\n const hasTransform = matrix !== undefined || transform !== undefined;\n const hasClip =\n this.clipRect !== undefined ||\n this.clipPath !== undefined ||\n this.clipRRect !== undefined;\n const shouldSave = hasTransform || hasClip || !!layer;\n const op = invertClip ? ClipOp.Difference : ClipOp.Intersect;\n if (shouldSave) {\n if (layer) {\n if (typeof layer === \"boolean\") {\n canvas.saveLayer();\n } else {\n canvas.saveLayer(layer);\n }\n } else {\n canvas.save();\n }\n }\n\n if (this.matrix) {\n canvas.concat(this.matrix);\n }\n if (this.clipRect) {\n canvas.clipRect(this.clipRect, op, true);\n } else if (this.clipRRect) {\n canvas.clipRRect(this.clipRRect, op, true);\n } else if (this.clipPath) {\n canvas.clipPath(this.clipPath, op, true);\n }\n\n this.renderNode(ctx);\n\n if (shouldSave) {\n canvas.restore();\n }\n }\n\n abstract renderNode(ctx: DrawingContext): void;\n}\n\nconst concatPaint = (\n parent: SkPaint,\n {\n color,\n strokeWidth,\n shader,\n antiAlias,\n blendMode,\n colorFilter,\n imageFilter,\n maskFilter,\n pathEffect,\n opacity: alpha,\n strokeCap,\n strokeJoin,\n strokeMiter,\n style,\n }: PaintContext,\n opacity: number\n) => {\n const paint = parent.copy();\n if (color !== undefined) {\n paint.setShader(null);\n color[3] *= opacity;\n paint.setColor(color);\n } else {\n const cl = paint.getColor();\n cl[3] = opacity;\n paint.setColor(cl);\n }\n if (strokeWidth !== undefined) {\n paint.setStrokeWidth(strokeWidth);\n }\n if (shader !== undefined) {\n paint.setShader(shader);\n }\n if (antiAlias !== undefined) {\n paint.setAntiAlias(antiAlias);\n }\n if (blendMode !== undefined) {\n paint.setBlendMode(blendMode);\n }\n if (colorFilter !== undefined) {\n paint.setColorFilter(colorFilter);\n }\n if (imageFilter !== undefined) {\n paint.setImageFilter(imageFilter);\n }\n if (maskFilter !== undefined) {\n paint.setMaskFilter(maskFilter);\n }\n if (pathEffect !== undefined) {\n paint.setPathEffect(pathEffect);\n }\n if (alpha !== undefined) {\n paint.setAlphaf(alpha * opacity);\n }\n if (strokeCap !== undefined) {\n paint.setStrokeCap(strokeCap);\n }\n if (strokeJoin !== undefined) {\n paint.setStrokeJoin(strokeJoin);\n }\n if (strokeMiter !== undefined) {\n paint.setStrokeMiter(strokeMiter);\n }\n if (style !== undefined) {\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AAK,CAAC0B,aAAN,CAAoBzC,UAApB;EACD;;EACD,IAAI6B,KAAK,KAAK/D,SAAd,EAAyB;IACvBiD,KAAK,CAAC2B,SAAN,CAAgBb,KAAK,GAAG5C,OAAxB;EACD;;EACD,IAAIF,SAAS,KAAKjB,SAAlB,EAA6B;IAC3BiD,KAAK,CAAC4B,YAAN,CAAmB5D,SAAnB;EACD;;EACD,IAAID,UAAU,KAAKhB,SAAnB,EAA8B;IAC5BiD,KAAK,CAAC6B,aAAN,CAAoB9D,UAApB;EACD;;EACD,IAAIE,WAAW,KAAKlB,SAApB,EAA+B;IAC7BiD,KAAK,CAAC8B,cAAN,CAAqB7D,WAArB;EACD;;EACD,IAAIH,KAAK,KAAKf,SAAd,EAAyB;IACvBiD,KAAK,CAAC+B,QAAN,CAAejE,KAAf;EACD;;EACD,OAAOkC,KAAP;AACD,CAtED"}
1
+ {"version":3,"names":["StrokeCap","StrokeJoin","PaintStyle","BlendMode","ClipOp","isRRect","isPathDef","processPath","processTransformProps","JsiNode","JsiDeclarationNode","enumKey","paintProps","JsiRenderNode","constructor","ctx","type","props","matrix","Skia","Matrix","onPropChange","setProps","paintCache","setProp","key","value","hasChanged","includes","identity","clipPath","undefined","clipRect","clipRRect","computeMatrix","computeClip","addChild","child","setInvalidate","insertChildBefore","before","clip","getPaintCtx","color","strokeWidth","blendMode","style","strokeJoin","strokeCap","strokeMiter","opacity","antiAlias","Color","_children","forEach","isColorFilter","cf","materialize","colorFilter","ColorFilter","MakeCompose","isShader","shader","isPathEffect","pe","pathEffect","PathEffect","isImageFilter","filter","imageFilter","ImageFilter","isMaskFilter","maskFilter","render","parentCtx","invertClip","layer","transform","canvas","parent","paint","paintCtx","concatPaint","copy","hasTransform","hasClip","shouldSave","op","Difference","Intersect","saveLayer","save","concat","renderNode","restore","setAlphaf","getAlphaf","currentOpacity","setShader","setColor","setStrokeWidth","setAntiAlias","setBlendMode","setColorFilter","setImageFilter","setMaskFilter","setPathEffect","setStrokeCap","setStrokeJoin","setStrokeMiter","setStyle"],"sources":["RenderNode.ts"],"sourcesContent":["import type {\n SkMatrix,\n SkRect,\n SkRRect,\n SkPath,\n SkPaint,\n} from \"../../skia/types\";\nimport {\n StrokeCap,\n StrokeJoin,\n PaintStyle,\n BlendMode,\n ClipOp,\n isRRect,\n} from \"../../skia/types\";\nimport type {\n RenderNode,\n GroupProps,\n DrawingContext,\n NodeType,\n Node,\n} from \"../types\";\n\nimport { isPathDef, processPath, processTransformProps } from \"./datatypes\";\nimport type { NodeContext } from \"./Node\";\nimport { JsiNode, JsiDeclarationNode } from \"./Node\";\nimport type { PaintContext } from \"./PaintContext\";\nimport { enumKey } from \"./datatypes/Enum\";\n\nconst paintProps = [\n \"color\",\n \"strokeWidth\",\n \"blendMode\",\n \"strokeCap\",\n \"strokeJoin\",\n \"strokeMiter\",\n \"style\",\n \"antiAlias\",\n \"opacity\",\n];\n\ninterface PaintCache {\n parent: SkPaint;\n child: SkPaint;\n}\n\nexport abstract class JsiRenderNode<P extends GroupProps>\n extends JsiNode<P>\n implements RenderNode<P>\n{\n paintCache: PaintCache | null = null;\n matrix: SkMatrix;\n clipRect?: SkRect;\n clipRRect?: SkRRect;\n clipPath?: SkPath;\n\n constructor(ctx: NodeContext, type: NodeType, props: P) {\n super(ctx, type, props);\n this.matrix = this.Skia.Matrix();\n this.onPropChange();\n }\n\n setProps(props: P) {\n super.setProps(props);\n this.onPropChange();\n this.paintCache = null;\n }\n\n setProp<K extends keyof P>(key: K, value: P[K]) {\n const hasChanged = super.setProp(key, value);\n if (hasChanged) {\n this.onPropChange();\n if (paintProps.includes(key as string)) {\n this.paintCache = null;\n }\n }\n return hasChanged;\n }\n\n protected onPropChange() {\n this.matrix.identity();\n this.clipPath = undefined;\n this.clipRect = undefined;\n this.clipRRect = undefined;\n this.computeMatrix();\n this.computeClip();\n }\n\n addChild(child: Node<unknown>) {\n if (child instanceof JsiDeclarationNode) {\n child.setInvalidate(() => (this.paintCache = null));\n }\n super.addChild(child);\n }\n\n insertChildBefore(child: Node<unknown>, before: Node<unknown>) {\n if (child instanceof JsiDeclarationNode) {\n child.setInvalidate(() => (this.paintCache = null));\n }\n super.insertChildBefore(child, before);\n }\n\n private computeClip() {\n const { clip } = this.props;\n if (clip) {\n if (isPathDef(clip)) {\n this.clipPath = processPath(this.Skia, clip);\n } else if (isRRect(clip)) {\n this.clipRRect = clip;\n } else {\n this.clipRect = clip;\n }\n }\n }\n\n private computeMatrix() {\n processTransformProps(this.matrix, this.props);\n }\n\n private getPaintCtx() {\n let ctx: PaintContext | undefined;\n const {\n color,\n strokeWidth,\n blendMode,\n style,\n strokeJoin,\n strokeCap,\n strokeMiter,\n opacity,\n antiAlias,\n } = this.props;\n if (\n color !== undefined ||\n strokeWidth !== undefined ||\n blendMode !== undefined ||\n style !== undefined ||\n strokeJoin !== undefined ||\n strokeCap !== undefined ||\n strokeMiter !== undefined ||\n opacity !== undefined ||\n antiAlias !== undefined\n ) {\n ctx = { opacity: 1 };\n if (color !== undefined) {\n ctx.color = this.Skia.Color(color);\n }\n if (strokeWidth !== undefined) {\n ctx.strokeWidth = strokeWidth;\n }\n if (blendMode !== undefined) {\n ctx.blendMode = BlendMode[enumKey(blendMode)];\n }\n if (style !== undefined) {\n ctx.style = PaintStyle[enumKey(style)];\n }\n if (strokeJoin !== undefined) {\n ctx.strokeJoin = StrokeJoin[enumKey(strokeJoin)];\n }\n if (strokeCap !== undefined) {\n ctx.strokeCap = StrokeCap[enumKey(strokeCap)];\n }\n if (strokeMiter !== undefined) {\n ctx.strokeMiter = strokeMiter;\n }\n if (opacity !== undefined) {\n ctx.opacity = opacity;\n }\n if (antiAlias !== undefined) {\n ctx.antiAlias = antiAlias;\n }\n }\n this._children.forEach((child) => {\n if (child instanceof JsiDeclarationNode) {\n if (child.isColorFilter()) {\n ctx = ctx || {};\n const cf = child.materialize();\n ctx.colorFilter = ctx.colorFilter\n ? this.Skia.ColorFilter.MakeCompose(cf, ctx.colorFilter)\n : cf;\n } else if (child.isShader()) {\n ctx = ctx || {};\n const shader = child.materialize();\n ctx.shader = shader;\n } else if (child.isPathEffect()) {\n ctx = ctx || {};\n const pe = child.materialize();\n ctx.pathEffect = ctx.pathEffect\n ? this.Skia.PathEffect.MakeCompose(pe, ctx.pathEffect)\n : pe;\n } else if (child.isImageFilter()) {\n ctx = ctx || {};\n const filter = child.materialize();\n ctx.imageFilter = ctx.imageFilter\n ? this.Skia.ImageFilter.MakeCompose(filter, ctx.imageFilter)\n : filter;\n } else if (child.isMaskFilter()) {\n ctx = ctx || {};\n const filter = child.materialize();\n ctx.maskFilter = filter;\n }\n }\n });\n return ctx;\n }\n\n render(parentCtx: DrawingContext) {\n const { invertClip, layer, matrix, transform } = this.props;\n const { canvas } = parentCtx;\n\n if (\n this.paintCache === null ||\n this.paintCache.parent !== parentCtx.paint\n ) {\n const paintCtx = this.getPaintCtx();\n const child = paintCtx\n ? concatPaint(parentCtx.paint.copy(), paintCtx)\n : parentCtx.paint;\n this.paintCache = { parent: parentCtx.paint, child };\n }\n const paint = this.paintCache.child;\n // TODO: can we only recreate a new context here if needed?\n const ctx = { ...parentCtx, paint };\n const hasTransform = matrix !== undefined || transform !== undefined;\n const hasClip =\n this.clipRect !== undefined ||\n this.clipPath !== undefined ||\n this.clipRRect !== undefined;\n const shouldSave = hasTransform || hasClip || !!layer;\n const op = invertClip ? ClipOp.Difference : ClipOp.Intersect;\n if (shouldSave) {\n if (layer) {\n if (typeof layer === \"boolean\") {\n canvas.saveLayer();\n } else {\n canvas.saveLayer(layer);\n }\n } else {\n canvas.save();\n }\n }\n\n if (this.matrix) {\n canvas.concat(this.matrix);\n }\n if (this.clipRect) {\n canvas.clipRect(this.clipRect, op, true);\n } else if (this.clipRRect) {\n canvas.clipRRect(this.clipRRect, op, true);\n } else if (this.clipPath) {\n canvas.clipPath(this.clipPath, op, true);\n }\n\n this.renderNode(ctx);\n\n if (shouldSave) {\n canvas.restore();\n }\n }\n\n abstract renderNode(ctx: DrawingContext): void;\n}\n\nconst concatPaint = (\n paint: SkPaint,\n {\n color,\n strokeWidth,\n shader,\n antiAlias,\n blendMode,\n colorFilter,\n imageFilter,\n maskFilter,\n pathEffect,\n opacity,\n strokeCap,\n strokeJoin,\n strokeMiter,\n style,\n }: PaintContext\n) => {\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(color);\n paint.setAlphaf(currentOpacity * paint.getAlphaf());\n }\n if (strokeWidth !== undefined) {\n paint.setStrokeWidth(strokeWidth);\n }\n if (shader !== undefined) {\n paint.setShader(shader);\n }\n if (antiAlias !== undefined) {\n paint.setAntiAlias(antiAlias);\n }\n if (blendMode !== undefined) {\n paint.setBlendMode(blendMode);\n }\n if (colorFilter !== undefined) {\n paint.setColorFilter(colorFilter);\n }\n if (imageFilter !== undefined) {\n paint.setImageFilter(imageFilter);\n }\n if (maskFilter !== undefined) {\n paint.setMaskFilter(maskFilter);\n }\n if (pathEffect !== undefined) {\n paint.setPathEffect(pathEffect);\n }\n if (strokeCap !== undefined) {\n paint.setStrokeCap(strokeCap);\n }\n if (strokeJoin !== undefined) {\n paint.setStrokeJoin(strokeJoin);\n }\n if (strokeMiter !== undefined) {\n paint.setStrokeMiter(strokeMiter);\n }\n if (style !== undefined) {\n paint.setStyle(style);\n }\n return paint;\n};\n"],"mappings":";;AAOA,SACEA,SADF,EAEEC,UAFF,EAGEC,UAHF,EAIEC,SAJF,EAKEC,MALF,EAMEC,OANF,QAOO,kBAPP;AAgBA,SAASC,SAAT,EAAoBC,WAApB,EAAiCC,qBAAjC,QAA8D,aAA9D;AAEA,SAASC,OAAT,EAAkBC,kBAAlB,QAA4C,QAA5C;AAEA,SAASC,OAAT,QAAwB,kBAAxB;AAEA,MAAMC,UAAU,GAAG,CACjB,OADiB,EAEjB,aAFiB,EAGjB,WAHiB,EAIjB,WAJiB,EAKjB,YALiB,EAMjB,aANiB,EAOj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CAACoB,cAAN,CAAqBxD,WAArB;EACD;;EACD,IAAIkB,MAAM,KAAK/B,SAAf,EAA0B;IACxBiD,KAAK,CAACkB,SAAN,CAAgBpC,MAAhB;EACD;;EACD,IAAIX,SAAS,KAAKpB,SAAlB,EAA6B;IAC3BiD,KAAK,CAACqB,YAAN,CAAmBlD,SAAnB;EACD;;EACD,IAAIN,SAAS,KAAKd,SAAlB,EAA6B;IAC3BiD,KAAK,CAACsB,YAAN,CAAmBzD,SAAnB;EACD;;EACD,IAAIa,WAAW,KAAK3B,SAApB,EAA+B;IAC7BiD,KAAK,CAACuB,cAAN,CAAqB7C,WAArB;EACD;;EACD,IAAIW,WAAW,KAAKtC,SAApB,EAA+B;IAC7BiD,KAAK,CAACwB,cAAN,CAAqBnC,WAArB;EACD;;EACD,IAAIG,UAAU,KAAKzC,SAAnB,EAA8B;IAC5BiD,KAAK,CAACyB,aAAN,CAAoBjC,UAApB;EACD;;EACD,IAAIP,UAAU,KAAKlC,SAAnB,EAA8B;IAC5BiD,KAAK,CAAC0B,aAAN,CAAoBzC,UAApB;EACD;;EACD,IAAIjB,SAAS,KAAKjB,SAAlB,EAA6B;IAC3BiD,KAAK,CAAC2B,YAAN,CAAmB3D,SAAnB;EACD;;EACD,IAAID,UAAU,KAAKhB,SAAnB,EAA8B;IAC5BiD,KAAK,CAAC4B,aAAN,CAAoB7D,UAApB;EACD;;EACD,IAAIE,WAAW,KAAKlB,SAApB,EAA+B;IAC7BiD,KAAK,CAAC6B,cAAN,CAAqB5D,WAArB;EACD;;EACD,IAAIH,KAAK,KAAKf,SAAd,EAAyB;IACvBiD,KAAK,CAAC8B,QAAN,CAAehE,KAAf;EACD;;EACD,OAAOkC,KAAP;AACD,CAjED"}
@@ -1,7 +1,6 @@
1
1
  export * from "./Enum";
2
2
  export * from "./Path";
3
3
  export * from "./Fitting";
4
- export * from "./Color";
5
4
  export * from "./Rect";
6
5
  export * from "./Radius";
7
6
  export * from "./Circle";
@@ -1 +1 @@
1
- {"version":3,"names":[],"sources":["index.ts"],"sourcesContent":["export * from \"./Enum\";\nexport * from \"./Path\";\nexport * from \"./Fitting\";\nexport * from \"./Color\";\nexport * from \"./Rect\";\nexport * from \"./Radius\";\nexport * from \"./Circle\";\nexport * from \"./Gradient\";\nexport * from \"./Transform\";\n"],"mappings":"AAAA,cAAc,QAAd;AACA,cAAc,QAAd;AACA,cAAc,WAAd;AACA,cAAc,SAAd;AACA,cAAc,QAAd;AACA,cAAc,UAAd;AACA,cAAc,UAAd;AACA,cAAc,YAAd;AACA,cAAc,aAAd"}
1
+ {"version":3,"names":[],"sources":["index.ts"],"sourcesContent":["export * from \"./Enum\";\nexport * from \"./Path\";\nexport * from \"./Fitting\";\nexport * from \"./Rect\";\nexport * from \"./Radius\";\nexport * from \"./Circle\";\nexport * from \"./Gradient\";\nexport * from \"./Transform\";\n"],"mappings":"AAAA,cAAc,QAAd;AACA,cAAc,QAAd;AACA,cAAc,WAAd;AACA,cAAc,QAAd;AACA,cAAc,UAAd;AACA,cAAc,UAAd;AACA,cAAc,YAAd;AACA,cAAc,aAAd"}
@@ -1,7 +1,6 @@
1
1
  import { BlurStyle, ClipOp, isRRect } from "../../../skia/types";
2
2
  import { DeclarationType, NodeType } from "../../types";
3
3
  import { JsiDeclarationNode } from "../Node";
4
- import { processColor } from "../datatypes";
5
4
  import { JsiRenderNode } from "../RenderNode";
6
5
 
7
6
  const inflate = function (Skia, box, dx, dy) {
@@ -34,12 +33,12 @@ export class BoxNode extends JsiRenderNode {
34
33
  renderNode(_ref) {
35
34
  let {
36
35
  canvas,
37
- paint,
38
- opacity
36
+ paint
39
37
  } = _ref;
40
38
  const {
41
39
  box: defaultBox
42
40
  } = this.props;
41
+ const opacity = paint.getAlphaf();
43
42
  const box = isRRect(defaultBox) ? defaultBox : this.Skia.RRectXY(defaultBox, 0, 0);
44
43
 
45
44
  const shadows = this._children.map(node => {
@@ -59,7 +58,8 @@ export class BoxNode extends JsiRenderNode {
59
58
  dy = 0
60
59
  } = shadow;
61
60
  const lPaint = this.Skia.Paint();
62
- lPaint.setColor(processColor(this.Skia, color, opacity));
61
+ lPaint.setColor(this.Skia.Color(color));
62
+ lPaint.setAlphaf(paint.getAlphaf() * opacity);
63
63
  lPaint.setMaskFilter(this.Skia.MaskFilter.MakeBlur(BlurStyle.Normal, blur, true));
64
64
  canvas.drawRRect(inflate(this.Skia, box, spread, spread, dx, dy), lPaint);
65
65
  });
@@ -76,7 +76,8 @@ export class BoxNode extends JsiRenderNode {
76
76
  canvas.save();
77
77
  canvas.clipRRect(box, ClipOp.Intersect, false);
78
78
  const lPaint = this.Skia.Paint();
79
- lPaint.setColor(processColor(this.Skia, color, opacity));
79
+ lPaint.setColor(this.Skia.Color(color));
80
+ lPaint.setAlphaf(paint.getAlphaf() * opacity);
80
81
  lPaint.setMaskFilter(this.Skia.MaskFilter.MakeBlur(BlurStyle.Normal, blur, true));
81
82
  const inner = deflate(this.Skia, box, spread, spread, dx, dy);
82
83
  const outer = inflate(this.Skia, box, delta.x, delta.y);
@@ -1 +1 @@
1
- {"version":3,"names":["BlurStyle","ClipOp","isRRect","DeclarationType","NodeType","JsiDeclarationNode","processColor","JsiRenderNode","inflate","Skia","box","dx","dy","tx","ty","RRectXY","XYWHRect","rect","x","y","width","height","rx","ry","deflate","BoxShadowNode","constructor","ctx","props","Unknown","Box","materialize","BoxNode","renderNode","canvas","paint","opacity","defaultBox","shadows","_children","map","node","filter","n","shadow","inner","color","blur","spread","lPaint","Paint","setColor","setMaskFilter","MaskFilter","MakeBlur","Normal","drawRRect","delta","Point","Math","abs","save","clipRRect","Intersect","outer","drawDRRect","restore"],"sources":["Box.ts"],"sourcesContent":["import type { SkRRect, Skia } from \"../../../skia/types\";\nimport { BlurStyle, ClipOp, isRRect } from \"../../../skia/types\";\nimport type { DrawingContext } from \"../../types\";\nimport { DeclarationType, NodeType } from \"../../types\";\nimport type { BoxShadowProps, BoxProps } from \"../../types/Drawings\";\nimport type { NodeContext } from \"../Node\";\nimport { JsiDeclarationNode } from \"../Node\";\nimport { processColor } from \"../datatypes\";\nimport { JsiRenderNode } from \"../RenderNode\";\n\nconst inflate = (\n Skia: Skia,\n box: SkRRect,\n dx: number,\n dy: number,\n tx = 0,\n ty = 0\n) =>\n Skia.RRectXY(\n Skia.XYWHRect(\n box.rect.x - dx + tx,\n box.rect.y - dy + ty,\n box.rect.width + 2 * dx,\n box.rect.height + 2 * dy\n ),\n box.rx + dx,\n box.ry + dy\n );\n\nconst deflate = (\n Skia: Skia,\n box: SkRRect,\n dx: number,\n dy: number,\n tx = 0,\n ty = 0\n) => inflate(Skia, box, -dx, -dy, tx, ty);\n\nexport class BoxShadowNode extends JsiDeclarationNode<\n BoxShadowProps,\n BoxShadowProps\n> {\n constructor(ctx: NodeContext, props: BoxShadowProps) {\n super(ctx, DeclarationType.Unknown, NodeType.Box, props);\n }\n\n materialize() {\n return this.props;\n }\n}\n\nexport class BoxNode extends JsiRenderNode<BoxProps> {\n constructor(ctx: NodeContext, props: BoxProps) {\n super(ctx, NodeType.Box, props);\n }\n\n renderNode({ canvas, paint, opacity }: DrawingContext) {\n const { box: defaultBox } = this.props;\n const box = isRRect(defaultBox)\n ? defaultBox\n : this.Skia.RRectXY(defaultBox, 0, 0);\n const shadows = this._children\n .map((node) => {\n if (node instanceof BoxShadowNode) {\n return node.materialize();\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 = this.Skia.Paint();\n lPaint.setColor(processColor(this.Skia, color, opacity));\n lPaint.setMaskFilter(\n this.Skia.MaskFilter.MakeBlur(BlurStyle.Normal, blur, true)\n );\n canvas.drawRRect(\n inflate(this.Skia, box, spread, spread, dx, dy),\n lPaint\n );\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 = this.Skia.Point(10 + Math.abs(dx), 10 + Math.abs(dy));\n canvas.save();\n canvas.clipRRect(box, ClipOp.Intersect, false);\n const lPaint = this.Skia.Paint();\n lPaint.setColor(processColor(this.Skia, color, opacity));\n lPaint.setMaskFilter(\n this.Skia.MaskFilter.MakeBlur(BlurStyle.Normal, blur, true)\n );\n const inner = deflate(this.Skia, box, spread, spread, dx, dy);\n const outer = inflate(this.Skia, box, delta.x, delta.y);\n canvas.drawDRRect(outer, inner, lPaint);\n canvas.restore();\n });\n }\n}\n"],"mappings":"AACA,SAASA,SAAT,EAAoBC,MAApB,EAA4BC,OAA5B,QAA2C,qBAA3C;AAEA,SAASC,eAAT,EAA0BC,QAA1B,QAA0C,aAA1C;AAGA,SAASC,kBAAT,QAAmC,SAAnC;AACA,SAASC,YAAT,QAA6B,cAA7B;AACA,SAASC,aAAT,QAA8B,eAA9B;;AAEA,MAAMC,OAAO,GAAG,UACdC,IADc,EAEdC,GAFc,EAGdC,EAHc,EAIdC,EAJc;EAAA,IAKdC,EALc,uEAKT,CALS;EAAA,IAMdC,EANc,uEAMT,CANS;EAAA,OAQdL,IAAI,CAACM,OAAL,CACEN,IAAI,CAACO,QAAL,CACEN,GAAG,CAACO,IAAJ,CAASC,CAAT,GAAaP,EAAb,GAAkBE,EADpB,EAEEH,GAAG,CAACO,IAAJ,CAASE,CAAT,GAAaP,EAAb,GAAkBE,EAFpB,EAGEJ,GAAG,CAACO,IAAJ,CAASG,KAAT,GAAiB,IAAIT,EAHvB,EAIED,GAAG,CAACO,IAAJ,CAASI,MAAT,GAAkB,IAAIT,EAJxB,CADF,EAOEF,GAAG,CAACY,EAAJ,GAASX,EAPX,EAQED,GAAG,CAACa,EAAJ,GAASX,EARX,CARc;AAAA,CAAhB;;AAmBA,MAAMY,OAAO,GAAG,UACdf,IADc,EAEdC,GAFc,EAGdC,EAHc,EAIdC,EAJc;EAAA,IAKdC,EALc,uEAKT,CALS;EAAA,IAMd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C,KAAV,EAAf;MACAD,MAAM,CAACE,QAAP,CAAgB7C,YAAY,CAAC,KAAKG,IAAN,EAAYqC,KAAZ,EAAmBV,OAAnB,CAA5B;MACAa,MAAM,CAACG,aAAP,CACE,KAAK3C,IAAL,CAAU4C,UAAV,CAAqBC,QAArB,CAA8BtD,SAAS,CAACuD,MAAxC,EAAgDR,IAAhD,EAAsD,IAAtD,CADF;MAGA,MAAMF,KAAK,GAAGrB,OAAO,CAAC,KAAKf,IAAN,EAAYC,GAAZ,EAAiBsC,MAAjB,EAAyBA,MAAzB,EAAiCrC,EAAjC,EAAqCC,EAArC,CAArB;MACA,MAAMoD,KAAK,GAAGxD,OAAO,CAAC,KAAKC,IAAN,EAAYC,GAAZ,EAAiB+C,KAAK,CAACvC,CAAvB,EAA0BuC,KAAK,CAACtC,CAAhC,CAArB;MACAe,MAAM,CAAC+B,UAAP,CAAkBD,KAAlB,EAAyBnB,KAAzB,EAAgCI,MAAhC;MACAf,MAAM,CAACgC,OAAP;IACD,CAhBH;EAiBD;;AApDkD"}
1
+ {"version":3,"names":["BlurStyle","ClipOp","isRRect","DeclarationType","NodeType","JsiDeclarationNode","JsiRenderNode","inflate","Skia","box","dx","dy","tx","ty","RRectXY","XYWHRect","rect","x","y","width","height","rx","ry","deflate","BoxShadowNode","constructor","ctx","props","Unknown","Box","materialize","BoxNode","renderNode","canvas","paint","defaultBox","opacity","getAlphaf","shadows","_children","map","node","filter","n","shadow","inner","color","blur","spread","lPaint","Paint","setColor","Color","setAlphaf","setMaskFilter","MaskFilter","MakeBlur","Normal","drawRRect","delta","Point","Math","abs","save","clipRRect","Intersect","outer","drawDRRect","restore"],"sources":["Box.ts"],"sourcesContent":["import type { SkRRect, Skia } from \"../../../skia/types\";\nimport { BlurStyle, ClipOp, isRRect } from \"../../../skia/types\";\nimport type { DrawingContext } from \"../../types\";\nimport { DeclarationType, NodeType } from \"../../types\";\nimport type { BoxShadowProps, BoxProps } from \"../../types/Drawings\";\nimport type { NodeContext } from \"../Node\";\nimport { JsiDeclarationNode } from \"../Node\";\nimport { JsiRenderNode } from \"../RenderNode\";\n\nconst inflate = (\n Skia: Skia,\n box: SkRRect,\n dx: number,\n dy: number,\n tx = 0,\n ty = 0\n) =>\n Skia.RRectXY(\n Skia.XYWHRect(\n box.rect.x - dx + tx,\n box.rect.y - dy + ty,\n box.rect.width + 2 * dx,\n box.rect.height + 2 * dy\n ),\n box.rx + dx,\n box.ry + dy\n );\n\nconst deflate = (\n Skia: Skia,\n box: SkRRect,\n dx: number,\n dy: number,\n tx = 0,\n ty = 0\n) => inflate(Skia, box, -dx, -dy, tx, ty);\n\nexport class BoxShadowNode extends JsiDeclarationNode<\n BoxShadowProps,\n BoxShadowProps\n> {\n constructor(ctx: NodeContext, props: BoxShadowProps) {\n super(ctx, DeclarationType.Unknown, NodeType.Box, props);\n }\n\n materialize() {\n return this.props;\n }\n}\n\nexport class BoxNode extends JsiRenderNode<BoxProps> {\n constructor(ctx: NodeContext, props: BoxProps) {\n super(ctx, NodeType.Box, props);\n }\n\n renderNode({ canvas, paint }: DrawingContext) {\n const { box: defaultBox } = this.props;\n const opacity = paint.getAlphaf();\n const box = isRRect(defaultBox)\n ? defaultBox\n : this.Skia.RRectXY(defaultBox, 0, 0);\n const shadows = this._children\n .map((node) => {\n if (node instanceof BoxShadowNode) {\n return node.materialize();\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 = this.Skia.Paint();\n lPaint.setColor(this.Skia.Color(color));\n lPaint.setAlphaf(paint.getAlphaf() * opacity);\n lPaint.setMaskFilter(\n this.Skia.MaskFilter.MakeBlur(BlurStyle.Normal, blur, true)\n );\n canvas.drawRRect(\n inflate(this.Skia, box, spread, spread, dx, dy),\n lPaint\n );\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 = this.Skia.Point(10 + Math.abs(dx), 10 + Math.abs(dy));\n canvas.save();\n canvas.clipRRect(box, ClipOp.Intersect, false);\n const lPaint = this.Skia.Paint();\n lPaint.setColor(this.Skia.Color(color));\n lPaint.setAlphaf(paint.getAlphaf() * opacity);\n\n lPaint.setMaskFilter(\n this.Skia.MaskFilter.MakeBlur(BlurStyle.Normal, blur, true)\n );\n const inner = deflate(this.Skia, box, spread, spread, dx, dy);\n const outer = inflate(this.Skia, box, delta.x, delta.y);\n canvas.drawDRRect(outer, inner, lPaint);\n canvas.restore();\n });\n }\n}\n"],"mappings":"AACA,SAASA,SAAT,EAAoBC,MAApB,EAA4BC,OAA5B,QAA2C,qBAA3C;AAEA,SAASC,eAAT,EAA0BC,QAA1B,QAA0C,aAA1C;AAGA,SAASC,kBAAT,QAAmC,SAAnC;AACA,SAASC,aAAT,QAA8B,eAA9B;;AAEA,MAAMC,OAAO,GAAG,UACdC,IADc,EAEdC,GAFc,EAGdC,EAHc,EAIdC,EAJc;EAAA,IAKdC,EALc,uEAKT,CALS;EAAA,IAMdC,EANc,uEAMT,CANS;EAAA,OAQdL,IAAI,CAACM,OAAL,CACEN,IAAI,CAACO,QAAL,CACEN,GAAG,CAACO,IAAJ,CAASC,CAAT,GAAaP,EAAb,GAAkBE,EADpB,EAEEH,GAAG,CAACO,IAAJ,CAASE,CAAT,GAAaP,EAAb,GAAkBE,EAFpB,EAGEJ,GAAG,CAACO,IAAJ,CAASG,KAAT,GAAiB,IAAIT,EAHvB,EAIED,GAAG,CAACO,IAAJ,CAASI,MAAT,GAAkB,IAAIT,EAJxB,CADF,EAOEF,GAAG,CAACY,EAAJ,GAASX,EAPX,EAQED,GAAG,CAACa,EAAJ,GAASX,EARX,CARc;AAAA,CAAhB;;AAmBA,MAAMY,OAAO,GAAG,UACdf,IADc,EAEdC,GAFc,EAGdC,EAHc,EAIdC,EAJc;EAAA,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,CAAC+B,SAAP,CAAiBvD,GAAjB,EAAsBR,MAAM,CAACgE,SAA7B,EAAwC,KAAxC;MACA,MAAMhB,MAAM,GAAG,KAAKzC,IAAL,CAAU0C,KAAV,EAAf;MACAD,MAAM,CAACE,QAAP,CAAgB,KAAK3C,IAAL,CAAU4C,KAAV,CAAgBN,KAAhB,CAAhB;MACAG,MAAM,CAACI,SAAP,CAAiBnB,KAAK,CAACG,SAAN,KAAoBD,OAArC;MAEAa,MAAM,CAACK,aAAP,CACE,KAAK9C,IAAL,CAAU+C,UAAV,CAAqBC,QAArB,CAA8BxD,SAAS,CAACyD,MAAxC,EAAgDV,IAAhD,EAAsD,IAAtD,CADF;MAGA,MAAMF,KAAK,GAAGtB,OAAO,CAAC,KAAKf,IAAN,EAAYC,GAAZ,EAAiBuC,MAAjB,EAAyBA,MAAzB,EAAiCtC,EAAjC,EAAqCC,EAArC,CAArB;MACA,MAAMuD,KAAK,GAAG3D,OAAO,CAAC,KAAKC,IAAN,EAAYC,GAAZ,EAAiBkD,KAAK,CAAC1C,CAAvB,EAA0B0C,KAAK,CAACzC,CAAhC,CAArB;MACAe,MAAM,CAACkC,UAAP,CAAkBD,KAAlB,EAAyBrB,KAAzB,EAAgCI,MAAhC;MACAhB,MAAM,CAACmC,OAAP;IACD,CAlBH;EAmBD;;AAxDkD"}
@@ -1,6 +1,6 @@
1
1
  import { BlendMode } from "../../../skia/types";
2
2
  import { NodeType } from "../../types";
3
- import { ALPHA, enumKey, processColor } from "../datatypes";
3
+ import { enumKey } from "../datatypes";
4
4
  import { JsiDrawingNode } from "../DrawingNode";
5
5
  export class PatchNode extends JsiDrawingNode {
6
6
  constructor(ctx, props) {
@@ -23,15 +23,14 @@ export class PatchNode extends JsiDrawingNode {
23
23
  return {
24
24
  mode,
25
25
  points: [patch[0].pos, patch[0].c2, patch[1].c1, patch[1].pos, patch[1].c2, patch[2].c1, patch[2].pos, patch[2].c2, patch[3].c1, patch[3].pos, patch[3].c2, patch[0].c1],
26
- colors: colors ? colors.map(c => processColor(this.Skia, c, 1)) : undefined
26
+ colors: colors ? colors.map(c => this.Skia.Color(c)) : undefined
27
27
  };
28
28
  }
29
29
 
30
30
  draw(_ref) {
31
31
  let {
32
32
  canvas,
33
- paint,
34
- opacity
33
+ paint
35
34
  } = _ref;
36
35
 
37
36
  if (!this.derived) {
@@ -46,10 +45,7 @@ export class PatchNode extends JsiDrawingNode {
46
45
  points,
47
46
  mode
48
47
  } = this.derived;
49
- canvas.drawPatch(points, opacity === 1 ? colors : colors && colors.map(c => {
50
- c[ALPHA] = c[ALPHA] * opacity;
51
- return c;
52
- }), texture, mode, paint);
48
+ canvas.drawPatch(points, colors, texture, mode, paint);
53
49
  }
54
50
 
55
51
  }
@@ -1 +1 @@
1
- {"version":3,"names":["BlendMode","NodeType","ALPHA","enumKey","processColor","JsiDrawingNode","PatchNode","constructor","ctx","props","Patch","deriveProps","colors","blendMode","patch","defaultBlendMode","DstOver","SrcOver","mode","points","pos","c2","c1","map","c","Skia","undefined","draw","canvas","paint","opacity","derived","Error","texture","drawPatch"],"sources":["PatchNode.ts"],"sourcesContent":["import type { SkColor, SkPoint } from \"../../../skia/types\";\nimport { BlendMode } from \"../../../skia/types\";\nimport type { DrawingContext, PatchProps } from \"../../types\";\nimport { NodeType } from \"../../types\";\nimport { ALPHA, enumKey, processColor } from \"../datatypes\";\nimport { JsiDrawingNode } from \"../DrawingNode\";\nimport type { NodeContext } from \"../Node\";\n\nexport class PatchNode extends JsiDrawingNode<\n PatchProps,\n { points: SkPoint[]; colors: SkColor[] | undefined; mode: BlendMode }\n> {\n constructor(ctx: NodeContext, props: PatchProps) {\n super(ctx, NodeType.Patch, props);\n }\n\n deriveProps() {\n const { colors, blendMode, patch } = this.props;\n const defaultBlendMode = 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 return {\n mode,\n 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 colors: colors\n ? colors.map((c) => processColor(this.Skia, c, 1))\n : undefined,\n };\n }\n\n draw({ canvas, paint, opacity }: DrawingContext) {\n if (!this.derived) {\n throw new Error(\"PatchNode: derived props not set\");\n }\n const { texture } = this.props;\n const { colors, points, mode } = this.derived;\n canvas.drawPatch(\n points,\n opacity === 1\n ? colors\n : colors &&\n colors.map((c) => {\n c[ALPHA] = c[ALPHA] * opacity;\n return c;\n }),\n texture,\n mode,\n paint\n );\n }\n}\n"],"mappings":"AACA,SAASA,SAAT,QAA0B,qBAA1B;AAEA,SAASC,QAAT,QAAyB,aAAzB;AACA,SAASC,KAAT,EAAgBC,OAAhB,EAAyBC,YAAzB,QAA6C,cAA7C;AACA,SAASC,cAAT,QAA+B,gBAA/B;AAGA,OAAO,MAAMC,SAAN,SAAwBD,cAAxB,CAGL;EACAE,WAAW,CAACC,GAAD,EAAmBC,KAAnB,EAAsC;IAC/C,MAAMD,GAAN,EAAWP,QAAQ,CAACS,KAApB,EAA2BD,KAA3B;EACD;;EAEDE,WAAW,GAAG;IACZ,MAAM;MAAEC,MAAF;MAAUC,SAAV;MAAqBC;IAArB,IAA+B,KAAKL,KAA1C;IACA,MAAMM,gBAAgB,GAAGH,MAAM,GAAGZ,SAAS,CAACgB,OAAb,GAAuBhB,SAAS,CAACiB,OAAhE;IACA,MAAMC,IAAI,GAAGL,SAAS,GAAGb,SAAS,CAACG,OAAO,CAACU,SAAD,CAAR,CAAZ,GAAmCE,gBAAzD,CAHY,CAIZ;IACA;IACA;IACA;IACA;;IACA,OAAO;MACLG,IADK;MAELC,MAAM,EAAE,CACNL,KAAK,CAAC,CAAD,CAAL,CAASM,GADH,EAENN,KA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
+ {"version":3,"names":["BlendMode","NodeType","enumKey","JsiDrawingNode","PatchNode","constructor","ctx","props","Patch","deriveProps","colors","blendMode","patch","defaultBlendMode","DstOver","SrcOver","mode","points","pos","c2","c1","map","c","Skia","Color","undefined","draw","canvas","paint","derived","Error","texture","drawPatch"],"sources":["PatchNode.ts"],"sourcesContent":["import type { SkColor, SkPoint } from \"../../../skia/types\";\nimport { BlendMode } from \"../../../skia/types\";\nimport type { DrawingContext, PatchProps } from \"../../types\";\nimport { NodeType } from \"../../types\";\nimport { enumKey } from \"../datatypes\";\nimport { JsiDrawingNode } from \"../DrawingNode\";\nimport type { NodeContext } from \"../Node\";\n\nexport class PatchNode extends JsiDrawingNode<\n PatchProps,\n { points: SkPoint[]; colors: SkColor[] | undefined; mode: BlendMode }\n> {\n constructor(ctx: NodeContext, props: PatchProps) {\n super(ctx, NodeType.Patch, props);\n }\n\n deriveProps() {\n const { colors, blendMode, patch } = this.props;\n const defaultBlendMode = 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 return {\n mode,\n 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 colors: colors ? colors.map((c) => this.Skia.Color(c)) : undefined,\n };\n }\n\n draw({ canvas, paint }: DrawingContext) {\n if (!this.derived) {\n throw new Error(\"PatchNode: derived props not set\");\n }\n const { texture } = this.props;\n const { colors, points, mode } = this.derived;\n canvas.drawPatch(points, colors, texture, mode, paint);\n }\n}\n"],"mappings":"AACA,SAASA,SAAT,QAA0B,qBAA1B;AAEA,SAASC,QAAT,QAAyB,aAAzB;AACA,SAASC,OAAT,QAAwB,cAA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