@shopify/react-native-skia 0.1.120 → 0.1.123

Sign up to get free protection for your applications and to get access to all the features.
Files changed (111) hide show
  1. package/android/CMakeLists.txt +33 -17
  2. package/android/build.gradle +81 -34
  3. package/android/cpp/jni/JniSkiaDrawView.cpp +14 -71
  4. package/android/cpp/jni/JniSkiaManager.cpp +1 -1
  5. package/android/cpp/jni/include/JniSkiaDrawView.h +18 -22
  6. package/android/cpp/jni/include/JniSkiaManager.h +4 -4
  7. package/android/cpp/rnskia-android/RNSkDrawViewImpl.cpp +68 -0
  8. package/android/cpp/rnskia-android/RNSkDrawViewImpl.h +48 -0
  9. package/android/cpp/{jni/include/JniPlatformContextWrapper.h → rnskia-android/RNSkPlatformContextImpl.h} +4 -4
  10. package/android/cpp/{jni → rnskia-android}/SkiaOpenGLRenderer.cpp +39 -54
  11. package/android/cpp/{jni/include → rnskia-android}/SkiaOpenGLRenderer.h +2 -31
  12. package/android/src/main/java/com/shopify/reactnative/skia/PlatformContext.java +1 -1
  13. package/android/src/main/java/com/shopify/reactnative/skia/RNSkiaViewManager.java +1 -1
  14. package/android/src/main/java/com/shopify/reactnative/skia/SkiaDrawView.java +21 -28
  15. package/cpp/api/JsiSkApi.h +2 -0
  16. package/cpp/api/JsiSkColor.h +49 -0
  17. package/cpp/api/JsiSkPath.h +31 -2
  18. package/cpp/api/JsiSkPathFactory.h +96 -1
  19. package/cpp/api/third_party/CSSColorParser.h +324 -0
  20. package/cpp/rnskia/RNSkAnimation.h +4 -7
  21. package/cpp/rnskia/RNSkDrawView.cpp +77 -116
  22. package/cpp/rnskia/RNSkDrawView.h +5 -35
  23. package/cpp/rnskia/RNSkJsiViewApi.h +8 -5
  24. package/cpp/rnskia/RNSkManager.cpp +2 -2
  25. package/cpp/rnskia/RNSkManager.h +2 -2
  26. package/cpp/rnskia/RNSkPlatformContext.h +1 -1
  27. package/cpp/rnskia/values/RNSkClockValue.h +19 -11
  28. package/cpp/rnskia/values/RNSkDerivedValue.h +1 -1
  29. package/cpp/rnskia/values/RNSkReadonlyValue.h +15 -15
  30. package/cpp/utils/RNSkTimingInfo.h +13 -1
  31. package/ios/RNSkia-iOS/RNSkDrawViewImpl.h +5 -7
  32. package/ios/RNSkia-iOS/RNSkDrawViewImpl.mm +25 -10
  33. package/ios/RNSkia-iOS/SkiaDrawView.mm +21 -15
  34. package/lib/commonjs/renderer/Canvas.js +3 -3
  35. package/lib/commonjs/renderer/Canvas.js.map +1 -1
  36. package/lib/commonjs/renderer/components/Paint.js +1 -1
  37. package/lib/commonjs/renderer/components/Paint.js.map +1 -1
  38. package/lib/commonjs/renderer/components/shapes/Path.js +10 -2
  39. package/lib/commonjs/renderer/components/shapes/Path.js.map +1 -1
  40. package/lib/commonjs/renderer/nodes/Node.js +3 -3
  41. package/lib/commonjs/renderer/nodes/Node.js.map +1 -1
  42. package/lib/commonjs/renderer/processors/Paint.js +6 -1
  43. package/lib/commonjs/renderer/processors/Paint.js.map +1 -1
  44. package/lib/commonjs/skia/Color.js +3 -25
  45. package/lib/commonjs/skia/Color.js.map +1 -1
  46. package/lib/commonjs/skia/Image/Image.js.map +1 -1
  47. package/lib/commonjs/skia/ImageFilter/ImageFilterFactory.js.map +1 -1
  48. package/lib/commonjs/skia/Paint/Paint.js +13 -1
  49. package/lib/commonjs/skia/Paint/Paint.js.map +1 -1
  50. package/lib/commonjs/skia/Paint/usePaint.js +2 -4
  51. package/lib/commonjs/skia/Paint/usePaint.js.map +1 -1
  52. package/lib/commonjs/skia/Path/Path.js +13 -1
  53. package/lib/commonjs/skia/Path/Path.js.map +1 -1
  54. package/lib/commonjs/skia/Shader/Shader.js.map +1 -1
  55. package/lib/commonjs/skia/Skia.js +43 -3
  56. package/lib/commonjs/skia/Skia.js.map +1 -1
  57. package/lib/module/renderer/Canvas.js +2 -2
  58. package/lib/module/renderer/Canvas.js.map +1 -1
  59. package/lib/module/renderer/components/Paint.js +2 -2
  60. package/lib/module/renderer/components/Paint.js.map +1 -1
  61. package/lib/module/renderer/components/shapes/Path.js +10 -3
  62. package/lib/module/renderer/components/shapes/Path.js.map +1 -1
  63. package/lib/module/renderer/nodes/Node.js +3 -3
  64. package/lib/module/renderer/nodes/Node.js.map +1 -1
  65. package/lib/module/renderer/processors/Paint.js +6 -1
  66. package/lib/module/renderer/processors/Paint.js.map +1 -1
  67. package/lib/module/skia/Color.js +2 -21
  68. package/lib/module/skia/Color.js.map +1 -1
  69. package/lib/module/skia/Image/Image.js.map +1 -1
  70. package/lib/module/skia/ImageFilter/ImageFilterFactory.js.map +1 -1
  71. package/lib/module/skia/Paint/Paint.js +6 -0
  72. package/lib/module/skia/Paint/Paint.js.map +1 -1
  73. package/lib/module/skia/Paint/usePaint.js +2 -3
  74. package/lib/module/skia/Paint/usePaint.js.map +1 -1
  75. package/lib/module/skia/Path/Path.js +11 -0
  76. package/lib/module/skia/Path/Path.js.map +1 -1
  77. package/lib/module/skia/Shader/Shader.js.map +1 -1
  78. package/lib/module/skia/Skia.js +45 -2
  79. package/lib/module/skia/Skia.js.map +1 -1
  80. package/lib/typescript/src/renderer/components/shapes/Path.d.ts +3 -1
  81. package/lib/typescript/src/renderer/processors/Paint.d.ts +2 -1
  82. package/lib/typescript/src/skia/Color.d.ts +0 -1
  83. package/lib/typescript/src/skia/Image/Image.d.ts +3 -3
  84. package/lib/typescript/src/skia/ImageFilter/ImageFilterFactory.d.ts +2 -2
  85. package/lib/typescript/src/skia/Paint/Paint.d.ts +3 -2
  86. package/lib/typescript/src/skia/Path/Path.d.ts +13 -0
  87. package/lib/typescript/src/skia/Path/PathFactory.d.ts +7 -1
  88. package/lib/typescript/src/skia/Picture/Picture.d.ts +2 -2
  89. package/lib/typescript/src/skia/RuntimeEffect/RuntimeEffect.d.ts +3 -3
  90. package/lib/typescript/src/skia/Shader/Shader.d.ts +2 -2
  91. package/lib/typescript/src/skia/Shader/ShaderFactory.d.ts +9 -9
  92. package/lib/typescript/src/skia/Skia.d.ts +5 -3
  93. package/package.json +1 -1
  94. package/scripts/install-npm.js +1 -1
  95. package/src/renderer/Canvas.tsx +2 -2
  96. package/src/renderer/components/Paint.tsx +2 -2
  97. package/src/renderer/components/shapes/Path.tsx +12 -4
  98. package/src/renderer/nodes/Node.ts +3 -3
  99. package/src/renderer/processors/Paint.ts +5 -0
  100. package/src/skia/Color.ts +3 -20
  101. package/src/skia/Image/Image.ts +3 -3
  102. package/src/skia/ImageFilter/ImageFilterFactory.ts +2 -2
  103. package/src/skia/Paint/Paint.ts +9 -2
  104. package/src/skia/Paint/usePaint.ts +2 -4
  105. package/src/skia/Path/Path.ts +16 -0
  106. package/src/skia/Path/PathFactory.ts +8 -1
  107. package/src/skia/Picture/Picture.ts +2 -2
  108. package/src/skia/RuntimeEffect/RuntimeEffect.ts +4 -4
  109. package/src/skia/Shader/Shader.ts +2 -2
  110. package/src/skia/Shader/ShaderFactory.ts +9 -9
  111. package/src/skia/Skia.ts +47 -3
@@ -1 +1 @@
1
- {"version":3,"sources":["Canvas.tsx"],"names":["React","useEffect","useState","useCallback","useMemo","useContext","forwardRef","useRef","ReactReconciler","SkiaView","useDrawCallback","Skia","useValue","debug","hostDebug","skHostConfig","vec","Container","DependencyManager","CanvasContext","createContext","useCanvasSize","canvas","Error","skiaReconciler","injectIntoDevTools","bundleType","version","rendererPackageName","render","element","root","container","updateContainer","depMgr","subscribe","useCanvasRef","defaultFontMgr","FontMgr","RefDefault","Canvas","forwardedRef","children","style","mode","onTouch","fontMgr","canvasCtx","width","height","innerRef","ref","useCombinedRefs","tick","setTick","redraw","t","createContainer","onDraw","info","timestamp","touches","current","paint","Paint","setAntiAlias","ctx","opacity","center","draw","unsubscribe","refs","targetRef","forEach"],"mappings":"AAAA,OAAOA,KAAP,IACEC,SADF,EAEEC,QAFF,EAGEC,WAHF,EAIEC,OAJF,EAKEC,UALF,EAMEC,UANF,EAOEC,MAPF,QAQO,OARP;AAiBA,OAAOC,eAAP,MAA4B,kBAA5B;AAEA,SAASC,QAAT,EAAmBC,eAAnB,QAA0C,UAA1C;AAEA,SAASC,I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R;AAKE,IAAA,KAAK,EAAE/B;AALT,IADF;AASD,CA3E6B,CAAzB;AA8EP;AACA;AACA;AACA;AACA;AACA;AACA;;AACA,MAAMuC,eAAe,GAAG,YAEnB;AAAA,oCADAmB,IACA;AADAA,IAAAA,IACA;AAAA;;AACH,QAAMC,SAAS,GAAGxE,KAAK,CAACO,MAAN,CAAgB,IAAhB,CAAlB;AACAP,EAAAA,KAAK,CAACC,SAAN,CAAgB,MAAM;AACpBsE,IAAAA,IAAI,CAACE,OAAL,CAActB,GAAD,IAAS;AACpB,UAAIA,GAAJ,EAAS;AACP,YAAI,OAAOA,GAAP,KAAe,UAAnB,EAA+B;AAC7BA,UAAAA,GAAG,CAACqB,SAAS,CAACV,OAAX,CAAH;AACD,SAFD,MAEO;AACLX,UAAAA,GAAG,CAACW,OAAJ,GAAcU,SAAS,CAACV,OAAxB;AACD;AACF;AACF,KARD;AASD,GAVD,EAUG,CAACS,IAAD,CAVH;AAWA,SAAOC,SAAP;AACD,CAhBD","sourcesContent":["import React, {\n useEffect,\n useState,\n useCallback,\n useMemo,\n useContext,\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 { SkiaView, useDrawCallback } from \"../views\";\nimport type { TouchHandler } from \"../views\";\nimport { Skia } from \"../skia\";\nimport type { FontMgr } from \"../skia/FontMgr/FontMgr\";\nimport { useValue } from \"../values/hooks/useValue\";\nimport type { SkiaReadonlyValue } from \"../values/types\";\n\nimport { debug as hostDebug, skHostConfig } from \"./HostConfig\";\n// import { debugTree } from \"./nodes\";\nimport { vec } from \"./processors\";\nimport { Container } from \"./nodes\";\nimport { DependencyManager } from \"./DependencyManager\";\n\nconst CanvasContext = React.createContext<SkiaReadonlyValue<{\n width: number;\n height: number;\n}> | null>(null);\n\nexport const useCanvasSize = () => {\n const canvas = useContext(CanvasContext);\n if (!canvas) {\n throw new Error(\"Canvas context is not available\");\n }\n return canvas;\n};\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\n container.depMgr.subscribe();\n });\n};\n\nexport const useCanvasRef = () => useRef<SkiaView>(null);\n\nexport interface CanvasProps extends ComponentProps<typeof SkiaView> {\n ref?: RefObject<SkiaView>;\n children: ReactNode;\n onTouch?: TouchHandler;\n fontMgr?: FontMgr;\n}\n\nconst defaultFontMgr = Skia.FontMgr.RefDefault();\n\nexport const Canvas = forwardRef<SkiaView, CanvasProps>(\n ({ children, style, debug, mode, onTouch, fontMgr }, forwardedRef) => {\n const canvasCtx = useValue({ width: 0, height: 0 });\n const innerRef = useCanvasRef();\n const ref = useCombinedRefs(forwardedRef, innerRef);\n const [tick, setTick] = useState(0);\n const redraw = useCallback(() => setTick((t) => t + 1), []);\n\n const container = useMemo(\n () => new Container(new DependencyManager(ref), redraw),\n [redraw, ref]\n );\n\n const root = useMemo(\n () => skiaReconciler.createContainer(container, 0, false, null),\n [container]\n );\n // Render effect\n useEffect(() => {\n render(\n <CanvasContext.Provider value={canvasCtx}>\n {children}\n </CanvasContext.Provider>,\n root,\n container\n );\n }, [children, root, redraw, container, canvasCtx]);\n\n // Draw callback\n const onDraw = useDrawCallback(\n (canvas, info) => {\n // TODO: if tree is empty (count === 1) maybe we should not render?\n const { width, height, timestamp } = info;\n if (onTouch) {\n onTouch(info.touches);\n }\n if (\n width !== canvasCtx.current.width ||\n height !== canvasCtx.current.height\n ) {\n canvasCtx.current = { width, height };\n }\n const paint = Skia.Paint();\n paint.setAntiAlias(true);\n const ctx = {\n width,\n height,\n timestamp,\n canvas,\n paint,\n opacity: 1,\n ref,\n center: vec(width / 2, height / 2),\n fontMgr: fontMgr ?? defaultFontMgr,\n };\n container.draw(ctx);\n },\n [tick, onTouch]\n );\n\n useEffect(() => {\n return () => {\n container.depMgr.unsubscribe();\n };\n }, [container]);\n\n return (\n <SkiaView\n ref={ref}\n style={style}\n onDraw={onDraw}\n mode={mode}\n debug={debug}\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"]}
1
+ {"version":3,"sources":["Canvas.tsx"],"names":["React","useEffect","useState","useCallback","useMemo","useContext","forwardRef","useRef","ReactReconciler","SkiaView","useDrawCallback","Skia","useValue","SkiaPaint","debug","hostDebug","skHostConfig","vec","Container","DependencyManager","CanvasContext","createContext","useCanvasSize","canvas","Error","skiaReconciler","injectIntoDevTools","bundleType","version","rendererPackageName","render","element","root","container","updateContainer","depMgr","subscribe","useCanvasRef","defaultFontMgr","FontMgr","RefDefault","Canvas","forwardedRef","children","style","mode","onTouch","fontMgr","canvasCtx","width","height","innerRef","ref","useCombinedRefs","tick","setTick","redraw","t","createContainer","onDraw","info","timestamp","touches","current","paint","ctx","opacity","center","draw","unsubscribe","refs","targetRef","forEach"],"mappings":"AAAA,OAAOA,KAAP,IACEC,SADF,EAEEC,QAFF,EAGEC,WAHF,EAIEC,OAJF,EAKEC,UALF,EAMEC,UANF,EAOEC,MAPF,QAQO,OARP;AAiBA,OAAOC,eAAP,MAA4B,kBAA5B;AAEA,SAASC,QAAT,EAAmBC,eAAnB,QAA0C,UAA1C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AAA,KAAK,EAAE/B;AALT,IADF;AASD,CA1E6B,CAAzB;AA6EP;AACA;AACA;AACA;AACA;AACA;AACA;;AACA,MAAMuC,eAAe,GAAG,YAEnB;AAAA,oCADAiB,IACA;AADAA,IAAAA,IACA;AAAA;;AACH,QAAMC,SAAS,GAAGvE,KAAK,CAACO,MAAN,CAAgB,IAAhB,CAAlB;AACAP,EAAAA,KAAK,CAACC,SAAN,CAAgB,MAAM;AACpBqE,IAAAA,IAAI,CAACE,OAAL,CAAcpB,GAAD,IAAS;AACpB,UAAIA,GAAJ,EAAS;AACP,YAAI,OAAOA,GAAP,KAAe,UAAnB,EAA+B;AAC7BA,UAAAA,GAAG,CAACmB,SAAS,CAACR,OAAX,CAAH;AACD,SAFD,MAEO;AACLX,UAAAA,GAAG,CAACW,OAAJ,GAAcQ,SAAS,CAACR,OAAxB;AACD;AACF;AACF,KARD;AASD,GAVD,EAUG,CAACO,IAAD,CAVH;AAWA,SAAOC,SAAP;AACD,CAhBD","sourcesContent":["import React, {\n useEffect,\n useState,\n useCallback,\n useMemo,\n useContext,\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 { SkiaView, useDrawCallback } from \"../views\";\nimport type { TouchHandler } from \"../views\";\nimport { Skia } from \"../skia\";\nimport type { FontMgr } from \"../skia/FontMgr/FontMgr\";\nimport { useValue } from \"../values/hooks/useValue\";\nimport type { SkiaReadonlyValue } from \"../values/types\";\nimport { SkiaPaint } from \"../skia/Paint/Paint\";\n\nimport { debug as hostDebug, skHostConfig } from \"./HostConfig\";\n// import { debugTree } from \"./nodes\";\nimport { vec } from \"./processors\";\nimport { Container } from \"./nodes\";\nimport { DependencyManager } from \"./DependencyManager\";\n\nconst CanvasContext = React.createContext<SkiaReadonlyValue<{\n width: number;\n height: number;\n}> | null>(null);\n\nexport const useCanvasSize = () => {\n const canvas = useContext(CanvasContext);\n if (!canvas) {\n throw new Error(\"Canvas context is not available\");\n }\n return canvas;\n};\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\n container.depMgr.subscribe();\n });\n};\n\nexport const useCanvasRef = () => useRef<SkiaView>(null);\n\nexport interface CanvasProps extends ComponentProps<typeof SkiaView> {\n ref?: RefObject<SkiaView>;\n children: ReactNode;\n onTouch?: TouchHandler;\n fontMgr?: FontMgr;\n}\n\nconst defaultFontMgr = Skia.FontMgr.RefDefault();\n\nexport const Canvas = forwardRef<SkiaView, CanvasProps>(\n ({ children, style, debug, mode, onTouch, fontMgr }, forwardedRef) => {\n const canvasCtx = useValue({ width: 0, height: 0 });\n const innerRef = useCanvasRef();\n const ref = useCombinedRefs(forwardedRef, innerRef);\n const [tick, setTick] = useState(0);\n const redraw = useCallback(() => setTick((t) => t + 1), []);\n\n const container = useMemo(\n () => new Container(new DependencyManager(ref), redraw),\n [redraw, ref]\n );\n\n const root = useMemo(\n () => skiaReconciler.createContainer(container, 0, false, null),\n [container]\n );\n // Render effect\n useEffect(() => {\n render(\n <CanvasContext.Provider value={canvasCtx}>\n {children}\n </CanvasContext.Provider>,\n root,\n container\n );\n }, [children, root, redraw, container, canvasCtx]);\n\n // Draw callback\n const onDraw = useDrawCallback(\n (canvas, info) => {\n // TODO: if tree is empty (count === 1) maybe we should not render?\n const { width, height, timestamp } = info;\n if (onTouch) {\n onTouch(info.touches);\n }\n if (\n width !== canvasCtx.current.width ||\n height !== canvasCtx.current.height\n ) {\n canvasCtx.current = { width, height };\n }\n const paint = SkiaPaint();\n const ctx = {\n width,\n height,\n timestamp,\n canvas,\n paint,\n opacity: 1,\n ref,\n center: vec(width / 2, height / 2),\n fontMgr: fontMgr ?? defaultFontMgr,\n };\n container.draw(ctx);\n },\n [tick, onTouch]\n );\n\n useEffect(() => {\n return () => {\n container.depMgr.unsubscribe();\n };\n }, [container]);\n\n return (\n <SkiaView\n ref={ref}\n style={style}\n onDraw={onDraw}\n mode={mode}\n debug={debug}\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"]}
@@ -1,12 +1,12 @@
1
1
  function _extends() { _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends.apply(this, arguments); }
2
2
 
3
3
  import React, { useRef, useMemo, forwardRef, useImperativeHandle } from "react";
4
- import { Skia } from "../../skia";
4
+ import { SkiaPaint } from "../../skia";
5
5
  import { processPaint } from "../processors";
6
6
  import { createDeclaration } from "../nodes";
7
7
  export const usePaintRef = () => useRef(null);
8
8
  export const Paint = /*#__PURE__*/forwardRef((props, ref) => {
9
- const paint = useMemo(() => Skia.Paint(), []);
9
+ const paint = useMemo(() => SkiaPaint(), []);
10
10
  useImperativeHandle(ref, () => paint, [paint]);
11
11
  const onDeclare = useMemo(() => createDeclaration((paintProps, children, ctx) => processPaint(paint, ctx.opacity, paintProps, children)), [paint]);
12
12
  return /*#__PURE__*/React.createElement("skDeclaration", _extends({
@@ -1 +1 @@
1
- {"version":3,"sources":["Paint.tsx"],"names":["React","useRef","useMemo","forwardRef","useImperativeHandle","Skia","processPaint","createDeclaration","usePaintRef","Paint","props","ref","paint","onDeclare","paintProps","children","ctx","opacity"],"mappings":";;AACA,OAAOA,KAAP,IAAgBC,MAAhB,EAAwBC,OAAxB,EAAiCC,UAAjC,EAA6CC,mBAA7C,QAAwE,OAAxE;AAGA,SAASC,IAAT,QAAqB,YAArB;AAEA,SAASC,YAAT,QAA6B,eAA7B;AACA,SAASC,iBAAT,QAAkC,UAAlC;AAEA,OAAO,MAAMC,WAAW,GAAG,MAAMP,MAAM,CAAU,IAAV,CAAhC;AAMP,OAAO,MAAMQ,KAAK,gBAAGN,UAAU,CAC7B,CAACO,KAAD,EAAQC,GAAR,KAAgB;AACd,QAAMC,KAAK,GAAGV,OAAO,CAAC,MAAMG,IAAI,CAACI,KAAL,EAAP,EAAqB,EAArB,CAArB;AACAL,EAAAA,mBAAmB,CAACO,GAAD,EAAM,MAAMC,KAAZ,EAAmB,CAACA,KAAD,CAAnB,CAAnB;AACA,QAAMC,SAAS,GAAGX,OAAO,CACvB,MACEK,iBAAiB,CAAa,CAACO,UAAD,EAAaC,QAAb,EAAuBC,GAAvB,KAC5BV,YAAY,CAACM,KAAD,EAAQI,GAAG,CAACC,OAAZ,EAAqBH,UAArB,EAAiCC,QAAjC,CADG,CAFI,EAKvB,CAACH,KAAD,CALuB,CAAzB;AAOA,sBAAO;AAAe,IAAA,SAAS,EAAEC;AAA1B,KAAyCH,KAAzC,EAAP;AACD,CAZ4B,CAAxB","sourcesContent":["import type { ReactNode } from \"react\";\nimport React, { useRef, useMemo, forwardRef, useImperativeHandle } from \"react\";\n\nimport type { SkPaint } from \"../../skia\";\nimport { Skia } from \"../../skia\";\nimport type { CustomPaintProps, AnimatedProps } from \"../processors\";\nimport { processPaint } from \"../processors\";\nimport { createDeclaration } from \"../nodes\";\n\nexport const usePaintRef = () => useRef<SkPaint>(null);\n\nexport interface PaintProps extends Omit<CustomPaintProps, \"paint\"> {\n children?: ReactNode | ReactNode[];\n}\n\nexport const Paint = forwardRef<SkPaint, AnimatedProps<PaintProps>>(\n (props, ref) => {\n const paint = useMemo(() => Skia.Paint(), []);\n useImperativeHandle(ref, () => paint, [paint]);\n const onDeclare = useMemo(\n () =>\n createDeclaration<PaintProps>((paintProps, children, ctx) =>\n processPaint(paint, ctx.opacity, paintProps, children)\n ),\n [paint]\n );\n return <skDeclaration onDeclare={onDeclare} {...props} />;\n }\n);\n"]}
1
+ {"version":3,"sources":["Paint.tsx"],"names":["React","useRef","useMemo","forwardRef","useImperativeHandle","SkiaPaint","processPaint","createDeclaration","usePaintRef","Paint","props","ref","paint","onDeclare","paintProps","children","ctx","opacity"],"mappings":";;AACA,OAAOA,KAAP,IAAgBC,MAAhB,EAAwBC,OAAxB,EAAiCC,UAAjC,EAA6CC,mBAA7C,QAAwE,OAAxE;AAGA,SAASC,SAAT,QAA0B,YAA1B;AAEA,SAASC,YAAT,QAA6B,eAA7B;AACA,SAASC,iBAAT,QAAkC,UAAlC;AAEA,OAAO,MAAMC,WAAW,GAAG,MAAMP,MAAM,CAAU,IAAV,CAAhC;AAMP,OAAO,MAAMQ,KAAK,gBAAGN,UAAU,CAC7B,CAACO,KAAD,EAAQC,GAAR,KAAgB;AACd,QAAMC,KAAK,GAAGV,OAAO,CAAC,MAAMG,SAAS,EAAhB,EAAoB,EAApB,CAArB;AACAD,EAAAA,mBAAmB,CAACO,GAAD,EAAM,MAAMC,KAAZ,EAAmB,CAACA,KAAD,CAAnB,CAAnB;AACA,QAAMC,SAAS,GAAGX,OAAO,CACvB,MACEK,iBAAiB,CAAa,CAACO,UAAD,EAAaC,QAAb,EAAuBC,GAAvB,KAC5BV,YAAY,CAACM,KAAD,EAAQI,GAAG,CAACC,OAAZ,EAAqBH,UAArB,EAAiCC,QAAjC,CADG,CAFI,EAKvB,CAACH,KAAD,CALuB,CAAzB;AAOA,sBAAO;AAAe,IAAA,SAAS,EAAEC;AAA1B,KAAyCH,KAAzC,EAAP;AACD,CAZ4B,CAAxB","sourcesContent":["import type { ReactNode } from \"react\";\nimport React, { useRef, useMemo, forwardRef, useImperativeHandle } from \"react\";\n\nimport type { SkPaint } from \"../../skia\";\nimport { SkiaPaint } from \"../../skia\";\nimport type { CustomPaintProps, AnimatedProps } from \"../processors\";\nimport { processPaint } from \"../processors\";\nimport { createDeclaration } from \"../nodes\";\n\nexport const usePaintRef = () => useRef<SkPaint>(null);\n\nexport interface PaintProps extends Omit<CustomPaintProps, \"paint\"> {\n children?: ReactNode | ReactNode[];\n}\n\nexport const Paint = forwardRef<SkPaint, AnimatedProps<PaintProps>>(\n (props, ref) => {\n const paint = useMemo(() => SkiaPaint(), []);\n useImperativeHandle(ref, () => paint, [paint]);\n const onDeclare = useMemo(\n () =>\n createDeclaration<PaintProps>((paintProps, children, ctx) =>\n processPaint(paint, ctx.opacity, paintProps, children)\n ),\n [paint]\n );\n return <skDeclaration onDeclare={onDeclare} {...props} />;\n }\n);\n"]}
@@ -2,7 +2,8 @@ function _extends() { _extends = Object.assign || function (target) { for (var i
2
2
 
3
3
  import React from "react";
4
4
  import { createDrawing } from "../../nodes";
5
- import { processPath } from "../../processors";
5
+ import { processPath, enumKey } from "../../processors";
6
+ import { FillType } from "../../../skia";
6
7
  const onDraw = createDrawing((_ref, _ref2) => {
7
8
  let {
8
9
  canvas,
@@ -12,15 +13,21 @@ const onDraw = createDrawing((_ref, _ref2) => {
12
13
  start,
13
14
  end,
14
15
  stroke,
16
+ fillType,
15
17
  ...pathProps
16
18
  } = _ref2;
17
19
  const hasStartOffset = start !== 0;
18
- const hasEndOffset = start !== 1;
20
+ const hasEndOffset = end !== 1;
19
21
  const hasStrokeOptions = stroke !== undefined;
20
- const willMutatePath = hasStartOffset || hasEndOffset || hasStrokeOptions;
22
+ const hasFillType = !!fillType;
23
+ const willMutatePath = hasStartOffset || hasEndOffset || hasStrokeOptions || hasFillType;
21
24
  const pristinePath = processPath(pathProps.path);
22
25
  const path = willMutatePath ? pristinePath.copy() : pristinePath;
23
26
 
27
+ if (hasFillType) {
28
+ path.setFillType(FillType[enumKey(fillType)]);
29
+ }
30
+
24
31
  if (hasStrokeOptions) {
25
32
  path.stroke(stroke);
26
33
  }
@@ -1 +1 @@
1
- {"version":3,"sources":["Path.tsx"],"names":["React","createDrawing","processPath","onDraw","canvas","paint","start","end","stroke","pathProps","hasStartOffset","hasEndOffset","hasStrokeOptions","undefined","willMutatePath","pristinePath","path","copy","trim","drawPath","Path","props","defaultProps"],"mappings":";;AAAA,OAAOA,KAAP,MAAkB,OAAlB;AAOA,SAASC,aAAT,QAA8B,aAA9B;AACA,SAASC,WAAT,QAA4B,kBAA5B;AAeA,MAAMC,MAAM,GAAGF,aAAa,CAC1B,iBAA6D;AAAA,MAA5D;AAAEG,IAAAA,MAAF;AAAUC,IAAAA;AAAV,GAA4D;AAAA,MAAzC;AAAEC,IAAAA,KAAF;AAASC,IAAAA,GAAT;AAAcC,IAAAA,MAAd;AAAsB,OAAGC;AAAzB,GAAyC;AAC3D,QAAMC,cAAc,GAAGJ,KAAK,KAAK,CAAjC;AACA,QAAMK,YAAY,GAAGL,KAAK,KAAK,CAA/B;AACA,QAAMM,gBAAgB,GAAGJ,MAAM,KAAKK,SAApC;AACA,QAAMC,cAAc,GAAGJ,cAAc,IAAIC,YAAlB,IAAkCC,gBAAzD;AACA,QAAMG,YAAY,GAAGb,WAAW,CAACO,SAAS,CAACO,IAAX,CAAhC;AACA,QAAMA,IAAI,GAAGF,cAAc,GAAGC,YAAY,CAACE,IAAb,EAAH,GAAyBF,YAApD;;AACA,MAAIH,gBAAJ,EAAsB;AACpBI,IAAAA,IAAI,CAACR,MAAL,CAAYA,MAAZ;AACD;;AACD,MAAIE,cAAc,IAAIC,YAAtB,EAAoC;AAClCK,IAAAA,IAAI,CAACE,IAAL,CAAUZ,KAAV,EAAiBC,GAAjB,EAAsB,KAAtB;AACD;;AACDH,EAAAA,MAAM,CAACe,QAAP,CAAgBH,IAAhB,EAAsBX,KAAtB;AACD,CAfyB,CAA5B;AAkBA,OAAO,MAAMe,IAAI,GAAIC,KAAD,IAAqC;AACvD,sBAAO;AAAW,IAAA,MAAM,EAAElB;AAAnB,KAA+BkB,KAA/B,EAAP;AACD,CAFM;AAIPD,IAAI,CAACE,YAAL,GAAoB;AAClBhB,EAAAA,KAAK,EAAE,CADW;AAElBC,EAAAA,GAAG,EAAE;AAFa,CAApB","sourcesContent":["import React from \"react\";\n\nimport type {\n CustomPaintProps,\n AnimatedProps,\n PathDef,\n} from \"../../processors\";\nimport { createDrawing } from \"../../nodes\";\nimport { processPath } from \"../../processors\";\n\ninterface StrokeOpts {\n width?: number;\n strokeMiterlimit?: number;\n precision?: number;\n}\n\nexport interface PathProps extends CustomPaintProps {\n path: PathDef;\n start: number;\n end: number;\n stroke?: StrokeOpts;\n}\n\nconst onDraw = createDrawing<PathProps>(\n ({ canvas, paint }, { start, end, stroke, ...pathProps }) => {\n const hasStartOffset = start !== 0;\n const hasEndOffset = start !== 1;\n const hasStrokeOptions = stroke !== undefined;\n const willMutatePath = hasStartOffset || hasEndOffset || hasStrokeOptions;\n const pristinePath = processPath(pathProps.path);\n const path = willMutatePath ? pristinePath.copy() : pristinePath;\n if (hasStrokeOptions) {\n path.stroke(stroke);\n }\n if (hasStartOffset || hasEndOffset) {\n path.trim(start, end, false);\n }\n canvas.drawPath(path, paint);\n }\n);\n\nexport const Path = (props: AnimatedProps<PathProps>) => {\n return <skDrawing onDraw={onDraw} {...props} />;\n};\n\nPath.defaultProps = {\n start: 0,\n end: 1,\n};\n"]}
1
+ {"version":3,"sources":["Path.tsx"],"names":["React","createDrawing","processPath","enumKey","FillType","onDraw","canvas","paint","start","end","stroke","fillType","pathProps","hasStartOffset","hasEndOffset","hasStrokeOptions","undefined","hasFillType","willMutatePath","pristinePath","path","copy","setFillType","trim","drawPath","Path","props","defaultProps"],"mappings":";;AAAA,OAAOA,KAAP,MAAkB,OAAlB;AAQA,SAASC,aAAT,QAA8B,aAA9B;AACA,SAAS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CAFM;AAIPD,IAAI,CAACE,YAAL,GAAoB;AAClBnB,EAAAA,KAAK,EAAE,CADW;AAElBC,EAAAA,GAAG,EAAE;AAFa,CAApB","sourcesContent":["import React from \"react\";\n\nimport type {\n CustomPaintProps,\n AnimatedProps,\n PathDef,\n SkEnum,\n} from \"../../processors\";\nimport { createDrawing } from \"../../nodes\";\nimport { processPath, enumKey } from \"../../processors\";\nimport { FillType } from \"../../../skia\";\n\ninterface StrokeOpts {\n width?: number;\n strokeMiterlimit?: number;\n precision?: number;\n}\n\nexport interface PathProps extends CustomPaintProps {\n path: PathDef;\n start: number;\n end: number;\n stroke?: StrokeOpts;\n fillType?: SkEnum<typeof FillType>;\n}\n\nconst onDraw = createDrawing<PathProps>(\n ({ canvas, paint }, { start, end, stroke, fillType, ...pathProps }) => {\n const hasStartOffset = start !== 0;\n const hasEndOffset = end !== 1;\n const hasStrokeOptions = stroke !== undefined;\n const hasFillType = !!fillType;\n const willMutatePath =\n hasStartOffset || hasEndOffset || hasStrokeOptions || hasFillType;\n const pristinePath = processPath(pathProps.path);\n const path = willMutatePath ? pristinePath.copy() : pristinePath;\n if (hasFillType) {\n path.setFillType(FillType[enumKey(fillType)]);\n }\n if (hasStrokeOptions) {\n path.stroke(stroke);\n }\n if (hasStartOffset || hasEndOffset) {\n path.trim(start, end, false);\n }\n canvas.drawPath(path, paint);\n }\n);\n\nexport const Path = (props: AnimatedProps<PathProps>) => {\n return <skDrawing onDraw={onDraw} {...props} />;\n};\n\nPath.defaultProps = {\n start: 0,\n end: 1,\n};\n"]}
@@ -40,7 +40,9 @@ export class Node {
40
40
  visit(ctx, children) {
41
41
  const returnedValues = [];
42
42
  (children !== null && children !== void 0 ? children : this.children).forEach(child => {
43
- if (!child.memoized) {
43
+ if (child.memoized && child.memoizable) {
44
+ returnedValues.push(child.memoized);
45
+ } else {
44
46
  const ret = child.draw(ctx);
45
47
 
46
48
  if (ret) {
@@ -50,8 +52,6 @@ export class Node {
50
52
  child.memoized = ret;
51
53
  }
52
54
  }
53
- } else {
54
- returnedValues.push(child.memoized);
55
55
  }
56
56
  });
57
57
  return returnedValues;
@@ -1 +1 @@
1
- {"version":3,"sources":["Node.ts"],"names":["NodeType","Node","constructor","depMgr","props","_props","unSubscribeNode","subscribeNode","visit","ctx","children","returnedValues","forEach","child","memoized","ret","draw","push","memoizable"],"mappings":";;AAKA,WAAYA,QAAZ;;WAAYA,Q;AAAAA,EAAAA,Q;AAAAA,EAAAA,Q;GAAAA,Q,KAAAA,Q;;AAOZ,OAAO,MAAeC,IAAf,CAAiC;AAQtCC,EAAAA,WAAW,CAACC,MAAD,EAA4BC,KAA5B,EAAqD;AAAA,sCAPpC,EAOoC;;AAAA;;AAAA,wCALnD,KAKmD;;AAAA,sCAJ3B,IAI2B;;AAAA;;AAAA;;AAC9D,SAAKC,MAAL,GAAcD,KAAd;AACA,SAAKD,MAAL,GAAcA,MAAd;AACA,SAAKA,MAAL,CAAYG,eAAZ,CAA4B,IAA5B;AACA,SAAKH,MAAL,CAAYI,aAAZ,CAA0B,IAA1B,EAAgCH,KAAhC;AACD;;AAIQ,MAALA,KAAK,CAACA,KAAD,EAA0B;AACjC,SAAKD,MAAL,CAAYG,eAAZ,CAA4B,IAA5B;AACA,SAAKH,MAAL,CAAYI,aAAZ,CAA0B,IAA1B,EAAgCH,KAAhC;AACA,SAAKC,MAAL,GAAcD,KAAd;AACD;;AAEQ,MAALA,KAAK,GAAG;AACV,WAAO,KAAKC,MAAZ;AACD;;AAEDG,EAAAA,KAAK,CAACC,GAAD,EAAsBC,QAAtB,EAAyC;AAC5C,UAAMC,cAAkD,GAAG,EAA3D;AACA,KAACD,QAAD,aAACA,QAAD,cAACA,QAAD,GAAa,KAAKA,QAAlB,EAA4BE,OAA5B,CAAqCC,KAAD,IAAW;AAC7C,UAAI,CAACA,KAAK,CAACC,QAAX,EAAqB;AACnB,cAAMC,GAAG,GAAGF,KAAK,CAACG,IAAN,CAAWP,GAAX,CAAZ;;AACA,YAAIM,GAAJ,EAAS;AACPJ,UAAAA,cAAc,CAACM,IAAf,CAAoBF,GAApB;;AACA,cAAIF,KAAK,CAACK,UAAV,EAAsB;AACpBL,YAAAA,KAAK,CAACC,QAAN,GAAiBC,GAAjB;AACD;AACF;AACF,OARD,MAQO;AACLJ,QAAAA,cAAc,CAACM,IAAf,CAAoBJ,KAAK,CAACC,QAA1B;AACD;AACF,KAZD;AAaA,WAAOH,cAAP;AACD;;AA3CqC","sourcesContent":["import type { SkJSIInstance } from \"../../skia/JsiInstance\";\nimport type { DependencyManager } from \"../DependencyManager\";\nimport type { DrawingContext } from \"../DrawingContext\";\nimport type { AnimatedProps } from \"../processors\";\n\nexport enum NodeType {\n Declaration = \"skDeclaration\",\n Drawing = \"skDrawing\",\n}\n\ntype DeclarationResult = SkJSIInstance<string> | null;\n\nexport abstract class Node<P = unknown> {\n readonly children: Node[] = [];\n _props: AnimatedProps<P>;\n memoizable = false;\n memoized: DeclarationResult | null = null;\n parent?: Node;\n depMgr: DependencyManager;\n\n constructor(depMgr: DependencyManager, props: AnimatedProps<P>) {\n this._props = props;\n this.depMgr = depMgr;\n this.depMgr.unSubscribeNode(this);\n this.depMgr.subscribeNode(this, props);\n }\n\n abstract draw(ctx: DrawingContext): void | DeclarationResult;\n\n set props(props: AnimatedProps<P>) {\n this.depMgr.unSubscribeNode(this);\n this.depMgr.subscribeNode(this, props);\n this._props = props;\n }\n\n get props() {\n return this._props;\n }\n\n visit(ctx: DrawingContext, children?: Node[]) {\n const returnedValues: Exclude<DeclarationResult, null>[] = [];\n (children ?? this.children).forEach((child) => {\n if (!child.memoized) {\n const ret = child.draw(ctx);\n if (ret) {\n returnedValues.push(ret);\n if (child.memoizable) {\n child.memoized = ret;\n }\n }\n } else {\n returnedValues.push(child.memoized);\n }\n });\n return returnedValues;\n }\n}\n"]}
1
+ {"version":3,"sources":["Node.ts"],"names":["NodeType","Node","constructor","depMgr","props","_props","unSubscribeNode","subscribeNode","visit","ctx","children","returnedValues","forEach","child","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AsB;AACpBF,YAAAA,KAAK,CAACC,QAAN,GAAiBG,GAAjB;AACD;AACF;AACF;AACF,KAZD;AAaA,WAAON,cAAP;AACD;;AA3CqC","sourcesContent":["import type { SkJSIInstance } from \"../../skia/JsiInstance\";\nimport type { DependencyManager } from \"../DependencyManager\";\nimport type { DrawingContext } from \"../DrawingContext\";\nimport type { AnimatedProps } from \"../processors\";\n\nexport enum NodeType {\n Declaration = \"skDeclaration\",\n Drawing = \"skDrawing\",\n}\n\ntype DeclarationResult = SkJSIInstance<string> | null;\n\nexport abstract class Node<P = unknown> {\n readonly children: Node[] = [];\n _props: AnimatedProps<P>;\n memoizable = false;\n memoized: DeclarationResult | null = null;\n parent?: Node;\n depMgr: DependencyManager;\n\n constructor(depMgr: DependencyManager, props: AnimatedProps<P>) {\n this._props = props;\n this.depMgr = depMgr;\n this.depMgr.unSubscribeNode(this);\n this.depMgr.subscribeNode(this, props);\n }\n\n abstract draw(ctx: DrawingContext): void | DeclarationResult;\n\n set props(props: AnimatedProps<P>) {\n this.depMgr.unSubscribeNode(this);\n this.depMgr.subscribeNode(this, props);\n this._props = props;\n }\n\n get props() {\n return this._props;\n }\n\n visit(ctx: DrawingContext, children?: Node[]) {\n const returnedValues: Exclude<DeclarationResult, null>[] = [];\n (children ?? this.children).forEach((child) => {\n if (child.memoized && child.memoizable) {\n returnedValues.push(child.memoized);\n } else {\n const ret = child.draw(ctx);\n if (ret) {\n returnedValues.push(ret);\n if (child.memoizable) {\n child.memoized = ret;\n }\n }\n }\n });\n return returnedValues;\n }\n}\n"]}
@@ -10,7 +10,8 @@ export const processPaint = (paint, currentOpacity, _ref, children) => {
10
10
  strokeJoin,
11
11
  strokeCap,
12
12
  strokeMiter,
13
- opacity
13
+ opacity,
14
+ antiAlias
14
15
  } = _ref;
15
16
 
16
17
  if (paintRef && paintRef.current) {
@@ -54,6 +55,10 @@ export const processPaint = (paint, currentOpacity, _ref, children) => {
54
55
  paint.setAlphaf(opacity);
55
56
  }
56
57
 
58
+ if (antiAlias !== undefined) {
59
+ paint.setAntiAlias(antiAlias);
60
+ }
61
+
57
62
  children.forEach(child => {
58
63
  if (isShader(child)) {
59
64
  paint.setShader(child);
@@ -1 +1 @@
1
- {"version":3,"sources":["Paint.ts"],"names":["BlendMode","PaintStyle","StrokeJoin","StrokeCap","processColor","isShader","isMaskFilter","isColorFilter","isPathEffect","isImageFilter","Skia","enumKey","k","charAt","toUpperCase","slice","processPaint","paint","currentOpacity","children","paintRef","color","blendMode","style","strokeWidth","strokeJoin","strokeCap","strokeMiter","opacity","current","undefined","c","setShader","setColor","getColor","setBlendMode","setStyle","setStrokeJoin","setStrokeCap","setStrokeMiter","setStrokeWidth","setAlphaf","forEach","child","setMaskFilter","setColorFilter","setPathEffect","filters","filter","length","setImageFilter","reverse","reduce","ImageFilter","MakeCompose"],"mappings":"AAEA,SACEA,SADF,EAEEC,UAFF,EAGEC,UAHF,EAIEC,SAJF,EAKEC,YALF,EAMEC,QANF,EAOEC,YAPF,EAQEC,aARF,EASEC,YATF,EAUEC,aAVF,EAWEC,IAXF,QAYO,YAZP;AAkCA,OAAO,MAAMC,OAAO,GAAsBC,CAAnB,IACpBA,CAAC,CAACC,MAAF,CAAS,CAAT,EAAYC,WAAZ,KAA4BF,CAAC,CAACG,KAAF,CAAQ,CAAR,CADxB;AAGP,OAAO,MAAMC,YAAY,GAAG,CAC1BC,KAD0B,EAE1BC,cAF0B,QAc1BC,QAd0B,KAevB;AAAA,MAZH;AACEF,IAAAA,KAAK,EAAEG,QADT;AAEEC,IAAAA,KAFF;AAGEC,IAAAA,SAHF;AAIEC,IAAAA,KAJF;AAKEC,IAAAA,WALF;AAMEC,IAAAA,UANF;AAOEC,IAAAA,SAPF;AAQEC,IAAAA,WARF;AASEC,IAAAA;AATF,GAYG;;AACH,MAAIR,QAAQ,IAAIA,QAAQ,CAACS,OAAzB,EAAkC;AAChC,WAAOT,QAAQ,CAACS,OAAhB;AACD;;AACD,MAAIR,KAAK,KAAKS,SAA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AD,CAAZ,EAAqB;AACnB1B,MAAAA,KAAK,CAACe,SAAN,CAAgBW,KAAhB;AACD,KAFD,MAEO,IAAIrC,YAAY,CAACqC,KAAD,CAAhB,EAAyB;AAC9B1B,MAAAA,KAAK,CAAC2B,aAAN,CAAoBD,KAApB;AACD,KAFM,MAEA,IAAIpC,aAAa,CAACoC,KAAD,CAAjB,EAA0B;AAC/B1B,MAAAA,KAAK,CAAC4B,cAAN,CAAqBF,KAArB;AACD,KAFM,MAEA,IAAInC,YAAY,CAACmC,KAAD,CAAhB,EAAyB;AAC9B1B,MAAAA,KAAK,CAAC6B,aAAN,CAAoBH,KAApB;AACD;AACF,GAVD;AAWA,QAAMI,OAAO,GAAG5B,QAAQ,CAAC6B,MAAT,CAAgBvC,aAAhB,CAAhB;;AACA,MAAIsC,OAAO,CAACE,MAAR,GAAiB,CAArB,EAAwB;AACtBhC,IAAAA,KAAK,CAACiC,cAAN,CACEH,OAAO,CACJI,OADH,GAEGC,MAFH,CAEgC1C,IAAI,CAAC2C,WAAL,CAAiBC,WAFjD,EAE8D,IAF9D,CADF;AAKD;;AACD,SAAOrC,KAAP;AACD,CApEM","sourcesContent":["import type { ReactNode, RefObject } from \"react\";\n\nimport {\n BlendMode,\n PaintStyle,\n StrokeJoin,\n StrokeCap,\n processColor,\n isShader,\n isMaskFilter,\n isColorFilter,\n isPathEffect,\n isImageFilter,\n Skia,\n} from \"../../skia\";\nimport type { SkPaint, Color, SkImageFilter } from \"../../skia\";\nimport type { DeclarationResult } from \"../nodes\";\nexport type SkEnum<T> = Uncapitalize<keyof T extends string ? keyof T : never>;\n\nexport interface ChildrenProps {\n children?: ReactNode | ReactNode[];\n}\n\n// TODO: rename to paint props?\nexport interface CustomPaintProps extends ChildrenProps {\n paint?: RefObject<SkPaint>;\n color?: Color;\n strokeWidth?: number;\n blendMode?: SkEnum<typeof BlendMode>;\n style?: SkEnum<typeof PaintStyle>;\n strokeJoin?: SkEnum<typeof StrokeJoin>;\n strokeCap?: SkEnum<typeof StrokeCap>;\n strokeMiter?: number;\n opacity?: number;\n}\n\nexport const enumKey = <K extends string>(k: K) =>\n (k.charAt(0).toUpperCase() + k.slice(1)) as Capitalize<K>;\n\nexport const processPaint = (\n paint: SkPaint,\n currentOpacity: number,\n {\n paint: paintRef,\n color,\n blendMode,\n style,\n strokeWidth,\n strokeJoin,\n strokeCap,\n strokeMiter,\n opacity,\n }: CustomPaintProps,\n children: DeclarationResult[]\n) => {\n if (paintRef && paintRef.current) {\n return paintRef.current;\n }\n if (color !== undefined) {\n const c = processColor(color, currentOpacity);\n paint.setShader(null);\n paint.setColor(c);\n } else {\n const c = processColor(paint.getColor(), currentOpacity);\n paint.setColor(c);\n }\n if (blendMode !== undefined) {\n paint.setBlendMode(BlendMode[enumKey(blendMode)]);\n }\n if (style !== undefined) {\n paint.setStyle(PaintStyle[enumKey(style)]);\n }\n if (strokeJoin !== undefined) {\n paint.setStrokeJoin(StrokeJoin[enumKey(strokeJoin)]);\n }\n if (strokeCap !== undefined) {\n paint.setStrokeCap(StrokeCap[enumKey(strokeCap)]);\n }\n if (strokeMiter !== undefined) {\n paint.setStrokeMiter(strokeMiter);\n }\n if (strokeWidth !== undefined) {\n paint.setStrokeWidth(strokeWidth);\n }\n if (opacity !== undefined) {\n paint.setAlphaf(opacity);\n }\n children.forEach((child) => {\n if (isShader(child)) {\n paint.setShader(child);\n } else if (isMaskFilter(child)) {\n paint.setMaskFilter(child);\n } else if (isColorFilter(child)) {\n paint.setColorFilter(child);\n } else if (isPathEffect(child)) {\n paint.setPathEffect(child);\n }\n });\n const filters = children.filter(isImageFilter);\n if (filters.length > 0) {\n paint.setImageFilter(\n filters\n .reverse()\n .reduce<SkImageFilter | null>(Skia.ImageFilter.MakeCompose, null)\n );\n }\n return paint;\n};\n"]}
1
+ {"version":3,"sources":["Paint.ts"],"names":["BlendMode","PaintStyle","StrokeJoin","StrokeCap","processColor","isShader","isMaskFilter","isColorFilter","isPathEffect","isImageFilter","Skia","enumKey","k","charAt","toUpperCase","slice","processPaint","paint","currentOpacity","children","paintRef","color","blendMode","style","strokeWidth","strokeJoin","strokeCap","strokeMiter","opacity","antiAlias","current","undefined","c","setShader","setColor","getColor","setBlendMode","setStyle","setStrokeJoin","setStrokeCap","setStrokeMiter","setStrokeWidth","setAlphaf","setAntiAlias","forEach","child","setMaskFilter","setColorFilter","setPathEffect","filters","filter","length","setImageFilter","reverse","reduce","ImageFilter","MakeCompose"],"mappings":"AAEA,SACEA,SADF,EAEEC,UAFF,EAGEC,UAHF,EAIEC,SAJF,EAKEC,YALF,EAMEC,QANF,EAOEC,YAPF,EAQEC,aARF,EASEC,YATF,EAUEC,aAVF,EAWEC,IAXF,QAYO,YAZP;AAmCA,OAAO,MAAMC,OAAO,GAAsBC,CAAnB,IACpBA,CAAC,CAACC,MAAF,CAAS,CAAT,EAAYC,WAAZ,KAA4BF,CAAC,CAACG,KAAF,CAAQ,CAAR,CADxB;AAGP,OAAO,MAAMC,YAAY,GAAG,CAC1BC,KAD0B,EAE1BC,cAF0B,QAe1BC,QAf0B,KAgBvB;AAAA,MAbH;AACEF,IAAAA,KAAK,EAAEG,QADT;AAEEC,IAAAA,KAFF;AAGEC,IAAAA,SAHF;AAIEC,IAAAA,KAJF;AAKEC,IAAAA,WALF;AAMEC,IAAAA,UANF;AAOEC,IAAAA,SAPF;AAQEC,IAAAA,WARF;AASEC,IAAAA,OATF;AAUEC,IAAAA;AAVF,GAaG;;AACH,MAAIT,QAAQ,IAAIA,QAAQ,CAACU,OAAzB,EAAkC;AAChC,WAAOV,QAAQ,CAACU,OAAhB;AACD;;AACD,MAAIT,KAAK,KAAKU,SAAd,EAAyB;AACvB,UAAMC,CAAC,GAAG5B,YAAY,CAACiB,KAAD,EAAQH,cAAR,CAAtB;AACAD,IAAAA,KAAK,CAACgB,SAAN,CAAgB,IAAhB;AACAhB,IAAAA,KAAK,CAACiB,QAAN,CAAeF,CAAf;AACD,GAJD,MAIO;AACL,UAAMA,CAAC,GAAG5B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,CAAhB,EAAyB;AAC9B5B,MAAAA,KAAK,CAAC6B,aAAN,CAAoBD,KAApB;AACD,KAFM,MAEA,IAAItC,aAAa,CAACsC,KAAD,CAAjB,EAA0B;AAC/B5B,MAAAA,KAAK,CAAC8B,cAAN,CAAqBF,KAArB;AACD,KAFM,MAEA,IAAIrC,YAAY,CAACqC,KAAD,CAAhB,EAAyB;AAC9B5B,MAAAA,KAAK,CAAC+B,aAAN,CAAoBH,KAApB;AACD;AACF,GAVD;AAWA,QAAMI,OAAO,GAAG9B,QAAQ,CAAC+B,MAAT,CAAgBzC,aAAhB,CAAhB;;AACA,MAAIwC,OAAO,CAACE,MAAR,GAAiB,CAArB,EAAwB;AACtBlC,IAAAA,KAAK,CAACmC,cAAN,CACEH,OAAO,CACJI,OADH,GAEGC,MAFH,CAEgC5C,IAAI,CAAC6C,WAAL,CAAiBC,WAFjD,EAE8D,IAF9D,CADF;AAKD;;AACD,SAAOvC,KAAP;AACD,CAxEM","sourcesContent":["import type { ReactNode, RefObject } from \"react\";\n\nimport {\n BlendMode,\n PaintStyle,\n StrokeJoin,\n StrokeCap,\n processColor,\n isShader,\n isMaskFilter,\n isColorFilter,\n isPathEffect,\n isImageFilter,\n Skia,\n} from \"../../skia\";\nimport type { SkPaint, Color, SkImageFilter } from \"../../skia\";\nimport type { DeclarationResult } from \"../nodes\";\nexport type SkEnum<T> = Uncapitalize<keyof T extends string ? keyof T : never>;\n\nexport interface ChildrenProps {\n children?: ReactNode | ReactNode[];\n}\n\n// TODO: rename to paint props?\nexport interface CustomPaintProps extends ChildrenProps {\n paint?: RefObject<SkPaint>;\n color?: Color;\n strokeWidth?: number;\n blendMode?: SkEnum<typeof BlendMode>;\n style?: SkEnum<typeof PaintStyle>;\n strokeJoin?: SkEnum<typeof StrokeJoin>;\n strokeCap?: SkEnum<typeof StrokeCap>;\n strokeMiter?: number;\n opacity?: number;\n antiAlias?: boolean;\n}\n\nexport const enumKey = <K extends string>(k: K) =>\n (k.charAt(0).toUpperCase() + k.slice(1)) as Capitalize<K>;\n\nexport const processPaint = (\n paint: SkPaint,\n currentOpacity: number,\n {\n paint: paintRef,\n color,\n blendMode,\n style,\n strokeWidth,\n strokeJoin,\n strokeCap,\n strokeMiter,\n opacity,\n antiAlias,\n }: CustomPaintProps,\n children: DeclarationResult[]\n) => {\n if (paintRef && paintRef.current) {\n return paintRef.current;\n }\n if (color !== undefined) {\n const c = processColor(color, currentOpacity);\n paint.setShader(null);\n paint.setColor(c);\n } else {\n const c = processColor(paint.getColor(), currentOpacity);\n paint.setColor(c);\n }\n if (blendMode !== undefined) {\n paint.setBlendMode(BlendMode[enumKey(blendMode)]);\n }\n if (style !== undefined) {\n paint.setStyle(PaintStyle[enumKey(style)]);\n }\n if (strokeJoin !== undefined) {\n paint.setStrokeJoin(StrokeJoin[enumKey(strokeJoin)]);\n }\n if (strokeCap !== undefined) {\n paint.setStrokeCap(StrokeCap[enumKey(strokeCap)]);\n }\n if (strokeMiter !== undefined) {\n paint.setStrokeMiter(strokeMiter);\n }\n if (strokeWidth !== undefined) {\n paint.setStrokeWidth(strokeWidth);\n }\n if (opacity !== undefined) {\n paint.setAlphaf(opacity);\n }\n if (antiAlias !== undefined) {\n paint.setAntiAlias(antiAlias);\n }\n children.forEach((child) => {\n if (isShader(child)) {\n paint.setShader(child);\n } else if (isMaskFilter(child)) {\n paint.setMaskFilter(child);\n } else if (isColorFilter(child)) {\n paint.setColorFilter(child);\n } else if (isPathEffect(child)) {\n paint.setPathEffect(child);\n }\n });\n const filters = children.filter(isImageFilter);\n if (filters.length > 0) {\n paint.setImageFilter(\n filters\n .reverse()\n .reduce<SkImageFilter | null>(Skia.ImageFilter.MakeCompose, null)\n );\n }\n return paint;\n};\n"]}
@@ -1,4 +1,4 @@
1
- import { Platform, processColor as processColorRN } from "react-native"; // This is the JSI color. Currently a number. This may change.
1
+ import { Skia } from "./Skia"; // This is the JSI color. Currently a number. This may change.
2
2
 
3
3
  export const alphaf = c => (c >> 24 & 255) / 255;
4
4
  export const red = c => c >> 16 & 255;
@@ -8,28 +8,9 @@ export const rgbaColor = (r, g, b, af) => {
8
8
  const a = Math.round(af * 255);
9
9
  return (a << 24 | r << 16 | g << 8 | b) >>> 0;
10
10
  };
11
- export const processColorAsInt = color => {
12
- let processedColor = processColorRN(color);
13
-
14
- if (typeof processedColor !== "number") {
15
- throw new Error(`Couldn't process color: ${color}`);
16
- } // On android we need to move the alpha byte to the start of the structure
17
-
18
-
19
- if (Platform.OS === "android") {
20
- processedColor = processedColor >>> 0;
21
- const a = processedColor >> 24 & 0xff;
22
- const r = processedColor >> 16 & 0xff;
23
- const g = processedColor >> 8 & 0xff;
24
- const b = processedColor & 0xff;
25
- processedColor = (a << 24 | r << 16 | g << 8 | b) >>> 0;
26
- }
27
-
28
- return processedColor;
29
- };
30
11
 
31
12
  const processColorAsArray = cl => {
32
- const icl = typeof cl === "string" ? processColorAsInt(cl) : cl;
13
+ const icl = typeof cl === "string" ? Skia.Color(cl) : cl;
33
14
  const r = red(icl);
34
15
  const g = green(icl);
35
16
  const b = blue(icl);
@@ -1 +1 @@
1
- {"version":3,"sources":["Color.ts"],"names":["Platform","processColor","processColorRN","alphaf","c","red","green","blue","rgbaColor","r","g","b","af","a","Math","round","processColorAsInt","color","processedColor","Error","OS","processColorAsArray","cl","icl","currentOpacity","processColorAsUnitArray"],"mappings":"AAAA,SAASA,QAAT,EAAmBC,YAAY,IAAIC,cAAnC,QAAyD,cAAzD,C,CAEA;;AAKA,OAAO,MAAMC,MAAM,GAAIC,CAAD,IAAe,CAAEA,CAAC,IAAI,EAAN,GAAY,GAAb,IAAoB,GAAlD;AACP,OAAO,MAAMC,GAAG,GAAID,CAAD,IAAgBA,CAAC,IAAI,EAAN,GAAY,GAAvC;AACP,OAAO,MAAME,KAAK,GAAIF,CAAD,IAAgBA,CAAC,IAAI,CAAN,GAAW,GAAxC;AACP,OAAO,MAAMG,IAAI,GAAIH,CAAD,IAAeA,CAAC,GAAG,GAAhC;AACP,OA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C,GAAGJ,KAAK,CAACiB,GAAD,CAAf;AACA,QAAMZ,CAAC,GAAGJ,IAAI,CAACgB,GAAD,CAAd;AACA,QAAMV,CAAC,GAAGV,MAAM,CAACoB,GAAD,CAAhB;AACA,SAAO,CAACd,CAAD,EAAIC,CAAJ,EAAOC,CAAP,EAAUE,CAAV,CAAP;AACD,CAPD;;AASA,OAAO,MAAMZ,YAAY,GAAG,CAACqB,EAAD,EAAYE,cAAZ,KAAuC;AACjE,QAAM,CAACf,CAAD,EAAIC,CAAJ,EAAOC,CAAP,EAAUE,CAAV,IAAeQ,mBAAmB,CAACC,EAAD,CAAxC;AACA,SAAOd,SAAS,CAACC,CAAD,EAAIC,CAAJ,EAAOC,CAAP,EAAUE,CAAC,GAAGW,cAAd,CAAhB;AACD,CAHM;AAKP,OAAO,MAAMC,uBAAuB,GAAG,CAACH,EAAD,EAAYE,cAAZ,KAAuC;AAC5E,QAAM,CAACf,CAAD,EAAIC,CAAJ,EAAOC,CAAP,EAAUE,CAAV,IAAeQ,mBAAmB,CAACC,EAAD,CAAxC;AACA,SAAO,CAACb,CAAC,GAAG,GAAL,EAAUC,CAAC,GAAG,GAAd,EAAmBC,CAAC,GAAG,GAAvB,EAA4BE,CAAC,GAAGW,cAAhC,CAAP;AACD,CAHM","sourcesContent":["import { Platform, processColor as processColorRN } from \"react-native\";\n\n// This is the JSI color. Currently a number. This may change.\nexport type SkColor = number;\n\nexport type Color = string | number;\n\nexport const alphaf = (c: number) => ((c >> 24) & 255) / 255;\nexport const red = (c: number) => (c >> 16) & 255;\nexport const green = (c: number) => (c >> 8) & 255;\nexport const blue = (c: number) => c & 255;\nexport const rgbaColor = (r: number, g: number, b: number, af: number) => {\n const a = Math.round(af * 255);\n return ((a << 24) | (r << 16) | (g << 8) | b) >>> 0;\n};\n\nexport const processColorAsInt = (color?: number | string): SkColor => {\n let processedColor = processColorRN(color);\n if (typeof processedColor !== \"number\") {\n throw new Error(`Couldn't process color: ${color}`);\n }\n // On android we need to move the alpha byte to the start of the structure\n if (Platform.OS === \"android\") {\n processedColor = processedColor >>> 0;\n const a = (processedColor >> 24) & 0xff;\n const r = (processedColor >> 16) & 0xff;\n const g = (processedColor >> 8) & 0xff;\n const b = processedColor & 0xff;\n processedColor = ((a << 24) | (r << 16) | (g << 8) | b) >>> 0;\n }\n return processedColor;\n};\n\nconst processColorAsArray = (cl: Color) => {\n const icl = typeof cl === \"string\" ? processColorAsInt(cl) : cl;\n const r = red(icl);\n const g = green(icl);\n const b = blue(icl);\n const a = alphaf(icl);\n return [r, g, b, a] as const;\n};\n\nexport const processColor = (cl: Color, currentOpacity: number) => {\n const [r, g, b, a] = processColorAsArray(cl);\n return rgbaColor(r, g, b, a * currentOpacity);\n};\n\nexport const processColorAsUnitArray = (cl: Color, currentOpacity: number) => {\n const [r, g, b, a] = processColorAsArray(cl);\n return [r / 255, g / 255, b / 255, a * currentOpacity] as const;\n};\n"]}
1
+ {"version":3,"sources":["Color.ts"],"names":["Skia","alphaf","c","red","green","blue","rgbaColor","r","g","b","af","a","Math","round","processColorAsArray","cl","icl","Color","processColor","currentOpacity","processColorAsUnitArray"],"mappings":"AAAA,SAASA,IAAT,QAAqB,QAArB,C,CAEA;;AAKA,OAAO,MAAMC,MAAM,GAAIC,CAAD,IAAe,CAAEA,CAAC,IAAI,EAAN,GAAY,GAAb,IAAoB,GAAlD;AACP,OAAO,MAAMC,GAAG,GAAID,CAAD,IAAgBA,CAAC,IAAI,EAAN,GAAY,GAAvC;AACP,OAAO,MAAME,KAAK,GAAIF,CAAD,IAAgBA,CAAC,IAAI,CAAN,GAAW,GAAxC;AACP,OAAO,MAAMG,IAAI,GAAIH,CAAD,IAAeA,CAAC,GAAG,GAAhC;AACP,OAAO,MAAMI,SAAS,GAAG,CAACC,CAAD,EAAYC,CAAZ,EAAuBC,CAAvB,EAAkCC,EAAlC,KAAiD;AACxE,QAAMC,CAAC,GAAGC,IAAI,CAACC,KAAL,CAAWH,EAAE,GAAG,GAAhB,CAAV;AACA,SAAO,CAAEC,CAAC,IAAI,EAAN,GAAaJ,CAAC,IAAI,EAAlB,GAAyBC,CAAC,IAAI,CAA9B,GAAmCC,CAApC,MAA2C,CAAlD;AACD,CAHM;;AAKP,MAAMK,mBAAmB,GAAIC,EAAD,IAAe;AACzC,QAAMC,GAAG,GAAG,OAAOD,EAAP,KAAc,QAAd,GAAyBf,IAAI,CAACiB,KAAL,CAAWF,EAAX,CAAzB,GAA0CA,EAAtD;AACA,QAAMR,CAAC,GAAGJ,GAAG,CAACa,GAAD,CAAb;AACA,QAAMR,CAAC,GAAGJ,KAAK,CAACY,GAAD,CAAf;AACA,QAAMP,CAAC,GAAGJ,IAAI,CAACW,GAAD,CAAd;AACA,QAAML,CAAC,GAAGV,MAAM,CAACe,GAAD,CAAhB;AACA,SAAO,CAACT,CAAD,EAAIC,CAAJ,EAAOC,CAAP,EAAUE,CAAV,CAAP;AACD,CAPD;;AASA,OAAO,MAAMO,YAAY,GAAG,CAACH,EAAD,EAAYI,cAAZ,KAAuC;AACjE,QAAM,CAACZ,CAAD,EAAIC,CAAJ,EAAOC,CAAP,EAAUE,CAAV,IAAeG,mBAAmB,CAACC,EAAD,CAAxC;AACA,SAAOT,SAAS,CAACC,CAAD,EAAIC,CAAJ,EAAOC,CAAP,EAAUE,CAAC,GAAGQ,cAAd,CAAhB;AACD,CAHM;AAKP,OAAO,MAAMC,uBAAuB,GAAG,CAACL,EAAD,EAAYI,cAAZ,KAAuC;AAC5E,QAAM,CAACZ,CAAD,EAAIC,CAAJ,EAAOC,CAAP,EAAUE,CAAV,IAAeG,mBAAmB,CAACC,EAAD,CAAxC;AACA,SAAO,CAACR,CAAC,GAAG,GAAL,EAAUC,CAAC,GAAG,GAAd,EAAmBC,CAAC,GAAG,GAAvB,EAA4BE,CAAC,GAAGQ,cAAhC,CAAP;AACD,CAHM","sourcesContent":["import { Skia } from \"./Skia\";\n\n// This is the JSI color. Currently a number. This may change.\nexport type SkColor = number;\n// Input colors can be string or number\nexport type Color = string | number;\n\nexport const alphaf = (c: number) => ((c >> 24) & 255) / 255;\nexport const red = (c: number) => (c >> 16) & 255;\nexport const green = (c: number) => (c >> 8) & 255;\nexport const blue = (c: number) => c & 255;\nexport const rgbaColor = (r: number, g: number, b: number, af: number) => {\n const a = Math.round(af * 255);\n return ((a << 24) | (r << 16) | (g << 8) | b) >>> 0;\n};\n\nconst processColorAsArray = (cl: Color) => {\n const icl = typeof cl === \"string\" ? Skia.Color(cl) : cl;\n const r = red(icl);\n const g = green(icl);\n const b = blue(icl);\n const a = alphaf(icl);\n return [r, g, b, a] as const;\n};\n\nexport const processColor = (cl: Color, currentOpacity: number) => {\n const [r, g, b, a] = processColorAsArray(cl);\n return rgbaColor(r, g, b, a * currentOpacity);\n};\n\nexport const processColorAsUnitArray = (cl: Color, currentOpacity: number) => {\n const [r, g, b, a] = processColorAsArray(cl);\n return [r / 255, g / 255, b / 255, a * currentOpacity] as const;\n};\n"]}
@@ -1 +1 @@
1
- {"version":3,"sources":["Image.ts"],"names":["FilterMode","MipmapMode","ImageFormat"],"mappings":"AAKA,WAAYA,UAAZ;;WAAYA,U;AAAAA,EAAAA,U,CAAAA,U;AAAAA,EAAAA,U,CAAAA,U;GAAAA,U,KAAAA,U;;AAKZ,WAAYC,UAAZ;;WAAYA,U;AAAAA,EAAAA,U,CAAAA,U;AAAAA,EAAAA,U,CAAAA,U;AAAAA,EAAAA,U,CAAAA,U;GAAAA,U,KAAAA,U;;AAMZ,WAAYC,WAAZ;;WAAYA,W;AAAAA,EAAAA,W,CAAAA,W;AAAAA,EAAAA,W,CAAAA,W;AAAAA,EAAAA,W,CAAAA,W;GAAAA,W,KAAAA,W","sourcesContent":["import type { TileMode } from \"../ImageFilter\";\nimport type { IShader } from \"../Shader\";\nimport type { SkMatrix } from \"../Matrix\";\nimport type { SkJSIInstance } from \"../JsiInstance\";\n\nexport enum FilterMode {\n Linear,\n Nearest,\n}\n\nexport enum MipmapMode {\n None,\n Nearest,\n Linear,\n}\n\nexport enum ImageFormat {\n PNG,\n JPEG,\n WEBP,\n}\n\nexport interface SkImage extends SkJSIInstance<\"Image\"> {\n /**\n * Returns the possibly scaled height of the image.\n */\n height(): number;\n\n /**\n * Returns the possibly scaled width of the image.\n */\n width(): number;\n\n /**\n * Returns this image as a shader with the specified tiling. It will use cubic sampling.\n * @param tx - tile mode in the x direction.\n * @param ty - tile mode in the y direction.\n * @param fm - The filter mode. (default nearest)\n * @param mm - The mipmap mode. Note: for settings other than None, the image must have mipmaps (default none)\n * calculated with makeCopyWithDefaultMipmaps;\n * @param localMatrix\n */\n makeShaderOptions(\n tx: TileMode,\n ty: TileMode,\n fm: FilterMode,\n mm: MipmapMode,\n localMatrix?: SkMatrix\n ): IShader;\n\n /**\n * Returns this image as a shader with the specified tiling. It will use cubic sampling.\n * @param tx - tile mode in the x direction.\n * @param ty - tile mode in the y direction.\n * @param B - See CubicResampler in SkSamplingOptions.h for more information\n * @param C - See CubicResampler in SkSamplingOptions.h for more information\n * @param localMatrix\n */\n makeShaderCubic(\n tx: TileMode,\n ty: TileMode,\n B: number,\n C: number,\n localMatrix?: SkMatrix\n ): IShader;\n\n /** Encodes Image pixels, returning result as UInt8Array. Returns existing\n encoded data if present; otherwise, SkImage is encoded with\n SkEncodedImageFormat::kPNG. Skia must be built with SK_ENCODE_PNG to encode\n SkImage.\n\n Returns nullptr if existing encoded data is missing or invalid, and\n encoding fails.\n\n @param fmt - PNG is the default value.\n @param quality - a value from 0 to 100; 100 is the least lossy. May be ignored.\n\n @return Uint8Array with data\n */\n encodeToBytes(fmt?: ImageFormat, quality?: number): Uint8Array;\n\n /** Encodes Image pixels, returning result as a base64 encoded string. Returns existing\n encoded data if present; otherwise, SkImage is encoded with\n SkEncodedImageFormat::kPNG. Skia must be built with SK_ENCODE_PNG to encode\n SkImage.\n\n Returns nullptr if existing encoded data is missing or invalid, and\n encoding fails.\n\n @param fmt - PNG is the default value.\n @param quality - a value from 0 to 100; 100 is the least lossy. May be ignored.\n\n @return base64 encoded string of data\n */\n encodeToBase64(fmt?: ImageFormat, quality?: number): string;\n}\n"]}
1
+ {"version":3,"sources":["Image.ts"],"names":["FilterMode","MipmapMode","ImageFormat"],"mappings":"AAKA,WAAYA,UAAZ;;WAAYA,U;AAAAA,EAAAA,U,CAAAA,U;AAAAA,EAAAA,U,CAAAA,U;GAAAA,U,KAAAA,U;;AAKZ,WAAYC,UAAZ;;WAAYA,U;AAAAA,EAAAA,U,CAAAA,U;AAAAA,EAAAA,U,CAAAA,U;AAAAA,EAAAA,U,CAAAA,U;GAAAA,U,KAAAA,U;;AAMZ,WAAYC,WAAZ;;WAAYA,W;AAAAA,EAAAA,W,CAAAA,W;AAAAA,EAAAA,W,CAAAA,W;AAAAA,EAAAA,W,CAAAA,W;GAAAA,W,KAAAA,W","sourcesContent":["import type { TileMode } from \"../ImageFilter\";\nimport type { SkShader } from \"../Shader\";\nimport type { SkMatrix } from \"../Matrix\";\nimport type { SkJSIInstance } from \"../JsiInstance\";\n\nexport enum FilterMode {\n Linear,\n Nearest,\n}\n\nexport enum MipmapMode {\n None,\n Nearest,\n Linear,\n}\n\nexport enum ImageFormat {\n PNG,\n JPEG,\n WEBP,\n}\n\nexport interface SkImage extends SkJSIInstance<\"Image\"> {\n /**\n * Returns the possibly scaled height of the image.\n */\n height(): number;\n\n /**\n * Returns the possibly scaled width of the image.\n */\n width(): number;\n\n /**\n * Returns this image as a shader with the specified tiling. It will use cubic sampling.\n * @param tx - tile mode in the x direction.\n * @param ty - tile mode in the y direction.\n * @param fm - The filter mode. (default nearest)\n * @param mm - The mipmap mode. Note: for settings other than None, the image must have mipmaps (default none)\n * calculated with makeCopyWithDefaultMipmaps;\n * @param localMatrix\n */\n makeShaderOptions(\n tx: TileMode,\n ty: TileMode,\n fm: FilterMode,\n mm: MipmapMode,\n localMatrix?: SkMatrix\n ): SkShader;\n\n /**\n * Returns this image as a shader with the specified tiling. It will use cubic sampling.\n * @param tx - tile mode in the x direction.\n * @param ty - tile mode in the y direction.\n * @param B - See CubicResampler in SkSamplingOptions.h for more information\n * @param C - See CubicResampler in SkSamplingOptions.h for more information\n * @param localMatrix\n */\n makeShaderCubic(\n tx: TileMode,\n ty: TileMode,\n B: number,\n C: number,\n localMatrix?: SkMatrix\n ): SkShader;\n\n /** Encodes Image pixels, returning result as UInt8Array. Returns existing\n encoded data if present; otherwise, SkImage is encoded with\n SkEncodedImageFormat::kPNG. Skia must be built with SK_ENCODE_PNG to encode\n SkImage.\n\n Returns nullptr if existing encoded data is missing or invalid, and\n encoding fails.\n\n @param fmt - PNG is the default value.\n @param quality - a value from 0 to 100; 100 is the least lossy. May be ignored.\n\n @return Uint8Array with data\n */\n encodeToBytes(fmt?: ImageFormat, quality?: number): Uint8Array;\n\n /** Encodes Image pixels, returning result as a base64 encoded string. Returns existing\n encoded data if present; otherwise, SkImage is encoded with\n SkEncodedImageFormat::kPNG. Skia must be built with SK_ENCODE_PNG to encode\n SkImage.\n\n Returns nullptr if existing encoded data is missing or invalid, and\n encoding fails.\n\n @param fmt - PNG is the default value.\n @param quality - a value from 0 to 100; 100 is the least lossy. May be ignored.\n\n @return base64 encoded string of data\n */\n encodeToBase64(fmt?: ImageFormat, quality?: number): string;\n}\n"]}
@@ -1 +1 @@
1
- {"version":3,"sources":["ImageFilterFactory.ts"],"names":["ColorChannel"],"mappings":"AAQA,WAAYA,YAAZ;;WAAYA,Y;AAAAA,EAAAA,Y,CAAAA,Y;AAAAA,EAAAA,Y,CAAAA,Y;AAAAA,EAAAA,Y,CAAAA,Y;AAAAA,EAAAA,Y,CAAAA,Y;GAAAA,Y,KAAAA,Y","sourcesContent":["import type { SkColor } from \"../Color\";\nimport type { SkColorFilter } from \"../ColorFilter/ColorFilter\";\nimport type { IShader } from \"../Shader/Shader\";\nimport type { SkRect } from \"../Rect\";\nimport type { BlendMode } from \"../Paint/BlendMode\";\n\nimport type { SkImageFilter, TileMode } from \"./ImageFilter\";\n\nexport enum ColorChannel {\n R,\n G,\n B,\n A,\n}\n\nexport interface ImageFilterFactory {\n /**\n * Offsets the input image\n *\n * @param dx - Offset along the X axis\n * @param dy - Offset along the X axis\n * @param input - if null, it will use the dynamic source image\n */\n MakeOffset(\n dx: number,\n dy: number,\n input: SkImageFilter | null\n ): SkImageFilter;\n /**\n * Spatially displace pixel values of the filtered image\n *\n * @param channelX - Color channel to be used along the X axis\n * @param channelY - Color channel to be used along the Y axis\n * @param scale - Scale factor to be used in the displacement\n * @param in1 - Source image filter to use for the displacement\n * @param input - if null, it will use the dynamic source image\n */\n MakeDisplacementMap(\n channelX: ColorChannel,\n channelY: ColorChannel,\n scale: number,\n in1: SkImageFilter,\n input: SkImageFilter | null\n ): SkImageFilter;\n /**\n * Transforms a shader into an impage filter\n *\n * @param shader - The Shader to be transformed\n * @param input - if null, it will use the dynamic source image\n */\n MakeShader(shader: IShader, input: SkImageFilter | null): SkImageFilter;\n /**\n * Create a filter that blurs its input by the separate X and Y sigmas. The provided tile mode\n * is used when the blur kernel goes outside the input image.\n *\n * @param sigmaX - The Gaussian sigma value for blurring along the X axis.\n * @param sigmaY - The Gaussian sigma value for blurring along the Y axis.\n * @param mode\n * @param input - if null, it will use the dynamic source image (e.g. a saved layer)\n */\n MakeBlur(\n sigmaX: number,\n sigmaY: number,\n mode: TileMode,\n input: SkImageFilter | null\n ): SkImageFilter;\n\n /**\n * Create a filter that applies the color filter to the input filter results.\n * @param cf\n * @param input - if null, it will use the dynamic source image (e.g. a saved layer)\n */\n MakeColorFilter(\n cf: SkColorFilter,\n input: SkImageFilter | null\n ): SkImageFilter;\n\n /**\n * Create a filter that composes 'inner' with 'outer', such that the results of 'inner' are\n * treated as the source bitmap passed to 'outer'.\n * If either param is null, the other param will be returned.\n * @param outer\n * @param inner - if null, it will use the dynamic source image (e.g. a saved layer)\n */\n MakeCompose(\n outer: SkImageFilter | null,\n inner: SkImageFilter | null\n ): SkImageFilter;\n\n /**\n * Create a filter that draws a drop shadow under the input content.\n * This filter produces an image that includes the inputs' content.\n * @param dx The X offset of the shadow.\n * @param dy\tThe Y offset of the shadow.\n * @param sigmaX\tThe blur radius for the shadow, along the X axis.\n * @param sigmaY\tThe blur radius for the shadow, along the Y axis.\n * @param color\tThe color of the drop shadow.\n * @param input\tThe input filter, or will use the source bitmap if this is null.\n * @param cropRect\tOptional rectangle that crops the input and output.\n */\n MakeDropShadow: (\n dx: number,\n dy: number,\n sigmaX: number,\n sigmaY: number,\n color: SkColor,\n input: SkImageFilter | null,\n cropRect?: SkRect\n ) => SkImageFilter;\n /**\n * Create a filter that renders a drop shadow, in exactly the same manner as ::DropShadow, except\n * that the resulting image does not include the input content.\n * This allows the shadow and input to be composed by a filter DAG in a more flexible manner.\n * @param dx The X offset of the shadow.\n * @param dy\tThe Y offset of the shadow.\n * @param sigmaX\tThe blur radius for the shadow, along the X axis.\n * @param sigmaY\tThe blur radius for the shadow, along the Y axis.\n * @param color\tThe color of the drop shadow.\n * @param input\tThe input filter, or will use the source bitmap if this is null.\n * @param cropRect\tOptional rectangle that crops the input and output.\n */\n MakeDropShadowOnly: (\n dx: number,\n dy: number,\n sigmaX: number,\n sigmaY: number,\n color: SkColor,\n input: SkImageFilter | null,\n cropRect?: SkRect\n ) => SkImageFilter;\n /**\n * Create a filter that erodes each input pixel's channel values to the minimum channel value\n * within the given radii along the x and y axes.\n * @param radiusX The distance to erode along the x axis to either side of each pixel.\n * @param radiusY The distance to erode along the y axis to either side of each pixel.\n * @param input The image filter that is eroded, using source bitmap if this is null.\n * @param cropRect Optional rectangle that crops the input and output.\n */\n MakeErode: (\n rx: number,\n ry: number,\n input: SkImageFilter | null,\n cropRect?: SkRect\n ) => SkImageFilter;\n /**\n * Create a filter that dilates each input pixel's channel values to the max value within the\n * given radii along the x and y axes.\n * @param radiusX The distance to dilate along the x axis to either side of each pixel.\n * @param radiusY The distance to dilate along the y axis to either side of each pixel.\n * @param input The image filter that is dilated, using source bitmap if this is null.\n * @param cropRect Optional rectangle that crops the input and output.\n */\n MakeDilate: (\n rx: number,\n ry: number,\n input: SkImageFilter | null,\n cropRect?: SkRect\n ) => SkImageFilter;\n /**\n * This filter takes an SkBlendMode and uses it to composite the two filters together.\n * @param mode The blend mode that defines the compositing operation\n * @param background The Dst pixels used in blending, if null the source bitmap is used.\n * @param foreground The Src pixels used in blending, if null the source bitmap is used.\n * @cropRect Optional rectangle to crop input and output.\n */\n MakeBlend: (\n mode: BlendMode,\n background: SkImageFilter,\n foreground: SkImageFilter | null,\n cropRect?: SkRect\n ) => SkImageFilter;\n}\n"]}
1
+ {"version":3,"sources":["ImageFilterFactory.ts"],"names":["ColorChannel"],"mappings":"AAQA,WAAYA,YAAZ;;WAAYA,Y;AAAAA,EAAAA,Y,CAAAA,Y;AAAAA,EAAAA,Y,CAAAA,Y;AAAAA,EAAAA,Y,CAAAA,Y;AAAAA,EAAAA,Y,CAAAA,Y;GAAAA,Y,KAAAA,Y","sourcesContent":["import type { SkColor } from \"../Color\";\nimport type { SkColorFilter } from \"../ColorFilter/ColorFilter\";\nimport type { SkShader } from \"../Shader/Shader\";\nimport type { SkRect } from \"../Rect\";\nimport type { BlendMode } from \"../Paint/BlendMode\";\n\nimport type { SkImageFilter, TileMode } from \"./ImageFilter\";\n\nexport enum ColorChannel {\n R,\n G,\n B,\n A,\n}\n\nexport interface ImageFilterFactory {\n /**\n * Offsets the input image\n *\n * @param dx - Offset along the X axis\n * @param dy - Offset along the X axis\n * @param input - if null, it will use the dynamic source image\n */\n MakeOffset(\n dx: number,\n dy: number,\n input: SkImageFilter | null\n ): SkImageFilter;\n /**\n * Spatially displace pixel values of the filtered image\n *\n * @param channelX - Color channel to be used along the X axis\n * @param channelY - Color channel to be used along the Y axis\n * @param scale - Scale factor to be used in the displacement\n * @param in1 - Source image filter to use for the displacement\n * @param input - if null, it will use the dynamic source image\n */\n MakeDisplacementMap(\n channelX: ColorChannel,\n channelY: ColorChannel,\n scale: number,\n in1: SkImageFilter,\n input: SkImageFilter | null\n ): SkImageFilter;\n /**\n * Transforms a shader into an impage filter\n *\n * @param shader - The Shader to be transformed\n * @param input - if null, it will use the dynamic source image\n */\n MakeShader(shader: SkShader, input: SkImageFilter | null): SkImageFilter;\n /**\n * Create a filter that blurs its input by the separate X and Y sigmas. The provided tile mode\n * is used when the blur kernel goes outside the input image.\n *\n * @param sigmaX - The Gaussian sigma value for blurring along the X axis.\n * @param sigmaY - The Gaussian sigma value for blurring along the Y axis.\n * @param mode\n * @param input - if null, it will use the dynamic source image (e.g. a saved layer)\n */\n MakeBlur(\n sigmaX: number,\n sigmaY: number,\n mode: TileMode,\n input: SkImageFilter | null\n ): SkImageFilter;\n\n /**\n * Create a filter that applies the color filter to the input filter results.\n * @param cf\n * @param input - if null, it will use the dynamic source image (e.g. a saved layer)\n */\n MakeColorFilter(\n cf: SkColorFilter,\n input: SkImageFilter | null\n ): SkImageFilter;\n\n /**\n * Create a filter that composes 'inner' with 'outer', such that the results of 'inner' are\n * treated as the source bitmap passed to 'outer'.\n * If either param is null, the other param will be returned.\n * @param outer\n * @param inner - if null, it will use the dynamic source image (e.g. a saved layer)\n */\n MakeCompose(\n outer: SkImageFilter | null,\n inner: SkImageFilter | null\n ): SkImageFilter;\n\n /**\n * Create a filter that draws a drop shadow under the input content.\n * This filter produces an image that includes the inputs' content.\n * @param dx The X offset of the shadow.\n * @param dy\tThe Y offset of the shadow.\n * @param sigmaX\tThe blur radius for the shadow, along the X axis.\n * @param sigmaY\tThe blur radius for the shadow, along the Y axis.\n * @param color\tThe color of the drop shadow.\n * @param input\tThe input filter, or will use the source bitmap if this is null.\n * @param cropRect\tOptional rectangle that crops the input and output.\n */\n MakeDropShadow: (\n dx: number,\n dy: number,\n sigmaX: number,\n sigmaY: number,\n color: SkColor,\n input: SkImageFilter | null,\n cropRect?: SkRect\n ) => SkImageFilter;\n /**\n * Create a filter that renders a drop shadow, in exactly the same manner as ::DropShadow, except\n * that the resulting image does not include the input content.\n * This allows the shadow and input to be composed by a filter DAG in a more flexible manner.\n * @param dx The X offset of the shadow.\n * @param dy\tThe Y offset of the shadow.\n * @param sigmaX\tThe blur radius for the shadow, along the X axis.\n * @param sigmaY\tThe blur radius for the shadow, along the Y axis.\n * @param color\tThe color of the drop shadow.\n * @param input\tThe input filter, or will use the source bitmap if this is null.\n * @param cropRect\tOptional rectangle that crops the input and output.\n */\n MakeDropShadowOnly: (\n dx: number,\n dy: number,\n sigmaX: number,\n sigmaY: number,\n color: SkColor,\n input: SkImageFilter | null,\n cropRect?: SkRect\n ) => SkImageFilter;\n /**\n * Create a filter that erodes each input pixel's channel values to the minimum channel value\n * within the given radii along the x and y axes.\n * @param radiusX The distance to erode along the x axis to either side of each pixel.\n * @param radiusY The distance to erode along the y axis to either side of each pixel.\n * @param input The image filter that is eroded, using source bitmap if this is null.\n * @param cropRect Optional rectangle that crops the input and output.\n */\n MakeErode: (\n rx: number,\n ry: number,\n input: SkImageFilter | null,\n cropRect?: SkRect\n ) => SkImageFilter;\n /**\n * Create a filter that dilates each input pixel's channel values to the max value within the\n * given radii along the x and y axes.\n * @param radiusX The distance to dilate along the x axis to either side of each pixel.\n * @param radiusY The distance to dilate along the y axis to either side of each pixel.\n * @param input The image filter that is dilated, using source bitmap if this is null.\n * @param cropRect Optional rectangle that crops the input and output.\n */\n MakeDilate: (\n rx: number,\n ry: number,\n input: SkImageFilter | null,\n cropRect?: SkRect\n ) => SkImageFilter;\n /**\n * This filter takes an SkBlendMode and uses it to composite the two filters together.\n * @param mode The blend mode that defines the compositing operation\n * @param background The Dst pixels used in blending, if null the source bitmap is used.\n * @param foreground The Src pixels used in blending, if null the source bitmap is used.\n * @cropRect Optional rectangle to crop input and output.\n */\n MakeBlend: (\n mode: BlendMode,\n background: SkImageFilter,\n foreground: SkImageFilter | null,\n cropRect?: SkRect\n ) => SkImageFilter;\n}\n"]}
@@ -1,3 +1,4 @@
1
+ import { Skia } from "../Skia";
1
2
  export let PaintStyle;
2
3
 
3
4
  (function (PaintStyle) {
@@ -21,5 +22,10 @@ export let StrokeJoin;
21
22
  StrokeJoin[StrokeJoin["Round"] = 2] = "Round";
22
23
  })(StrokeJoin || (StrokeJoin = {}));
23
24
 
25
+ export const SkiaPaint = () => {
26
+ const paint = Skia.Paint();
27
+ paint.setAntiAlias(true);
28
+ return paint;
29
+ };
24
30
  export const isPaint = obj => obj !== null && obj.__typename__ === "Paint";
25
31
  //# sourceMappingURL=Paint.js.map
@@ -1 +1 @@
1
- {"version":3,"sources":["Paint.ts"],"names":["PaintStyle","StrokeCap","StrokeJoin","isPaint","obj","__typename__"],"mappings":"AAUA,WAAYA,UAAZ;;WAAYA,U;AAAAA,EAAAA,U,CAAAA,U;AAAAA,EAAAA,U,CAAAA,U;GAAAA,U,KAAAA,U;;AAKZ,WAAYC,SAAZ;;WAAYA,S;AAAAA,EAAAA,S,CAAAA,S;AAAAA,EAAAA,S,CAAAA,S;AAAAA,EAAAA,S,CAAAA,S;GAAAA,S,KAAAA,S;;AAMZ,WAAYC,UAAZ;;WAAYA,U;AAAAA,EAAAA,U,CAAAA,U;AAAAA,EAAAA,U,CAAAA,U;AAAAA,EAAAA,U,CAAAA,U;GAAAA,U,KAAAA,U;;AAMZ,OAAO,MAAMC,OAAO,GAAIC,GAAD,IACrBA,GAAG,KAAK,IAAR,IAAgBA,GAAG,CAACC,YAAJ,KAAqB,OADhC","sourcesContent":["import type { SkImageFilter } from \"../ImageFilter\";\nimport type { IMaskFilter } from \"../MaskFilter\";\nimport type { SkColorFilter } from \"../ColorFilter\";\nimport type { IShader } from \"../Shader\";\nimport type { SkColor } from \"../Color\";\nimport type { IPathEffect } from \"../PathEffect\";\nimport type { SkJSIInstance } from \"../JsiInstance\";\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 Bevel,\n Miter,\n Round,\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 * 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: IMaskFilter | 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: IPathEffect | null): void;\n\n /**\n * Sets the current shader, replacing the existing one if there was one.\n * @param shader\n */\n setShader(shader: IShader | 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"]}
1
+ {"version":3,"sources":["Paint.ts"],"names":["Skia","PaintStyle","StrokeCap","StrokeJoin","SkiaPaint","paint","Paint","setAntiAlias","isPaint","obj","__typename__"],"mappings":"AAOA,SAASA,IAAT,QAAqB,SAArB;AAIA,WAAYC,UAAZ;;WAAYA,U;AAAAA,EAAAA,U,CAAAA,U;AAAAA,EAAAA,U,CAAAA,U;GAAAA,U,KAAAA,U;;AAKZ,WAAYC,SAAZ;;WAAYA,S;AAAAA,EAAAA,S,CAAAA,S;AAAAA,EAAAA,S,CAAAA,S;AAAAA,EAAAA,S,CAAAA,S;GAAAA,S,KAAAA,S;;AAMZ,WAAYC,UAAZ;;WAAYA,U;AAAAA,EAAAA,U,CAAAA,U;AAAAA,EAAAA,U,CAAAA,U;AAAAA,EAAAA,U,CAAAA,U;GAAAA,U,KAAAA,U;;AAMZ,OAAO,MAAMC,SAAS,GAAG,MAAM;AAC7B,QAAMC,KAAK,GAAGL,IAAI,CAACM,KAAL,EAAd;AACAD,EAAAA,KAAK,CAACE,YAAN,CAAmB,IAAnB;AACA,SAAOF,KAAP;AACD,CAJM;AAMP,OAAO,MAAMG,OAAO,GAAIC,GAAD,IACrBA,GAAG,KAAK,IAAR,IAAgBA,GAAG,CAACC,YAAJ,KAAqB,OADhC","sourcesContent":["import type { SkImageFilter } from \"../ImageFilter\";\nimport type { IMaskFilter } from \"../MaskFilter\";\nimport type { SkColorFilter } from \"../ColorFilter\";\nimport type { SkShader } from \"../Shader\";\nimport type { SkColor } from \"../Color\";\nimport type { IPathEffect } from \"../PathEffect\";\nimport type { SkJSIInstance } from \"../JsiInstance\";\nimport { Skia } from \"../Skia\";\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 Bevel,\n Miter,\n Round,\n}\n\nexport const SkiaPaint = () => {\n const paint = Skia.Paint();\n paint.setAntiAlias(true);\n return paint;\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 * 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: IMaskFilter | 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: IPathEffect | 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"]}
@@ -1,12 +1,11 @@
1
1
  import { useMemo } from "react";
2
- import { Skia } from "../Skia";
2
+ import { SkiaPaint } from "./Paint";
3
3
 
4
4
  /**
5
5
  * Returns a Skia Paint object
6
6
  * */
7
7
  export const usePaint = (initializer, deps) => useMemo(() => {
8
- const p = Skia.Paint();
9
- p.setAntiAlias(true);
8
+ const p = SkiaPaint();
10
9
 
11
10
  if (initializer) {
12
11
  initializer(p);
@@ -1 +1 @@
1
- {"version":3,"sources":["usePaint.ts"],"names":["useMemo","Skia","usePaint","initializer","deps","p","Paint","setAntiAlias"],"mappings":"AACA,SAASA,OAAT,QAAwB,OAAxB;AAEA,SAASC,IAAT,QAAqB,SAArB;;AAIA;AACA;AACA;AACA,OAAO,MAAMC,QAAQ,GAAG,CACtBC,WADsB,EAEtBC,IAFsB,KAItBJ,OAAO,CAAC,MAAM;AACZ,QAAMK,CAAC,GAAGJ,IAAI,CAACK,KAAL,EAAV;AACAD,EAAAA,CAAC,CAACE,YAAF,CAAe,IAAf;;AACA,MAAIJ,WAAJ,EAAiB;AACfA,IAAAA,WAAW,CAACE,CAAD,CAAX;AACD;;AACD,SAAOA,CAAP,CANY,CAOZ;AACD,CARM,EAQJD,IARI,CAJF","sourcesContent":["import type { DependencyList } from \"react\";\nimport { useMemo } from \"react\";\n\nimport { Skia } from \"../Skia\";\n\nimport type { SkPaint } from \"./Paint\";\n\n/**\n * Returns a Skia Paint object\n * */\nexport const usePaint = (\n initializer?: (paint: SkPaint) => void,\n deps?: DependencyList\n) =>\n useMemo(() => {\n const p = Skia.Paint();\n p.setAntiAlias(true);\n if (initializer) {\n initializer(p);\n }\n return p;\n // eslint-disable-next-line react-hooks/exhaustive-deps\n }, deps);\n"]}
1
+ {"version":3,"sources":["usePaint.ts"],"names":["useMemo","SkiaPaint","usePaint","initializer","deps","p"],"mappings":"AACA,SAASA,OAAT,QAAwB,OAAxB;AAEA,SAASC,SAAT,QAA0B,SAA1B;;AAGA;AACA;AACA;AACA,OAAO,MAAMC,QAAQ,GAAG,CACtBC,WADsB,EAEtBC,IAFsB,KAItBJ,OAAO,CAAC,MAAM;AACZ,QAAMK,CAAC,GAAGJ,SAAS,EAAnB;;AACA,MAAIE,WAAJ,EAAiB;AACfA,IAAAA,WAAW,CAACE,CAAD,CAAX;AACD;;AACD,SAAOA,CAAP,CALY,CAMZ;AACD,CAPM,EAOJD,IAPI,CAJF","sourcesContent":["import type { DependencyList } from \"react\";\nimport { useMemo } from \"react\";\n\nimport { SkiaPaint } from \"./Paint\";\nimport type { SkPaint } from \"./Paint\";\n\n/**\n * Returns a Skia Paint object\n * */\nexport const usePaint = (\n initializer?: (paint: SkPaint) => void,\n deps?: DependencyList\n) =>\n useMemo(() => {\n const p = SkiaPaint();\n if (initializer) {\n initializer(p);\n }\n return p;\n // eslint-disable-next-line react-hooks/exhaustive-deps\n }, deps);\n"]}
@@ -20,5 +20,16 @@ export let PathOp;
20
20
  PathOp[PathOp["ReverseDifference"] = 4] = "ReverseDifference";
21
21
  })(PathOp || (PathOp = {}));
22
22
 
23
+ export let PathVerb;
24
+
25
+ (function (PathVerb) {
26
+ PathVerb[PathVerb["Move"] = 0] = "Move";
27
+ PathVerb[PathVerb["Line"] = 1] = "Line";
28
+ PathVerb[PathVerb["Quad"] = 2] = "Quad";
29
+ PathVerb[PathVerb["Conic"] = 3] = "Conic";
30
+ PathVerb[PathVerb["Cubic"] = 4] = "Cubic";
31
+ PathVerb[PathVerb["Close"] = 5] = "Close";
32
+ })(PathVerb || (PathVerb = {}));
33
+
23
34
  export const isPath = obj => obj !== null && obj.__typename__ === "Path";
24
35
  //# sourceMappingURL=Path.js.map
@@ -1 +1 @@
1
- {"version":3,"sources":["Path.ts"],"names":["FillType","PathOp","isPath","obj","__typename__"],"mappings":"AAQA;AACA;AACA;AAeA,WAAYA,QAAZ;;WAAYA,Q;AAAAA,EAAAA,Q,CAAAA,Q;AAAAA,EAAAA,Q,CAAAA,Q;AAAAA,EAAAA,Q,CAAAA,Q;AAAAA,EAAAA,Q,CAAAA,Q;GAAAA,Q,KAAAA,Q;;AAOZ,WAAYC,MAAZ;;WAAYA,M;AAAAA,EAAAA,M,CAAAA,M;AAAAA,EAAAA,M,CAAAA,M;AAAAA,EAAAA,M,CAAAA,M;AAAAA,EAAAA,M,CAAAA,M;AAAAA,EAAAA,M,CAAAA,M;GAAAA,M,KAAAA,M;;AAQZ,OAAO,MAAMC,MAAM,GAAIC,GAAD,IACpBA,GAAG,KAAK,IAAR,IAAgBA,GAAG,CAACC,YAAJ,KAAqB,MADhC","sourcesContent":["import type { SkFont } from \"../Font\";\nimport type { SkRect } from \"../Rect\";\nimport type { SkPoint } from \"../Point\";\nimport type { SkRRect } from \"../RRect\";\nimport type { StrokeJoin, StrokeCap } from \"../Paint\";\nimport type { SkMatrix } from \"../Matrix\";\nimport type { SkJSIInstance } from \"../JsiInstance\";\n\n/**\n * Options used for Path.stroke(). If an option is omitted, a sensible default will be used.\n */\nexport interface StrokeOpts {\n /** The width of the stroked lines. */\n width?: number;\n // eslint-disable-next-line camelcase\n miter_limit?: number;\n /**\n * if > 1, increase precision, else if (0 < resScale < 1) reduce precision to\n * favor speed and size\n */\n precision?: number;\n join?: StrokeJoin;\n cap?: StrokeCap;\n}\n\nexport enum FillType {\n Winding,\n EvenOdd,\n InverseWinding,\n InverseEvenOdd,\n}\n\nexport enum PathOp {\n Difference, //!< subtract the op path from the first path\n Intersect, //!< intersect the two paths\n Union, //!< union (inclusive-or) the two paths\n XOR, //!< exclusive-or the two paths\n ReverseDifference,\n}\n\nexport const isPath = (obj: SkJSIInstance<string> | null): obj is SkPath =>\n obj !== null && obj.__typename__ === \"Path\";\n\nexport interface SkPath extends SkJSIInstance<\"Path\"> {\n /**\n * Appends arc to Path, as the start of new contour. Arc added is part of ellipse\n * bounded by oval, from startAngle through sweepAngle. Both startAngle and\n * sweepAngle are measured in degrees, where zero degrees is aligned with the\n * positive x-axis, and positive sweeps extends arc clockwise.\n * Returns the modified path for easier chaining.\n * @param oval\n * @param startAngle\n * @param sweepAngle\n */\n addArc(\n oval: SkRect,\n startAngleInDegrees: number,\n sweepAngleInDegrees: number\n ): SkPath;\n\n /**\n * Adds oval to Path, appending kMove_Verb, four kConic_Verb, and kClose_Verb.\n * Oval is upright ellipse bounded by Rect oval with radii equal to half oval width\n * and half oval height. Oval begins at start and continues clockwise by default.\n * Returns the modified path for easier chaining.\n * @param oval\n * @param isCCW - if the path should be drawn counter-clockwise or not\n * @param startIndex - index of initial point of ellipse\n */\n addOval(oval: SkRect, isCCW?: boolean, startIndex?: number): void;\n\n /**\n * Returns the number of points in this path. Initially zero.\n */\n countPoints(): number;\n\n /**\n * Adds contour created from array of n points, adding (count - 1) line segments.\n * Contour added starts at pts[0], then adds a line for every additional point\n * in pts array. If close is true, appends kClose_Verb to Path, connecting\n * pts[count - 1] and pts[0].\n * Returns the modified path for easier chaining.\n * @param points\n * @param close - if true, will add a line connecting last point to the first point.\n */\n addPoly(points: SkPoint[], close: boolean): void;\n\n /** Adds beginning of contour at SkPoint (x, y).\n\n @param x x-axis value of contour start\n @param y y-axis value of contour start\n @return reference to SkPath\n\n example: https://fiddle.skia.org/c/@Path_moveTo\n */\n moveTo(x: number, y: number): void;\n /** Adds line from last point to (x, y). If SkPath is empty, or last SkPath::Verb is\n kClose_Verb, last point is set to (0, 0) before adding line.\n\n lineTo() appends kMove_Verb to verb array and (0, 0) to SkPoint array, if needed.\n lineTo() then appends kLine_Verb to verb array and (x, y) to SkPoint array.\n\n @param x end of added line on x-axis\n @param y end of added line on y-axis\n @return reference to SkPath\n\n example: https://fiddle.skia.org/c/@Path_lineTo\n */\n lineTo(x: number, y: number): void;\n\n /**\n * Returns a new path that covers the same area as the original path, but with the\n * Winding FillType. This may re-draw some contours in the path as counter-clockwise\n * instead of clockwise to achieve that effect. If such a transformation cannot\n * be done, null is returned.\n */\n makeAsWinding(): SkPath | null;\n\n /**\n * Translates all the points in the path by dx, dy.\n * @param dx\n * @param dy\n */\n offset(dx: number, dy: number): void;\n\n /**\n * Relative version of arcToRotated.\n * @param rx\n * @param ry\n * @param xAxisRotate\n * @param useSmallArc\n * @param isCCW\n * @param dx\n * @param dy\n */\n rArcTo(\n rx: number,\n ry: number,\n xAxisRotateInDegrees: number,\n useSmallArc: boolean,\n isCCW: boolean,\n dx: number,\n dy: number\n ): void;\n\n /**\n * Relative version of conicTo.\n * @param dx1\n * @param dy1\n * @param dx2\n * @param dy2\n * @param w\n */\n rConicTo(dx1: number, dy1: number, dx2: number, dy2: number, w: number): void;\n\n /**\n * Relative version of cubicTo.\n * @param cpx1\n * @param cpy1\n * @param cpx2\n * @param cpy2\n * @param x\n * @param y\n */\n rCubicTo(\n cpx1: number,\n cpy1: number,\n cpx2: number,\n cpy2: number,\n x: number,\n y: number\n ): void;\n\n /**\n * Relative version of moveTo.\n * @param x\n * @param y\n */\n rMoveTo(x: number, y: number): SkPath;\n\n /**\n * Relative version of lineTo.\n * @param x\n * @param y\n */\n rLineTo(x: number, y: number): SkPath;\n\n /**\n * Relative version of quadTo.\n * @param x1\n * @param y1\n * @param x2\n * @param y2\n */\n rQuadTo(x1: number, y1: number, x2: number, y2: number): SkPath;\n\n /**\n * Sets FillType, the rule used to fill Path.\n * @param fill\n */\n setFillType(fill: FillType): void;\n\n /**\n * Specifies whether Path is volatile; whether it will be altered or discarded\n * by the caller after it is drawn. Path by default have volatile set false.\n *\n * Mark animating or temporary paths as volatile to improve performance.\n * Mark unchanging Path non-volatile to improve repeated rendering.\n * @param volatile\n */\n setIsVolatile(volatile: boolean): void;\n\n /**\n * Turns this path into the filled equivalent of the stroked path. Returns false if the operation\n * fails (e.g. the path is a hairline).\n * @param opts - describe how stroked path should look.\n */\n stroke(opts?: StrokeOpts): boolean;\n\n /**\n * Appends CLOSE_VERB to Path. A closed contour connects the first and last point\n * with a line, forming a continuous loop.\n */\n close(): void;\n\n /**\n * Sets Path to its initial state.\n * Removes verb array, point array, and weights, and sets FillType to Winding.\n * Internal storage associated with Path is released\n */\n reset(): void;\n\n /**\n * Sets Path to its initial state.\n * Removes verb array, point array, and weights, and sets FillType to Winding.\n * Internal storage associated with Path is *not* released.\n * Use rewind() instead of reset() if Path storage will be reused and performance\n * is critical.\n */\n rewind(): void;\n\n /**\n * Returns minimum and maximum axes values of the lines and curves in Path.\n * Returns (0, 0, 0, 0) if Path contains no points.\n * Returned bounds width and height may be larger or smaller than area affected\n * when Path is drawn.\n *\n * Behaves identically to getBounds() when Path contains\n * only lines. If Path contains curves, computed bounds includes\n * the maximum extent of the quad, conic, or cubic; is slower than getBounds();\n * and unlike getBounds(), does not cache the result.\n * @param outputArray - if provided, the bounding box will be copied into this array instead of\n * allocating a new one.\n */\n computeTightBounds(outputArray?: SkRect): SkRect;\n\n /**\n * Appends arc to Path. Arc added is part of ellipse\n * bounded by oval, from startAngle through sweepAngle. Both startAngle and\n * sweepAngle are measured in degrees, where zero degrees is aligned with the\n * positive x-axis, and positive sweeps extends arc clockwise.\n * Returns the modified path for easier chaining.\n * @param oval\n * @param startAngleInDegrees\n * @param sweepAngleInDegrees\n * @param forceMoveTo\n */\n arcToOval(\n oval: SkRect,\n startAngleInDegrees: number,\n sweepAngleInDegrees: number,\n forceMoveTo: boolean\n ): SkPath;\n\n /**\n * Appends arc to Path. Arc is implemented by one or more conics weighted to\n * describe part of oval with radii (rx, ry) rotated by xAxisRotate degrees. Arc\n * curves from last Path Point to (x, y), choosing one of four possible routes:\n * clockwise or counterclockwise, and smaller or larger. See SkPath.h for more details.\n * Returns the modified path for easier chaining.\n * @param rx\n * @param ry\n * @param xAxisRotate\n * @param useSmallArc\n * @param isCCW\n * @param x\n * @param y\n */\n arcToRotated(\n rx: number,\n ry: number,\n xAxisRotateInDegrees: number,\n useSmallArc: boolean,\n isCCW: boolean,\n x: number,\n y: number\n ): SkPath;\n\n /**\n * Appends arc to Path, after appending line if needed. Arc is implemented by conic\n * weighted to describe part of circle. Arc is contained by tangent from\n * last Path point to (x1, y1), and tangent from (x1, y1) to (x2, y2). Arc\n * is part of circle sized to radius, positioned so it touches both tangent lines.\n * Returns the modified path for easier chaining.\n * @param x1\n * @param y1\n * @param x2\n * @param y2\n * @param radius\n */\n arcToTangent(\n x1: number,\n y1: number,\n x2: number,\n y2: number,\n radius: number\n ): SkPath;\n\n /**\n * Adds conic from last point towards (x1, y1), to (x2, y2), weighted by w.\n * If Path is empty, or path is closed, the last point is set to (0, 0)\n * before adding conic.\n * Returns the modified path for easier chaining.\n * @param x1\n * @param y1\n * @param x2\n * @param y2\n * @param w\n */\n conicTo(x1: number, y1: number, x2: number, y2: number, w: number): SkPath;\n\n /**\n * Returns true if the point (x, y) is contained by Path, taking into\n * account FillType.\n * @param x\n * @param y\n */\n contains(x: number, y: number): boolean;\n\n /**\n * Returns a copy of this Path.\n */\n copy(): SkPath;\n\n /**\n * Adds cubic from last point towards (x1, y1), then towards (x2, y2), ending at\n * (x3, y3). If Path is empty, or path is closed, the last point is set to\n * (0, 0) before adding cubic.\n * @param cpx1\n * @param cpy1\n * @param cpx2\n * @param cpy2\n * @param x\n * @param y\n */\n cubicTo(\n cpx1: number,\n cpy1: number,\n cpx2: number,\n cpy2: number,\n x: number,\n y: number\n ): void;\n\n /**\n * Changes this path to be the dashed version of itself. This is the same effect as creating\n * a DashPathEffect and calling filterPath on this path.\n * @param on\n * @param off\n * @param phase\n */\n dash(on: number, off: number, phase: number): boolean;\n\n /**\n * Returns true if other path is equal to this path.\n * @param other\n */\n equals(other: SkPath): boolean;\n\n /**\n * Returns minimum and maximum axes values of Point array.\n * Returns (0, 0, 0, 0) if Path contains no points. Returned bounds width and height may\n * be larger or smaller than area affected when Path is drawn.\n */\n getBounds(): SkRect;\n\n /**\n * Return the FillType for this path.\n */\n getFillType(): FillType;\n\n /**\n Adds quad from last point towards (x1, y1), to (x2, y2).\n\n If SkPath is empty, or last SkPath::Verb is kClose_Verb, last point is set to (0, 0) before adding quad.\n\n Appends kMove_Verb to verb array and (0, 0) to SkPoint array, if needed; then appends kQuad_Verb to verb array;\n and (x1, y1), (x2, y2) to SkPoint array.\n\n Parameters\n x1\tcontrol SkPoint of quad on x-axis\n y1\tcontrol SkPoint of quad on y-axis\n x2\tend SkPoint of quad on x-axis\n y2\tend SkPoint of quad on y-axis\n Returns\n reference to SkPath\n example: https://fiddle.skia.org/c/@Path_quadTo\n */\n quadTo(x1: number, y1: number, x2: number, y2: number): void;\n\n /**\n * Adds Rect to Path, appending kMove_Verb, three kLine_Verb, and kClose_Verb,\n * starting with top-left corner of Rect; followed by top-right, bottom-right,\n * and bottom-left if isCCW is false; or followed by bottom-left,\n * bottom-right, and top-right if isCCW is true.\n * Returns the modified path for easier chaining.\n * @param rect\n * @param isCCW\n */\n addRect(rect: SkRect, isCCW?: boolean): void;\n\n /**\n * Adds rrect to Path, creating a new closed contour.\n * Returns the modified path for easier chaining.\n * @param rrect\n * @param isCCW\n */\n addRRect(rrect: SkRRect, isCCW?: boolean): SkPath;\n\n /**\n * Returns the Point at index in Point array. Valid range for index is\n * 0 to countPoints() - 1.\n * @param index\n */\n getPoint(index: number): SkPoint;\n\n /**\n * Returns true if there are no verbs in the path.\n */\n isEmpty(): boolean;\n\n /**\n * Returns true if the path is volatile; it will not be altered or discarded\n * by the caller after it is drawn. Path by default have volatile set false, allowing\n * Surface to attach a cache of data which speeds repeated drawing. If true, Surface\n * may not speed repeated drawing.\n */\n isVolatile(): boolean;\n\n addCircle(x: number, y: number, r: number): void;\n\n getLastPt(): { x: number; y: number };\n\n /** Set this path to the result of applying the Op to this path and the\n specified path: this = (this op operand).\n The resulting path will be constructed from non-overlapping contours.\n The curve order is reduced where possible so that cubics may be turned\n into quadratics, and quadratics maybe turned into lines.\n\n Returns true if operation was able to produce a result;\n otherwise, result is unmodified.\n\n @param path The second path (for difference, the subtrahend)\n @param op The operator to apply.\n @param result The product of the operands. The result may be one of the\n inputs.\n @return True if the operation succeeded.\n */\n op(path: SkPath, op: PathOp): boolean;\n\n /** Set this path to a set of non-overlapping contours that describe the\n same area as the original path.\n The curve order is reduced where possible so that cubics may\n be turned into quadratics, and quadratics maybe turned into lines.\n\n Returns true if operation was able to produce a result;\n otherwise, result is unmodified.\n\n @param result The simplified path. The result may be the input.\n @return True if simplification succeeded.\n */\n simplify(): boolean;\n\n /**\n * Returns this path as an SVG string.\n */\n toSVGString(): string;\n\n /**\n * Take start and stop \"t\" values (values between 0...1), and modify this path such that\n * it is a subset of the original path.\n * The trim values apply to the entire path, so if it contains several contours, all of them\n * are including in the calculation.\n * Null is returned if either input value is NaN.\n * @param startT - a value in the range [0.0, 1.0]. 0.0 is the beginning of the path.\n * @param stopT - a value in the range [0.0, 1.0]. 1.0 is the end of the path.\n * @param isComplement\n */\n trim(startT: number, stopT: number, isComplement: boolean): boolean;\n\n /**\n * Transforms the path by the specified matrix.\n */\n transform(m3: SkMatrix): void;\n\n /**\n * Converts the text to a path with the given font at location x / y.\n */\n fromText(text: string, x: number, y: number, font: SkFont): void;\n\n /**\n * Interpolates between Path with point array of equal size.\n * Copy verb array and weights to result, and set result path to a weighted\n * average of this path array and ending path.\n\n * weight is most useful when between zero (ending path) and\n one (this path); will work with values outside of this\n range.\n\n * interpolate() returns undefined if path is not\n * the same size as ending path. Call isInterpolatable() to check Path\n * compatibility prior to calling interpolate().\n\n * @param ending path to interpolate with\n * @param weight contribution of this path, and\n * one minus contribution of ending path\n * @return Path replaced by interpolated averages or undefined if \n * not interpolatable\n * */\n interpolate(end: SkPath, weight: number): SkPath;\n\n /** Returns true if Path contain equal verbs and equal weights.\n * @param compare path to compare\n * @return true if Path can be interpolated equivalent\n *\n * */\n isInterpolatable(compare: SkPath): boolean;\n}\n"]}
1
+ {"version":3,"sources":["Path.ts"],"names":["FillType","PathOp","PathVerb","isPath","obj","__typename__"],"mappings":"AAQA;AACA;AACA;AAeA,WAAYA,QAAZ;;WAAYA,Q;AAAAA,EAAAA,Q,CAAAA,Q;AAAAA,EAAAA,Q,CAAAA,Q;AAAAA,EAAAA,Q,CAAAA,Q;AAAAA,EAAAA,Q,CAAAA,Q;GAAAA,Q,KAAAA,Q;;AAOZ,WAAYC,MAAZ;;WAAYA,M;AAAAA,EAAAA,M,CAAAA,M;AAAAA,EAAAA,M,CAAAA,M;AAAAA,EAAAA,M,CAAAA,M;AAAAA,EAAAA,M,CAAAA,M;AAAAA,EAAAA,M,CAAAA,M;GAAAA,M,KAAAA,M;;AAQZ,WAAYC,QAAZ;;WAAYA,Q;AAAAA,EAAAA,Q,CAAAA,Q;AAAAA,EAAAA,Q,CAAAA,Q;AAAAA,EAAAA,Q,CAAAA,Q;AAAAA,EAAAA,Q,CAAAA,Q;AAAAA,EAAAA,Q,CAAAA,Q;AAAAA,EAAAA,Q,CAAAA,Q;GAAAA,Q,KAAAA,Q;;AAWZ,OAAO,MAAMC,MAAM,GAAIC,GAAD,IACpBA,GAAG,KAAK,IAAR,IAAgBA,GAAG,CAACC,YAAJ,KAAqB,MADhC","sourcesContent":["import type { SkFont } from \"../Font\";\nimport type { SkRect } from \"../Rect\";\nimport type { SkPoint } from \"../Point\";\nimport type { SkRRect } from \"../RRect\";\nimport type { StrokeJoin, StrokeCap } from \"../Paint\";\nimport type { SkMatrix } from \"../Matrix\";\nimport type { SkJSIInstance } from \"../JsiInstance\";\n\n/**\n * Options used for Path.stroke(). If an option is omitted, a sensible default will be used.\n */\nexport interface StrokeOpts {\n /** The width of the stroked lines. */\n width?: number;\n // eslint-disable-next-line camelcase\n miter_limit?: number;\n /**\n * if > 1, increase precision, else if (0 < resScale < 1) reduce precision to\n * favor speed and size\n */\n precision?: number;\n join?: StrokeJoin;\n cap?: StrokeCap;\n}\n\nexport enum FillType {\n Winding,\n EvenOdd,\n InverseWinding,\n InverseEvenOdd,\n}\n\nexport enum PathOp {\n Difference, //!< subtract the op path from the first path\n Intersect, //!< intersect the two paths\n Union, //!< union (inclusive-or) the two paths\n XOR, //!< exclusive-or the two paths\n ReverseDifference,\n}\n\nexport enum PathVerb {\n Move,\n Line,\n Quad,\n Conic,\n Cubic,\n Close,\n}\n\nexport type PathCommand = number[];\n\nexport const isPath = (obj: SkJSIInstance<string> | null): obj is SkPath =>\n obj !== null && obj.__typename__ === \"Path\";\n\nexport interface SkPath extends SkJSIInstance<\"Path\"> {\n /**\n * Appends arc to Path, as the start of new contour. Arc added is part of ellipse\n * bounded by oval, from startAngle through sweepAngle. Both startAngle and\n * sweepAngle are measured in degrees, where zero degrees is aligned with the\n * positive x-axis, and positive sweeps extends arc clockwise.\n * Returns the modified path for easier chaining.\n * @param oval\n * @param startAngle\n * @param sweepAngle\n */\n addArc(\n oval: SkRect,\n startAngleInDegrees: number,\n sweepAngleInDegrees: number\n ): SkPath;\n\n /**\n * Adds oval to Path, appending kMove_Verb, four kConic_Verb, and kClose_Verb.\n * Oval is upright ellipse bounded by Rect oval with radii equal to half oval width\n * and half oval height. Oval begins at start and continues clockwise by default.\n * Returns the modified path for easier chaining.\n * @param oval\n * @param isCCW - if the path should be drawn counter-clockwise or not\n * @param startIndex - index of initial point of ellipse\n */\n addOval(oval: SkRect, isCCW?: boolean, startIndex?: number): void;\n\n /**\n * Returns the number of points in this path. Initially zero.\n */\n countPoints(): number;\n\n /**\n * Adds contour created from array of n points, adding (count - 1) line segments.\n * Contour added starts at pts[0], then adds a line for every additional point\n * in pts array. If close is true, appends kClose_Verb to Path, connecting\n * pts[count - 1] and pts[0].\n * Returns the modified path for easier chaining.\n * @param points\n * @param close - if true, will add a line connecting last point to the first point.\n */\n addPoly(points: SkPoint[], close: boolean): void;\n\n /** Adds beginning of contour at SkPoint (x, y).\n\n @param x x-axis value of contour start\n @param y y-axis value of contour start\n @return reference to SkPath\n\n example: https://fiddle.skia.org/c/@Path_moveTo\n */\n moveTo(x: number, y: number): void;\n /** Adds line from last point to (x, y). If SkPath is empty, or last SkPath::Verb is\n kClose_Verb, last point is set to (0, 0) before adding line.\n\n lineTo() appends kMove_Verb to verb array and (0, 0) to SkPoint array, if needed.\n lineTo() then appends kLine_Verb to verb array and (x, y) to SkPoint array.\n\n @param x end of added line on x-axis\n @param y end of added line on y-axis\n @return reference to SkPath\n\n example: https://fiddle.skia.org/c/@Path_lineTo\n */\n lineTo(x: number, y: number): void;\n\n /**\n * Returns a new path that covers the same area as the original path, but with the\n * Winding FillType. This may re-draw some contours in the path as counter-clockwise\n * instead of clockwise to achieve that effect. If such a transformation cannot\n * be done, null is returned.\n */\n makeAsWinding(): SkPath | null;\n\n /**\n * Translates all the points in the path by dx, dy.\n * @param dx\n * @param dy\n */\n offset(dx: number, dy: number): void;\n\n /**\n * Relative version of arcToRotated.\n * @param rx\n * @param ry\n * @param xAxisRotate\n * @param useSmallArc\n * @param isCCW\n * @param dx\n * @param dy\n */\n rArcTo(\n rx: number,\n ry: number,\n xAxisRotateInDegrees: number,\n useSmallArc: boolean,\n isCCW: boolean,\n dx: number,\n dy: number\n ): void;\n\n /**\n * Relative version of conicTo.\n * @param dx1\n * @param dy1\n * @param dx2\n * @param dy2\n * @param w\n */\n rConicTo(dx1: number, dy1: number, dx2: number, dy2: number, w: number): void;\n\n /**\n * Relative version of cubicTo.\n * @param cpx1\n * @param cpy1\n * @param cpx2\n * @param cpy2\n * @param x\n * @param y\n */\n rCubicTo(\n cpx1: number,\n cpy1: number,\n cpx2: number,\n cpy2: number,\n x: number,\n y: number\n ): void;\n\n /**\n * Relative version of moveTo.\n * @param x\n * @param y\n */\n rMoveTo(x: number, y: number): SkPath;\n\n /**\n * Relative version of lineTo.\n * @param x\n * @param y\n */\n rLineTo(x: number, y: number): SkPath;\n\n /**\n * Relative version of quadTo.\n * @param x1\n * @param y1\n * @param x2\n * @param y2\n */\n rQuadTo(x1: number, y1: number, x2: number, y2: number): SkPath;\n\n /**\n * Sets FillType, the rule used to fill Path.\n * @param fill\n */\n setFillType(fill: FillType): void;\n\n /**\n * Specifies whether Path is volatile; whether it will be altered or discarded\n * by the caller after it is drawn. Path by default have volatile set false.\n *\n * Mark animating or temporary paths as volatile to improve performance.\n * Mark unchanging Path non-volatile to improve repeated rendering.\n * @param volatile\n */\n setIsVolatile(volatile: boolean): void;\n\n /**\n * Turns this path into the filled equivalent of the stroked path. Returns false if the operation\n * fails (e.g. the path is a hairline).\n * @param opts - describe how stroked path should look.\n */\n stroke(opts?: StrokeOpts): boolean;\n\n /**\n * Appends CLOSE_VERB to Path. A closed contour connects the first and last point\n * with a line, forming a continuous loop.\n */\n close(): void;\n\n /**\n * Sets Path to its initial state.\n * Removes verb array, point array, and weights, and sets FillType to Winding.\n * Internal storage associated with Path is released\n */\n reset(): void;\n\n /**\n * Sets Path to its initial state.\n * Removes verb array, point array, and weights, and sets FillType to Winding.\n * Internal storage associated with Path is *not* released.\n * Use rewind() instead of reset() if Path storage will be reused and performance\n * is critical.\n */\n rewind(): void;\n\n /**\n * Returns minimum and maximum axes values of the lines and curves in Path.\n * Returns (0, 0, 0, 0) if Path contains no points.\n * Returned bounds width and height may be larger or smaller than area affected\n * when Path is drawn.\n *\n * Behaves identically to getBounds() when Path contains\n * only lines. If Path contains curves, computed bounds includes\n * the maximum extent of the quad, conic, or cubic; is slower than getBounds();\n * and unlike getBounds(), does not cache the result.\n * @param outputArray - if provided, the bounding box will be copied into this array instead of\n * allocating a new one.\n */\n computeTightBounds(outputArray?: SkRect): SkRect;\n\n /**\n * Appends arc to Path. Arc added is part of ellipse\n * bounded by oval, from startAngle through sweepAngle. Both startAngle and\n * sweepAngle are measured in degrees, where zero degrees is aligned with the\n * positive x-axis, and positive sweeps extends arc clockwise.\n * Returns the modified path for easier chaining.\n * @param oval\n * @param startAngleInDegrees\n * @param sweepAngleInDegrees\n * @param forceMoveTo\n */\n arcToOval(\n oval: SkRect,\n startAngleInDegrees: number,\n sweepAngleInDegrees: number,\n forceMoveTo: boolean\n ): SkPath;\n\n /**\n * Appends arc to Path. Arc is implemented by one or more conics weighted to\n * describe part of oval with radii (rx, ry) rotated by xAxisRotate degrees. Arc\n * curves from last Path Point to (x, y), choosing one of four possible routes:\n * clockwise or counterclockwise, and smaller or larger. See SkPath.h for more details.\n * Returns the modified path for easier chaining.\n * @param rx\n * @param ry\n * @param xAxisRotate\n * @param useSmallArc\n * @param isCCW\n * @param x\n * @param y\n */\n arcToRotated(\n rx: number,\n ry: number,\n xAxisRotateInDegrees: number,\n useSmallArc: boolean,\n isCCW: boolean,\n x: number,\n y: number\n ): SkPath;\n\n /**\n * Appends arc to Path, after appending line if needed. Arc is implemented by conic\n * weighted to describe part of circle. Arc is contained by tangent from\n * last Path point to (x1, y1), and tangent from (x1, y1) to (x2, y2). Arc\n * is part of circle sized to radius, positioned so it touches both tangent lines.\n * Returns the modified path for easier chaining.\n * @param x1\n * @param y1\n * @param x2\n * @param y2\n * @param radius\n */\n arcToTangent(\n x1: number,\n y1: number,\n x2: number,\n y2: number,\n radius: number\n ): SkPath;\n\n /**\n * Adds conic from last point towards (x1, y1), to (x2, y2), weighted by w.\n * If Path is empty, or path is closed, the last point is set to (0, 0)\n * before adding conic.\n * Returns the modified path for easier chaining.\n * @param x1\n * @param y1\n * @param x2\n * @param y2\n * @param w\n */\n conicTo(x1: number, y1: number, x2: number, y2: number, w: number): SkPath;\n\n /**\n * Returns true if the point (x, y) is contained by Path, taking into\n * account FillType.\n * @param x\n * @param y\n */\n contains(x: number, y: number): boolean;\n\n /**\n * Returns a copy of this Path.\n */\n copy(): SkPath;\n\n /**\n * Adds cubic from last point towards (x1, y1), then towards (x2, y2), ending at\n * (x3, y3). If Path is empty, or path is closed, the last point is set to\n * (0, 0) before adding cubic.\n * @param cpx1\n * @param cpy1\n * @param cpx2\n * @param cpy2\n * @param x\n * @param y\n */\n cubicTo(\n cpx1: number,\n cpy1: number,\n cpx2: number,\n cpy2: number,\n x: number,\n y: number\n ): void;\n\n /**\n * Changes this path to be the dashed version of itself. This is the same effect as creating\n * a DashPathEffect and calling filterPath on this path.\n * @param on\n * @param off\n * @param phase\n */\n dash(on: number, off: number, phase: number): boolean;\n\n /**\n * Returns true if other path is equal to this path.\n * @param other\n */\n equals(other: SkPath): boolean;\n\n /**\n * Returns minimum and maximum axes values of Point array.\n * Returns (0, 0, 0, 0) if Path contains no points. Returned bounds width and height may\n * be larger or smaller than area affected when Path is drawn.\n */\n getBounds(): SkRect;\n\n /**\n * Return the FillType for this path.\n */\n getFillType(): FillType;\n\n /**\n Adds quad from last point towards (x1, y1), to (x2, y2).\n\n If SkPath is empty, or last SkPath::Verb is kClose_Verb, last point is set to (0, 0) before adding quad.\n\n Appends kMove_Verb to verb array and (0, 0) to SkPoint array, if needed; then appends kQuad_Verb to verb array;\n and (x1, y1), (x2, y2) to SkPoint array.\n\n Parameters\n x1\tcontrol SkPoint of quad on x-axis\n y1\tcontrol SkPoint of quad on y-axis\n x2\tend SkPoint of quad on x-axis\n y2\tend SkPoint of quad on y-axis\n Returns\n reference to SkPath\n example: https://fiddle.skia.org/c/@Path_quadTo\n */\n quadTo(x1: number, y1: number, x2: number, y2: number): void;\n\n /**\n * Adds Rect to Path, appending kMove_Verb, three kLine_Verb, and kClose_Verb,\n * starting with top-left corner of Rect; followed by top-right, bottom-right,\n * and bottom-left if isCCW is false; or followed by bottom-left,\n * bottom-right, and top-right if isCCW is true.\n * Returns the modified path for easier chaining.\n * @param rect\n * @param isCCW\n */\n addRect(rect: SkRect, isCCW?: boolean): void;\n\n /**\n * Adds rrect to Path, creating a new closed contour.\n * Returns the modified path for easier chaining.\n * @param rrect\n * @param isCCW\n */\n addRRect(rrect: SkRRect, isCCW?: boolean): SkPath;\n\n /**\n * Returns the Point at index in Point array. Valid range for index is\n * 0 to countPoints() - 1.\n * @param index\n */\n getPoint(index: number): SkPoint;\n\n /**\n * Returns true if there are no verbs in the path.\n */\n isEmpty(): boolean;\n\n /**\n * Returns true if the path is volatile; it will not be altered or discarded\n * by the caller after it is drawn. Path by default have volatile set false, allowing\n * Surface to attach a cache of data which speeds repeated drawing. If true, Surface\n * may not speed repeated drawing.\n */\n isVolatile(): boolean;\n\n addCircle(x: number, y: number, r: number): void;\n\n getLastPt(): { x: number; y: number };\n\n /** Set this path to the result of applying the Op to this path and the\n specified path: this = (this op operand).\n The resulting path will be constructed from non-overlapping contours.\n The curve order is reduced where possible so that cubics may be turned\n into quadratics, and quadratics maybe turned into lines.\n\n Returns true if operation was able to produce a result;\n otherwise, result is unmodified.\n\n @param path The second path (for difference, the subtrahend)\n @param op The operator to apply.\n @param result The product of the operands. The result may be one of the\n inputs.\n @return True if the operation succeeded.\n */\n op(path: SkPath, op: PathOp): boolean;\n\n /** Set this path to a set of non-overlapping contours that describe the\n same area as the original path.\n The curve order is reduced where possible so that cubics may\n be turned into quadratics, and quadratics maybe turned into lines.\n\n Returns true if operation was able to produce a result;\n otherwise, result is unmodified.\n\n @param result The simplified path. The result may be the input.\n @return True if simplification succeeded.\n */\n simplify(): boolean;\n\n /**\n * Returns this path as an SVG string.\n */\n toSVGString(): string;\n\n /**\n * Take start and stop \"t\" values (values between 0...1), and modify this path such that\n * it is a subset of the original path.\n * The trim values apply to the entire path, so if it contains several contours, all of them\n * are including in the calculation.\n * Null is returned if either input value is NaN.\n * @param startT - a value in the range [0.0, 1.0]. 0.0 is the beginning of the path.\n * @param stopT - a value in the range [0.0, 1.0]. 1.0 is the end of the path.\n * @param isComplement\n */\n trim(startT: number, stopT: number, isComplement: boolean): boolean;\n\n /**\n * Transforms the path by the specified matrix.\n */\n transform(m3: SkMatrix): void;\n\n /**\n * Converts the text to a path with the given font at location x / y.\n */\n fromText(text: string, x: number, y: number, font: SkFont): void;\n\n /**\n * Interpolates between Path with point array of equal size.\n * Copy verb array and weights to result, and set result path to a weighted\n * average of this path array and ending path.\n\n * weight is most useful when between zero (ending path) and\n one (this path); will work with values outside of this\n range.\n\n * interpolate() returns undefined if path is not\n * the same size as ending path. Call isInterpolatable() to check Path\n * compatibility prior to calling interpolate().\n\n * @param ending path to interpolate with\n * @param weight contribution of this path, and\n * one minus contribution of ending path\n * @return Path replaced by interpolated averages or undefined if \n * not interpolatable\n * */\n interpolate(end: SkPath, weight: number): SkPath;\n\n /** Returns true if Path contain equal verbs and equal weights.\n * @param compare path to compare\n * @return true if Path can be interpolated equivalent\n *\n * */\n isInterpolatable(compare: SkPath): boolean;\n\n /**\n * Serializes the contents of this path as a series of commands.\n */\n toCmds(): PathCommand[];\n}\n"]}
@@ -1 +1 @@
1
- {"version":3,"sources":["Shader.ts"],"names":["isShader","obj","__typename__"],"mappings":"AAEA,OAAO,MAAMA,QAAQ,GAAIC,GAAD,IACtBA,GAAG,KAAK,IAAR,IAAgBA,GAAG,CAACC,YAAJ,KAAqB,QADhC","sourcesContent":["import type { SkJSIInstance } from \"../JsiInstance\";\n\nexport const isShader = (obj: SkJSIInstance<string> | null): obj is IShader =>\n obj !== null && obj.__typename__ === \"Shader\";\n\nexport type IShader = SkJSIInstance<\"Shader\">;\n"]}
1
+ {"version":3,"sources":["Shader.ts"],"names":["isShader","obj","__typename__"],"mappings":"AAEA,OAAO,MAAMA,QAAQ,GAAIC,GAAD,IACtBA,GAAG,KAAK,IAAR,IAAgBA,GAAG,CAACC,YAAJ,KAAqB,QADhC","sourcesContent":["import type { SkJSIInstance } from \"../JsiInstance\";\n\nexport const isShader = (obj: SkJSIInstance<string> | null): obj is SkShader =>\n obj !== null && obj.__typename__ === \"Shader\";\n\nexport type SkShader = SkJSIInstance<\"Shader\">;\n"]}
@@ -1,7 +1,48 @@
1
+ import { Platform, processColor } from "react-native";
1
2
  /*global SkiaApi*/
2
- import { processColor } from "./Color";
3
+
3
4
  import "./NativeSetup";
4
5
 
6
+ /*
7
+ * Parse CSS colors
8
+ */
9
+ const SkiaColor = cl => {
10
+ if (typeof cl === "number") {
11
+ return cl;
12
+ }
13
+
14
+ const color = Skia.parseColorString(cl);
15
+
16
+ if (color !== undefined) {
17
+ return color;
18
+ } else {
19
+ // If the color is not recognized, we fallback to React Native
20
+ let rnColor = processColor(cl); // 1. Neither Skia or RN could parse the color
21
+
22
+ if (typeof rnColor !== "number") {
23
+ console.warn("Skia couldn't parse the following color " + cl);
24
+ return BLACK; // 2. The color is recognized by RN but not by Skia
25
+ } else {
26
+ console.warn("Skia couldn't parse the following color " + cl + ". The color parsing was delegated to React Native. Please file on issue with that color."); // On android we need to move the alpha byte to the start of the structure
27
+
28
+ if (Platform.OS === "android") {
29
+ rnColor = rnColor >>> 0;
30
+ const a = rnColor >> 24 & 0xff;
31
+ const r = rnColor >> 16 & 0xff;
32
+ const g = rnColor >> 8 & 0xff;
33
+ const b = rnColor & 0xff;
34
+ rnColor = (a << 24 | r << 16 | g << 8 | b) >>> 0;
35
+ }
36
+
37
+ return rnColor;
38
+ }
39
+ }
40
+ };
41
+ /**
42
+ * Declares the interface for the native Skia API
43
+ */
44
+
45
+
5
46
  /**
6
47
  * Declares the implemented API with overrides.
7
48
  */
@@ -30,7 +71,8 @@ export const Skia = {
30
71
  ColorFilter: SkiaApi.ColorFilter,
31
72
  ContourMeasureIter: SkiaApi.ContourMeasureIter,
32
73
  // Here are constructors for data types which are represented as typed arrays in CanvasKit
33
- Color: color => processColor(color, 1),
74
+ Color: SkiaColor,
75
+ parseColorString: SkiaApi.parseColorString,
34
76
  RSXform: SkiaApi.RSXform,
35
77
  // For the following methods the factory symmetry is broken to be comptatible with CanvasKit
36
78
  MakeSurface: SkiaApi.Surface.Make,
@@ -38,4 +80,5 @@ export const Skia = {
38
80
  MakeImage: SkiaApi.Image.MakeImage,
39
81
  MakeVertices: SkiaApi.MakeVertices
40
82
  };
83
+ const BLACK = Skia.parseColorString("black");
41
84
  //# sourceMappingURL=Skia.js.map