@react-native-ohos/react-native-svg 15.12.1-rc.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (280) hide show
  1. package/LICENSE +21 -0
  2. package/README.OpenSource +11 -0
  3. package/README.md +13 -0
  4. package/css/package.json +6 -0
  5. package/harmony/svg/BuildProfile.ets +17 -0
  6. package/harmony/svg/build-profile.json5 +9 -0
  7. package/harmony/svg/hvigorfile.ts +2 -0
  8. package/harmony/svg/index.ets +7 -0
  9. package/harmony/svg/oh-package.json5 +13 -0
  10. package/harmony/svg/src/main/cpp/Attribute.h +52 -0
  11. package/harmony/svg/src/main/cpp/CMakeLists.txt +32 -0
  12. package/harmony/svg/src/main/cpp/FallbackProps.h +0 -0
  13. package/harmony/svg/src/main/cpp/FontHolderBase.cpp +22 -0
  14. package/harmony/svg/src/main/cpp/FontHolderBase.h +54 -0
  15. package/harmony/svg/src/main/cpp/SVGPackage.cpp +135 -0
  16. package/harmony/svg/src/main/cpp/SVGPackage.h +153 -0
  17. package/harmony/svg/src/main/cpp/SvgArkUINode.cpp +75 -0
  18. package/harmony/svg/src/main/cpp/SvgArkUINode.h +45 -0
  19. package/harmony/svg/src/main/cpp/SvgBaseAttribute.h +83 -0
  20. package/harmony/svg/src/main/cpp/SvgCircle.cpp +29 -0
  21. package/harmony/svg/src/main/cpp/SvgCircle.h +29 -0
  22. package/harmony/svg/src/main/cpp/SvgClipPath.h +22 -0
  23. package/harmony/svg/src/main/cpp/SvgContext.cpp +56 -0
  24. package/harmony/svg/src/main/cpp/SvgContext.h +71 -0
  25. package/harmony/svg/src/main/cpp/SvgDefs.h +46 -0
  26. package/harmony/svg/src/main/cpp/SvgEllipse.cpp +32 -0
  27. package/harmony/svg/src/main/cpp/SvgEllipse.h +34 -0
  28. package/harmony/svg/src/main/cpp/SvgFilter.cpp +505 -0
  29. package/harmony/svg/src/main/cpp/SvgFilter.h +112 -0
  30. package/harmony/svg/src/main/cpp/SvgGradient.cpp +116 -0
  31. package/harmony/svg/src/main/cpp/SvgGradient.h +49 -0
  32. package/harmony/svg/src/main/cpp/SvgGraphic.cpp +553 -0
  33. package/harmony/svg/src/main/cpp/SvgGraphic.h +77 -0
  34. package/harmony/svg/src/main/cpp/SvgGroup.cpp +86 -0
  35. package/harmony/svg/src/main/cpp/SvgGroup.h +41 -0
  36. package/harmony/svg/src/main/cpp/SvgHost.cpp +27 -0
  37. package/harmony/svg/src/main/cpp/SvgHost.h +38 -0
  38. package/harmony/svg/src/main/cpp/SvgImage.cpp +168 -0
  39. package/harmony/svg/src/main/cpp/SvgImage.h +52 -0
  40. package/harmony/svg/src/main/cpp/SvgLine.cpp +28 -0
  41. package/harmony/svg/src/main/cpp/SvgLine.h +32 -0
  42. package/harmony/svg/src/main/cpp/SvgMarker.cpp +61 -0
  43. package/harmony/svg/src/main/cpp/SvgMarker.h +86 -0
  44. package/harmony/svg/src/main/cpp/SvgMask.cpp +72 -0
  45. package/harmony/svg/src/main/cpp/SvgMask.h +68 -0
  46. package/harmony/svg/src/main/cpp/SvgNode.cpp +289 -0
  47. package/harmony/svg/src/main/cpp/SvgNode.h +347 -0
  48. package/harmony/svg/src/main/cpp/SvgPath.cpp +42 -0
  49. package/harmony/svg/src/main/cpp/SvgPath.h +29 -0
  50. package/harmony/svg/src/main/cpp/SvgPattern.cpp +77 -0
  51. package/harmony/svg/src/main/cpp/SvgPattern.h +64 -0
  52. package/harmony/svg/src/main/cpp/SvgQuote.h +87 -0
  53. package/harmony/svg/src/main/cpp/SvgRect.cpp +58 -0
  54. package/harmony/svg/src/main/cpp/SvgRect.h +33 -0
  55. package/harmony/svg/src/main/cpp/SvgSvg.cpp +83 -0
  56. package/harmony/svg/src/main/cpp/SvgSvg.h +52 -0
  57. package/harmony/svg/src/main/cpp/SvgSymbol.cpp +25 -0
  58. package/harmony/svg/src/main/cpp/SvgSymbol.h +37 -0
  59. package/harmony/svg/src/main/cpp/SvgTSpan.cpp +501 -0
  60. package/harmony/svg/src/main/cpp/SvgTSpan.h +101 -0
  61. package/harmony/svg/src/main/cpp/SvgText.cpp +48 -0
  62. package/harmony/svg/src/main/cpp/SvgText.h +29 -0
  63. package/harmony/svg/src/main/cpp/SvgTextPath.cpp +35 -0
  64. package/harmony/svg/src/main/cpp/SvgTextPath.h +51 -0
  65. package/harmony/svg/src/main/cpp/SvgUse.cpp +65 -0
  66. package/harmony/svg/src/main/cpp/SvgUse.h +46 -0
  67. package/harmony/svg/src/main/cpp/SvgViewManager.cpp +36 -0
  68. package/harmony/svg/src/main/cpp/SvgViewManager.h +37 -0
  69. package/harmony/svg/src/main/cpp/TextBase.cpp +20 -0
  70. package/harmony/svg/src/main/cpp/TextBase.h +114 -0
  71. package/harmony/svg/src/main/cpp/componentInstances/RNSVGBaseComponentInstance.h +212 -0
  72. package/harmony/svg/src/main/cpp/componentInstances/RNSVGCircleComponentInstance.cpp +31 -0
  73. package/harmony/svg/src/main/cpp/componentInstances/RNSVGCircleComponentInstance.h +27 -0
  74. package/harmony/svg/src/main/cpp/componentInstances/RNSVGClipPathComponentInstance.cpp +23 -0
  75. package/harmony/svg/src/main/cpp/componentInstances/RNSVGClipPathComponentInstance.h +27 -0
  76. package/harmony/svg/src/main/cpp/componentInstances/RNSVGDefsComponentInstance.cpp +23 -0
  77. package/harmony/svg/src/main/cpp/componentInstances/RNSVGDefsComponentInstance.h +28 -0
  78. package/harmony/svg/src/main/cpp/componentInstances/RNSVGEllipseComponentInstance.cpp +27 -0
  79. package/harmony/svg/src/main/cpp/componentInstances/RNSVGEllipseComponentInstance.h +27 -0
  80. package/harmony/svg/src/main/cpp/componentInstances/RNSVGFeBlendComponentInstance.cpp +40 -0
  81. package/harmony/svg/src/main/cpp/componentInstances/RNSVGFeBlendComponentInstance.h +48 -0
  82. package/harmony/svg/src/main/cpp/componentInstances/RNSVGFeColorMatrixComponentInstance.cpp +33 -0
  83. package/harmony/svg/src/main/cpp/componentInstances/RNSVGFeColorMatrixComponentInstance.h +48 -0
  84. package/harmony/svg/src/main/cpp/componentInstances/RNSVGFeCompositeComponentInstance.cpp +39 -0
  85. package/harmony/svg/src/main/cpp/componentInstances/RNSVGFeCompositeComponentInstance.h +55 -0
  86. package/harmony/svg/src/main/cpp/componentInstances/RNSVGFeFloodComponentInstance.cpp +33 -0
  87. package/harmony/svg/src/main/cpp/componentInstances/RNSVGFeFloodComponentInstance.h +49 -0
  88. package/harmony/svg/src/main/cpp/componentInstances/RNSVGFeGaussianBlurComponentInstance.cpp +34 -0
  89. package/harmony/svg/src/main/cpp/componentInstances/RNSVGFeGaussianBlurComponentInstance.h +48 -0
  90. package/harmony/svg/src/main/cpp/componentInstances/RNSVGFeOffsetComponentInstance.cpp +35 -0
  91. package/harmony/svg/src/main/cpp/componentInstances/RNSVGFeOffsetComponentInstance.h +46 -0
  92. package/harmony/svg/src/main/cpp/componentInstances/RNSVGFilterComponentInstance.cpp +199 -0
  93. package/harmony/svg/src/main/cpp/componentInstances/RNSVGFilterComponentInstance.h +48 -0
  94. package/harmony/svg/src/main/cpp/componentInstances/RNSVGGroupComponentInstance.cpp +32 -0
  95. package/harmony/svg/src/main/cpp/componentInstances/RNSVGGroupComponentInstance.h +27 -0
  96. package/harmony/svg/src/main/cpp/componentInstances/RNSVGImageComponentInstance.cpp +100 -0
  97. package/harmony/svg/src/main/cpp/componentInstances/RNSVGImageComponentInstance.h +43 -0
  98. package/harmony/svg/src/main/cpp/componentInstances/RNSVGLineComponentInstance.cpp +27 -0
  99. package/harmony/svg/src/main/cpp/componentInstances/RNSVGLineComponentInstance.h +27 -0
  100. package/harmony/svg/src/main/cpp/componentInstances/RNSVGLinearGradientComponentInstance.cpp +30 -0
  101. package/harmony/svg/src/main/cpp/componentInstances/RNSVGLinearGradientComponentInstance.h +28 -0
  102. package/harmony/svg/src/main/cpp/componentInstances/RNSVGMarkerComponentInstance.cpp +35 -0
  103. package/harmony/svg/src/main/cpp/componentInstances/RNSVGMarkerComponentInstance.h +27 -0
  104. package/harmony/svg/src/main/cpp/componentInstances/RNSVGMaskComponentInstance.cpp +30 -0
  105. package/harmony/svg/src/main/cpp/componentInstances/RNSVGMaskComponentInstance.h +27 -0
  106. package/harmony/svg/src/main/cpp/componentInstances/RNSVGPathComponentInstance.cpp +33 -0
  107. package/harmony/svg/src/main/cpp/componentInstances/RNSVGPathComponentInstance.h +29 -0
  108. package/harmony/svg/src/main/cpp/componentInstances/RNSVGPatternComponentInstance.cpp +40 -0
  109. package/harmony/svg/src/main/cpp/componentInstances/RNSVGPatternComponentInstance.h +27 -0
  110. package/harmony/svg/src/main/cpp/componentInstances/RNSVGRadialGradientComponentInstance.cpp +32 -0
  111. package/harmony/svg/src/main/cpp/componentInstances/RNSVGRadialGradientComponentInstance.h +28 -0
  112. package/harmony/svg/src/main/cpp/componentInstances/RNSVGRectComponentInstance.cpp +36 -0
  113. package/harmony/svg/src/main/cpp/componentInstances/RNSVGRectComponentInstance.h +27 -0
  114. package/harmony/svg/src/main/cpp/componentInstances/RNSVGSvgViewComponentInstance.cpp +86 -0
  115. package/harmony/svg/src/main/cpp/componentInstances/RNSVGSvgViewComponentInstance.h +47 -0
  116. package/harmony/svg/src/main/cpp/componentInstances/RNSVGSymbolComponentInstance.cpp +30 -0
  117. package/harmony/svg/src/main/cpp/componentInstances/RNSVGSymbolComponentInstance.h +27 -0
  118. package/harmony/svg/src/main/cpp/componentInstances/RNSVGTSpanComponentInstance.cpp +27 -0
  119. package/harmony/svg/src/main/cpp/componentInstances/RNSVGTSpanComponentInstance.h +27 -0
  120. package/harmony/svg/src/main/cpp/componentInstances/RNSVGTextComponentInstance.cpp +25 -0
  121. package/harmony/svg/src/main/cpp/componentInstances/RNSVGTextComponentInstance.h +27 -0
  122. package/harmony/svg/src/main/cpp/componentInstances/RNSVGTextPathComponentInstance.cpp +32 -0
  123. package/harmony/svg/src/main/cpp/componentInstances/RNSVGTextPathComponentInstance.h +27 -0
  124. package/harmony/svg/src/main/cpp/componentInstances/RNSVGUseComponentInstance.cpp +32 -0
  125. package/harmony/svg/src/main/cpp/componentInstances/RNSVGUseComponentInstance.h +32 -0
  126. package/harmony/svg/src/main/cpp/downloadUtils/HttpTaskProcessor.cpp +207 -0
  127. package/harmony/svg/src/main/cpp/downloadUtils/HttpTaskProcessor.h +88 -0
  128. package/harmony/svg/src/main/cpp/downloadUtils/ImageSourceResolver.cpp +106 -0
  129. package/harmony/svg/src/main/cpp/downloadUtils/ImageSourceResolver.h +97 -0
  130. package/harmony/svg/src/main/cpp/downloadUtils/LRUCache.h +98 -0
  131. package/harmony/svg/src/main/cpp/drawing/Brush.cpp +50 -0
  132. package/harmony/svg/src/main/cpp/drawing/Brush.h +52 -0
  133. package/harmony/svg/src/main/cpp/drawing/GlyPathBag.cpp +20 -0
  134. package/harmony/svg/src/main/cpp/drawing/GlyPathBag.h +31 -0
  135. package/harmony/svg/src/main/cpp/drawing/Matrix.cpp +100 -0
  136. package/harmony/svg/src/main/cpp/drawing/Matrix.h +68 -0
  137. package/harmony/svg/src/main/cpp/drawing/Path.cpp +173 -0
  138. package/harmony/svg/src/main/cpp/drawing/Path.h +127 -0
  139. package/harmony/svg/src/main/cpp/drawing/Pen.cpp +57 -0
  140. package/harmony/svg/src/main/cpp/drawing/Pen.h +59 -0
  141. package/harmony/svg/src/main/cpp/drawing/Rect.cpp +47 -0
  142. package/harmony/svg/src/main/cpp/drawing/Rect.h +56 -0
  143. package/harmony/svg/src/main/cpp/drawing/RoundRect.cpp +24 -0
  144. package/harmony/svg/src/main/cpp/drawing/RoundRect.h +39 -0
  145. package/harmony/svg/src/main/cpp/drawing/ShaderEffect.cpp +37 -0
  146. package/harmony/svg/src/main/cpp/drawing/ShaderEffect.h +51 -0
  147. package/harmony/svg/src/main/cpp/drawing/TextStyle.cpp +49 -0
  148. package/harmony/svg/src/main/cpp/drawing/TextStyle.h +41 -0
  149. package/harmony/svg/src/main/cpp/drawing/Typography.cpp +9 -0
  150. package/harmony/svg/src/main/cpp/drawing/Typography.h +25 -0
  151. package/harmony/svg/src/main/cpp/drawing/TypographyStyle.cpp +31 -0
  152. package/harmony/svg/src/main/cpp/drawing/TypographyStyle.h +41 -0
  153. package/harmony/svg/src/main/cpp/generated/RNOH/generated/components/RNSVGCircleJSIBinder.h +54 -0
  154. package/harmony/svg/src/main/cpp/generated/RNOH/generated/components/RNSVGClipPathJSIBinder.h +54 -0
  155. package/harmony/svg/src/main/cpp/generated/RNOH/generated/components/RNSVGDefsJSIBinder.h +38 -0
  156. package/harmony/svg/src/main/cpp/generated/RNOH/generated/components/RNSVGEllipseJSIBinder.h +55 -0
  157. package/harmony/svg/src/main/cpp/generated/RNOH/generated/components/RNSVGFeBlendJSIBinder.h +26 -0
  158. package/harmony/svg/src/main/cpp/generated/RNOH/generated/components/RNSVGFeColorMatrixJSIBinder.h +26 -0
  159. package/harmony/svg/src/main/cpp/generated/RNOH/generated/components/RNSVGFeCompositeJSIBinder.h +30 -0
  160. package/harmony/svg/src/main/cpp/generated/RNOH/generated/components/RNSVGFeFloodJSIBinder.h +26 -0
  161. package/harmony/svg/src/main/cpp/generated/RNOH/generated/components/RNSVGFeGaussianBlurJSIBinder.h +27 -0
  162. package/harmony/svg/src/main/cpp/generated/RNOH/generated/components/RNSVGFeOffsetJSIBinder.h +26 -0
  163. package/harmony/svg/src/main/cpp/generated/RNOH/generated/components/RNSVGFilterJSIBinder.h +44 -0
  164. package/harmony/svg/src/main/cpp/generated/RNOH/generated/components/RNSVGForeignObjectJSIBinder.h +57 -0
  165. package/harmony/svg/src/main/cpp/generated/RNOH/generated/components/RNSVGGroupJSIBinder.h +54 -0
  166. package/harmony/svg/src/main/cpp/generated/RNOH/generated/components/RNSVGImageJSIBinder.h +58 -0
  167. package/harmony/svg/src/main/cpp/generated/RNOH/generated/components/RNSVGLineJSIBinder.h +55 -0
  168. package/harmony/svg/src/main/cpp/generated/RNOH/generated/components/RNSVGLinearGradientJSIBinder.h +45 -0
  169. package/harmony/svg/src/main/cpp/generated/RNOH/generated/components/RNSVGMarkerJSIBinder.h +66 -0
  170. package/harmony/svg/src/main/cpp/generated/RNOH/generated/components/RNSVGMaskJSIBinder.h +60 -0
  171. package/harmony/svg/src/main/cpp/generated/RNOH/generated/components/RNSVGPathJSIBinder.h +52 -0
  172. package/harmony/svg/src/main/cpp/generated/RNOH/generated/components/RNSVGPatternJSIBinder.h +67 -0
  173. package/harmony/svg/src/main/cpp/generated/RNOH/generated/components/RNSVGRadialGradientJSIBinder.h +47 -0
  174. package/harmony/svg/src/main/cpp/generated/RNOH/generated/components/RNSVGRectJSIBinder.h +57 -0
  175. package/harmony/svg/src/main/cpp/generated/RNOH/generated/components/RNSVGSvgViewAndroidJSIBinder.h +67 -0
  176. package/harmony/svg/src/main/cpp/generated/RNOH/generated/components/RNSVGSvgViewJSIBinder.h +36 -0
  177. package/harmony/svg/src/main/cpp/generated/RNOH/generated/components/RNSVGSymbolJSIBinder.h +60 -0
  178. package/harmony/svg/src/main/cpp/generated/RNOH/generated/components/RNSVGTSpanJSIBinder.h +66 -0
  179. package/harmony/svg/src/main/cpp/generated/RNOH/generated/components/RNSVGTextJSIBinder.h +65 -0
  180. package/harmony/svg/src/main/cpp/generated/RNOH/generated/components/RNSVGTextPathJSIBinder.h +71 -0
  181. package/harmony/svg/src/main/cpp/generated/RNOH/generated/components/RNSVGUseJSIBinder.h +56 -0
  182. package/harmony/svg/src/main/cpp/generated/react/renderer/components/react_native_svg/ComponentDescriptors.h +48 -0
  183. package/harmony/svg/src/main/cpp/generated/react/renderer/components/react_native_svg/EventEmitters.cpp +20 -0
  184. package/harmony/svg/src/main/cpp/generated/react/renderer/components/react_native_svg/EventEmitters.h +253 -0
  185. package/harmony/svg/src/main/cpp/generated/react/renderer/components/react_native_svg/Props.cpp +977 -0
  186. package/harmony/svg/src/main/cpp/generated/react/renderer/components/react_native_svg/Props.h +1280 -0
  187. package/harmony/svg/src/main/cpp/generated/react/renderer/components/react_native_svg/ShadowNodes.cpp +45 -0
  188. package/harmony/svg/src/main/cpp/generated/react/renderer/components/react_native_svg/ShadowNodes.h +331 -0
  189. package/harmony/svg/src/main/cpp/generated/react/renderer/components/react_native_svg/States.cpp +18 -0
  190. package/harmony/svg/src/main/cpp/generated/react/renderer/components/react_native_svg/States.h +441 -0
  191. package/harmony/svg/src/main/cpp/properties/Color.cpp +458 -0
  192. package/harmony/svg/src/main/cpp/properties/Color.h +144 -0
  193. package/harmony/svg/src/main/cpp/properties/Decoration.cpp +41 -0
  194. package/harmony/svg/src/main/cpp/properties/Decoration.h +483 -0
  195. package/harmony/svg/src/main/cpp/properties/Dimension.cpp +64 -0
  196. package/harmony/svg/src/main/cpp/properties/Dimension.h +243 -0
  197. package/harmony/svg/src/main/cpp/properties/Font.cpp +166 -0
  198. package/harmony/svg/src/main/cpp/properties/Font.h +163 -0
  199. package/harmony/svg/src/main/cpp/properties/Offset.h +119 -0
  200. package/harmony/svg/src/main/cpp/properties/PaintState.h +240 -0
  201. package/harmony/svg/src/main/cpp/properties/Rect.h +423 -0
  202. package/harmony/svg/src/main/cpp/properties/Size.h +246 -0
  203. package/harmony/svg/src/main/cpp/properties/SvgPaintState.h +452 -0
  204. package/harmony/svg/src/main/cpp/properties/TextProperties.cpp +91 -0
  205. package/harmony/svg/src/main/cpp/properties/TextProperties.h +56 -0
  206. package/harmony/svg/src/main/cpp/properties/ViewBox.h +108 -0
  207. package/harmony/svg/src/main/cpp/svgImage/RNSVGImageComponentDescriptor.h +41 -0
  208. package/harmony/svg/src/main/cpp/svgImage/RNSVGImageShadowNode.cpp +62 -0
  209. package/harmony/svg/src/main/cpp/svgImage/RNSVGImageShadowNode.h +63 -0
  210. package/harmony/svg/src/main/cpp/svgImage/RNSVGImageState.cpp +17 -0
  211. package/harmony/svg/src/main/cpp/svgImage/RNSVGImageState.h +58 -0
  212. package/harmony/svg/src/main/cpp/turboModules/RNSVGImageModule.cpp +54 -0
  213. package/harmony/svg/src/main/cpp/turboModules/RNSVGImageModule.h +32 -0
  214. package/harmony/svg/src/main/cpp/turboModules/RNSVGRenderableModule.cpp +101 -0
  215. package/harmony/svg/src/main/cpp/turboModules/RNSVGRenderableModule.h +32 -0
  216. package/harmony/svg/src/main/cpp/turboModules/RNSVGSvgViewModule.cpp +71 -0
  217. package/harmony/svg/src/main/cpp/turboModules/RNSVGSvgViewModule.h +32 -0
  218. package/harmony/svg/src/main/cpp/utils/DynamicUtils.h +55 -0
  219. package/harmony/svg/src/main/cpp/utils/FilterManager.h +190 -0
  220. package/harmony/svg/src/main/cpp/utils/GlyphContext.cpp +221 -0
  221. package/harmony/svg/src/main/cpp/utils/GlyphContext.h +106 -0
  222. package/harmony/svg/src/main/cpp/utils/LinearMap.h +69 -0
  223. package/harmony/svg/src/main/cpp/utils/PathParserUtils.cpp +591 -0
  224. package/harmony/svg/src/main/cpp/utils/PathParserUtils.h +93 -0
  225. package/harmony/svg/src/main/cpp/utils/StringUtils.cpp +134 -0
  226. package/harmony/svg/src/main/cpp/utils/StringUtils.h +644 -0
  227. package/harmony/svg/src/main/cpp/utils/SvgAttributesParser.cpp +239 -0
  228. package/harmony/svg/src/main/cpp/utils/SvgAttributesParser.h +277 -0
  229. package/harmony/svg/src/main/cpp/utils/SvgMarkerPositionUtils.h +200 -0
  230. package/harmony/svg/src/main/cpp/utils/SvgUtils.h +176 -0
  231. package/harmony/svg/src/main/cpp/utils/TextPathHelper.cpp +94 -0
  232. package/harmony/svg/src/main/cpp/utils/TextPathHelper.h +61 -0
  233. package/harmony/svg/src/main/ets/RNSVGImageModule.ts +21 -0
  234. package/harmony/svg/src/main/ets/RNSVGRenderableModule.ts +16 -0
  235. package/harmony/svg/src/main/ets/RNSVGSvgViewModule.ts +18 -0
  236. package/harmony/svg/src/main/ets/SvgPackage.ts +58 -0
  237. package/harmony/svg/src/main/module.json5 +7 -0
  238. package/harmony/svg/src/main/resources/base/element/string.json +8 -0
  239. package/harmony/svg/src/main/resources/en_US/element/string.json +8 -0
  240. package/harmony/svg/src/main/resources/zh_CN/element/string.json +8 -0
  241. package/harmony/svg/ts.ts +8 -0
  242. package/harmony/svg.har +0 -0
  243. package/lib/commonjs/css/index.js +55 -0
  244. package/lib/commonjs/css/index.js.map +1 -0
  245. package/lib/commonjs/index.js +26 -0
  246. package/lib/commonjs/index.js.map +1 -0
  247. package/lib/module/css/index.js +4 -0
  248. package/lib/module/css/index.js.map +1 -0
  249. package/lib/module/index.js +3 -0
  250. package/lib/module/index.js.map +1 -0
  251. package/lib/typescript/babel.config.d.ts +8 -0
  252. package/lib/typescript/babel.config.d.ts.map +1 -0
  253. package/lib/typescript/example/babel.config.d.ts +3 -0
  254. package/lib/typescript/example/babel.config.d.ts.map +1 -0
  255. package/lib/typescript/example/contexts.d.ts +3 -0
  256. package/lib/typescript/example/contexts.d.ts.map +1 -0
  257. package/lib/typescript/example/harmony/entry/hvigorfile.d.ts +2 -0
  258. package/lib/typescript/example/harmony/entry/hvigorfile.d.ts.map +1 -0
  259. package/lib/typescript/example/harmony/hvigorfile.d.ts +2 -0
  260. package/lib/typescript/example/harmony/hvigorfile.d.ts.map +1 -0
  261. package/lib/typescript/example/index.d.ts +2 -0
  262. package/lib/typescript/example/index.d.ts.map +1 -0
  263. package/lib/typescript/example/jest.config.d.ts +3 -0
  264. package/lib/typescript/example/jest.config.d.ts.map +1 -0
  265. package/lib/typescript/example/metro.config.d.ts +3 -0
  266. package/lib/typescript/example/metro.config.d.ts.map +1 -0
  267. package/lib/typescript/example/react-native.config.d.ts +3 -0
  268. package/lib/typescript/example/react-native.config.d.ts.map +1 -0
  269. package/lib/typescript/example/scripts/create-build-profile.d.ts +2 -0
  270. package/lib/typescript/example/scripts/create-build-profile.d.ts.map +1 -0
  271. package/lib/typescript/example/src/index.d.ts +3 -0
  272. package/lib/typescript/example/src/index.d.ts.map +1 -0
  273. package/lib/typescript/src/css/index.d.ts +4 -0
  274. package/lib/typescript/src/css/index.d.ts.map +1 -0
  275. package/lib/typescript/src/index.d.ts +3 -0
  276. package/lib/typescript/src/index.d.ts.map +1 -0
  277. package/package.json +54 -0
  278. package/src/css/index.tsx +20 -0
  279. package/src/index.tsx +3 -0
  280. package/tsconfig.json +12 -0
@@ -0,0 +1,347 @@
1
+ /*
2
+ * Copyright (c) 2024 Huawei Device Co., Ltd. All rights reserved
3
+ * Use of this source code is governed by a MIT license that can be
4
+ * found in the LICENSE file.
5
+ *
6
+ * This file incorporates from the OpenHarmony project, licensed under
7
+ * the Apache License, Version 2.0. Specifically:
8
+ * - [OpenHarmony/arkui_ace_engine] (https://gitee.com/openharmony/arkui_ace_engine)
9
+ *
10
+ * Licensed under the Apache License, Version 2.0 (the "License"); you may not
11
+ * use this file except in compliance with the License. You may obtain a copy
12
+ * of the License at:
13
+ * http://www.apache.org/licenses/LICENSE-2.0
14
+ *
15
+ * Unless required by applicable law or agreed to in writing, software
16
+ * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
17
+ * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
18
+ * License for the specific language governing permissions and limitations
19
+ * under the License.
20
+ */
21
+
22
+ // from ArkUI "frameworks/core/components_ng/svg/parse/svg_node.h"
23
+ #pragma once
24
+
25
+ #include <memory>
26
+ #include <vector>
27
+ #include <unordered_set>
28
+ #include <type_traits>
29
+ #include "SvgBaseAttribute.h"
30
+ #include "SvgContext.h"
31
+ #include "properties/Decoration.h"
32
+ #include "properties/Dimension.h"
33
+ #include "properties/Size.h"
34
+ #include <react/renderer/components/react_native_svg/Props.h>
35
+ #include "drawing/Path.h"
36
+ #include "utils/StringUtils.h"
37
+ #include "utils/SvgAttributesParser.h"
38
+ #include <glog/logging.h>
39
+ #include <native_drawing/drawing_canvas.h>
40
+ #include <native_drawing/drawing_rect.h>
41
+ #include "utils/DynamicUtils.h"
42
+
43
+ namespace rnoh {
44
+ namespace svg {
45
+
46
+ constexpr int INHERIT_TYPE = 2;
47
+
48
+ class SvgNode : public std::enable_shared_from_this<SvgNode> {
49
+ public:
50
+ SvgNode() = default;
51
+ virtual ~SvgNode() = default;
52
+
53
+ std::shared_ptr<SvgContext> GetContext() { return context_; }
54
+ void SetContext(std::shared_ptr<SvgContext> context) { context_ = context; }
55
+
56
+ void ContextTraversal();
57
+ void InitStyle(const SvgBaseAttribute &attr);
58
+
59
+ virtual void Draw(OH_Drawing_Canvas *canvas);
60
+
61
+ virtual drawing::Path AsPath() {
62
+ DLOG(INFO) << "[SVGNode] AsPath";
63
+ return drawing::Path();
64
+ };
65
+
66
+ SvgBaseAttribute GetBaseAttributes() const { return attributes_; }
67
+
68
+ void SetBaseAttributes(const SvgBaseAttribute &attr) { attributes_ = attr; }
69
+
70
+ virtual void AppendChild(const std::shared_ptr<SvgNode> &child) { children_.emplace_back(child); }
71
+
72
+ virtual void removeChild(const std::shared_ptr<SvgNode> &child) {
73
+ auto it = std::find(children_.begin(), children_.end(), child);
74
+ if (it != children_.end()) {
75
+ children_.erase(it);
76
+ }
77
+ }
78
+
79
+ template <typename ConcreteProps> void UpdateHrefRenderProps(const std::shared_ptr<ConcreteProps> &props, bool inherit = false) {
80
+ if (!props) {
81
+ return;
82
+ }
83
+
84
+ if (inherit) {
85
+ attributes_.hasInheritedFilter = true;
86
+ }
87
+ // Check which properties are available and update them
88
+ std::unordered_set<std::string> propSet;
89
+ if constexpr (requires { props->propList; }) {
90
+ propSet.insert(props->propList.begin(), props->propList.end());
91
+ }
92
+
93
+ // Always set name and display if available
94
+ if constexpr (requires { props->name; }) {
95
+ attributes_.id = props->name;
96
+ }
97
+ if constexpr (requires { props->display; }) {
98
+ display_ = props->display != "none";
99
+ }
100
+
101
+ if (hrefRender_) {
102
+ // Only access properties that exist in this Props type
103
+ if constexpr (requires { props->matrix; }) {
104
+ attributes_.transform = props->matrix;
105
+ }
106
+ if constexpr (requires { props->mask; }) {
107
+ attributes_.maskId = props->mask;
108
+ }
109
+ if constexpr (requires { props->filter; } &&
110
+ std::is_same_v<std::decay_t<decltype(props->filter)>, std::string>) {
111
+ attributes_.filterId = props->filter;
112
+ attributes_.hasInheritedFilter = inherit;
113
+ }
114
+ if constexpr (requires { props->opacity; }) {
115
+ attributes_.selfOpacity = props->opacity;
116
+ }
117
+ if constexpr (requires { props->markerStart; }) {
118
+ attributes_.markerStart = props->markerStart;
119
+ }
120
+ if constexpr (requires { props->markerMid; }) {
121
+ attributes_.markerMid = props->markerMid;
122
+ }
123
+ if constexpr (requires { props->markerEnd; }) {
124
+ attributes_.markerEnd = props->markerEnd;
125
+ }
126
+ if constexpr (requires { props->clipPath; }) {
127
+ if (!props->clipPath.empty()) {
128
+ attributes_.clipPath = props->clipPath;
129
+ hrefClipPath_ = props->clipPath;
130
+ }
131
+ }
132
+ }
133
+ }
134
+
135
+ template <typename ConcreteProps> void UpdateCommonProps(const std::shared_ptr<ConcreteProps> &props, bool inherit = false) {
136
+ UpdateHrefRenderProps(props, inherit);
137
+ std::unordered_set<std::string> set;
138
+ if constexpr (requires { props->propList; }) {
139
+ for (const auto &prop : props->propList) {
140
+ set.insert(prop);
141
+ }
142
+ }
143
+
144
+ // Handle fill properties - support both generic and text-specific structures
145
+ if constexpr (requires { props->fill; }) {
146
+ if (!props->fill.isNull() && props->fill.count("type") > 0 && props->fill.count("payload") > 0) {
147
+ int fillType = props->fill["type"].asInt();
148
+ if (fillType == INHERIT_TYPE) {
149
+ Color color = Color(static_cast<uint32_t>(props->fill["payload"].asInt()));
150
+ color.SetUseCurrentColor(true);
151
+ attributes_.fillState.SetColor(color, true);
152
+ } else {
153
+ uint32_t colorValue = static_cast<uint32_t>(props->fill["payload"].asInt());
154
+ if (facebook::react::isColorMeaningful(facebook::react::SharedColor(colorValue))) {
155
+ attributes_.fillState.SetColor(Color(colorValue), set.count("fill"));
156
+ } else {
157
+ attributes_.fillState.SetColor(Color::TRANSPARENT, set.count("fill"));
158
+ }
159
+ }
160
+ } else if (!props->fill.isNull() && props->fill.count("payload") > 0) {
161
+ uint32_t colorValue = static_cast<uint32_t>(props->fill["payload"].asInt());
162
+ if (facebook::react::isColorMeaningful(facebook::react::SharedColor(colorValue))) {
163
+ attributes_.fillState.SetColor(Color(colorValue), set.count("fill"));
164
+ } else {
165
+ attributes_.fillState.SetColor(Color::TRANSPARENT, set.count("fill"));
166
+ }
167
+ } else {
168
+ attributes_.fillState.SetColor(Color::TRANSPARENT, set.count("fill"));
169
+ }
170
+ if (!props->fill.isNull() && props->fill.count("brushRef") > 0) {
171
+ attributes_.fillState.SetHref(props->fill["brushRef"].asString());
172
+ }
173
+ }
174
+
175
+ // Handle stroke properties - support both generic and text-specific structures
176
+ if constexpr (requires { props->stroke; }) {
177
+ if (!props->stroke.isNull() && props->stroke.count("type") > 0 && props->stroke.count("payload") > 0) {
178
+ int strokeType = props->stroke["type"].asInt();
179
+ if (strokeType == INHERIT_TYPE) {
180
+ Color color = Color(static_cast<uint32_t>(props->stroke["payload"].asInt()));
181
+ color.SetUseCurrentColor(true);
182
+ attributes_.strokeState.SetColor(color, true);
183
+ } else {
184
+ uint32_t colorValue = static_cast<uint32_t>(props->stroke["payload"].asInt());
185
+ if (facebook::react::isColorMeaningful(facebook::react::SharedColor(colorValue))) {
186
+ attributes_.strokeState.SetColor(Color(colorValue), set.count("stroke"));
187
+ } else {
188
+ attributes_.strokeState.SetColor(Color::TRANSPARENT, set.count("stroke"));
189
+ }
190
+ }
191
+ } else if (!props->stroke.isNull() && props->stroke.count("payload") > 0) {
192
+ uint32_t colorValue = static_cast<uint32_t>(props->stroke["payload"].asInt());
193
+ if (facebook::react::isColorMeaningful(facebook::react::SharedColor(colorValue))) {
194
+ attributes_.strokeState.SetColor(Color(colorValue), set.count("stroke"));
195
+ } else {
196
+ attributes_.strokeState.SetColor(Color::TRANSPARENT, set.count("stroke"));
197
+ }
198
+ } else {
199
+ attributes_.strokeState.SetColor(Color::TRANSPARENT, set.count("stroke"));
200
+ }
201
+ if (!props->stroke.isNull() && props->stroke.count("brushRef") > 0) {
202
+ attributes_.strokeState.SetHref(props->stroke["brushRef"].asString());
203
+ }
204
+ }
205
+
206
+ if constexpr (requires { props->fillOpacity; }) {
207
+ attributes_.fillState.SetOpacity(std::clamp(props->fillOpacity, 0.0, 1.0), true);
208
+ }
209
+ if constexpr (requires { props->fillRule; }) {
210
+ attributes_.fillState.SetFillRule(static_cast<FillState::FillRule>(props->fillRule), true);
211
+ }
212
+ if constexpr (requires { props->strokeWidth; }) {
213
+ bool hasStrokeWidthInPropList = set.count("strokeWidth") > 0;
214
+ if (hasStrokeWidthInPropList) {
215
+ attributes_.strokeState.SetLineWidth(StringUtils::StringToDouble(DynamicUtils::DynamicToString(props->strokeWidth)) * scale_, true);
216
+ }
217
+ }
218
+ if constexpr (requires { props->strokeDasharray; }) {
219
+ attributes_.strokeState.SetStrokeDashArray(
220
+ StringUtils::stringVectorToDoubleVector(DynamicUtils::DynamicToStringVector(props->strokeDasharray), scale_), set.count("strokeDasharray"));
221
+ }
222
+ if constexpr (requires { props->strokeDashoffset; }) {
223
+ attributes_.strokeState.SetStrokeDashOffset(props->strokeDashoffset * scale_, set.count("strokeDashoffset"));
224
+ }
225
+ if constexpr (requires { props->strokeLinecap; }) {
226
+ attributes_.strokeState.SetLineCap(SvgAttributesParser::GetLineCapStyle(std::to_string(props->strokeLinecap)), set.count("strokeLinecap"));
227
+ }
228
+ if constexpr (requires { props->strokeLinejoin; }) {
229
+ attributes_.strokeState.SetLineJoin(
230
+ SvgAttributesParser::GetLineJoinStyle(std::to_string(props->strokeLinejoin)), set.count("strokeLinejoin"));
231
+ }
232
+ if constexpr (requires { props->vectorEffect; }) {
233
+ attributes_.strokeState.SetVectorEffect(props->vectorEffect);
234
+ }
235
+ if constexpr (requires { props->strokeMiterlimit; }) {
236
+ auto limit = props->strokeMiterlimit * scale_;
237
+ if (GreatOrEqual(limit, 1.0)) {
238
+ attributes_.strokeState.SetMiterLimit(limit, set.count("strokeMiterlimit"));
239
+ }
240
+ }
241
+ if constexpr (requires { props->strokeOpacity; }) {
242
+ attributes_.strokeState.SetOpacity(std::clamp(props->strokeOpacity, 0.0, 1.0), set.count("strokeOpacity"));
243
+ }
244
+ if constexpr (requires { props->clipRule; }) {
245
+ attributes_.clipState.SetClipRule(static_cast<ClipState::ClipRule>(props->clipRule), true);
246
+ }
247
+ }
248
+
249
+ virtual Rect AsBounds();
250
+
251
+ void SetScale(const double &scale) { scale_ = scale; }
252
+
253
+ double GetScale() const { return scale_; }
254
+
255
+ void InheritAttr(const SvgBaseAttribute &parent) {
256
+ attributes_.Inherit(parent);
257
+ // svg color -> current color
258
+ if (attributes_.strokeState.GetColor().IsUseCurrentColor()) {
259
+ attributes_.strokeState.SetColor(context_->GetSvgColor(), true);
260
+ }
261
+ if (attributes_.fillState.GetColor().IsUseCurrentColor()) {
262
+ attributes_.fillState.SetColor(context_->GetSvgColor(), true);
263
+ }
264
+ }
265
+
266
+ void InheritUseAttr(const SvgBaseAttribute &parent) { attributes_.InheritFromUse(parent); }
267
+
268
+ drawing::Matrix lastCanvasMatrix_;
269
+
270
+ double relativeOnWidth(Dimension length);
271
+ double relativeOnHeight(Dimension length);
272
+ double relativeOnOther(Dimension length);
273
+
274
+ double getCanvasWidth();
275
+ double getCanvasHeight();
276
+ double getCanvasDiagonal();
277
+
278
+ protected:
279
+ // override as need by derived class
280
+ // called by function AppendChild
281
+ virtual void OnAppendChild(const std::shared_ptr<SvgNode> &child) {}
282
+ // called by function InitStyle
283
+ virtual void OnInitStyle() {}
284
+
285
+ virtual void OnDraw(OH_Drawing_Canvas *canvas) {}
286
+ virtual void OnDrawTraversed(OH_Drawing_Canvas *canvas);
287
+ void OnClipPath(OH_Drawing_Canvas *canvas);
288
+ void OnMask(OH_Drawing_Canvas *canvas);
289
+ void OnTransform(OH_Drawing_Canvas *canvas);
290
+
291
+ const Rect &GetRootViewBox() const;
292
+
293
+ void SetSmoothEdge(float edge) { attributes_.smoothEdge = edge; }
294
+ float GetSmoothEdge() const { return attributes_.smoothEdge; }
295
+
296
+ std::optional<Gradient> GetGradient(const std::string &href);
297
+
298
+ std::shared_ptr<PatternAttr> GetPatternAttr(const std::string &href);
299
+
300
+ void InitNoneFlag() {
301
+ hrefFill_ = false;
302
+ hrefRender_ = false;
303
+ passStyle_ = false;
304
+ inheritStyle_ = false;
305
+ drawTraversed_ = false;
306
+ }
307
+
308
+ SvgBaseAttribute attributes_;
309
+
310
+ std::shared_ptr<SvgContext> context_;
311
+
312
+ std::vector<std::shared_ptr<SvgNode>> children_;
313
+
314
+ std::string hrefClipPath_;
315
+ std::string imagePath_;
316
+
317
+ double scale_ = 3.25;
318
+
319
+ drawing::Matrix cTM_;
320
+
321
+ bool display_ = true;
322
+
323
+ bool hrefFill_ = true; // get fill attributes from reference
324
+ bool hrefRender_ = true; // get render attr (mask, filter, transform, opacity,
325
+ // clip path) from reference
326
+ bool passStyle_ = false; // pass style attributes to child node, TAGS
327
+ // circle/path/line/... = false
328
+ bool inheritStyle_ = true; // inherit style attributes from parent node, TAGS
329
+ // mask/defs/pattern/filter = false
330
+ bool drawTraversed_ = true; // enable OnDraw, TAGS mask/defs/pattern/filter = false
331
+
332
+ double canvasHeight_ = -1;
333
+
334
+ double canvasWidth_ = -1;
335
+
336
+ double canvasDiagonal_ = -1;
337
+
338
+ /*
339
+ N[1/Sqrt[2], 36]
340
+ The inverse of the square root of 2.
341
+ Provide enough digits for the 128-bit IEEE quad (36 significant digits).
342
+ */
343
+ const double M_SQRT1_2l = 0.707106781186547524400844362104849039;
344
+ };
345
+
346
+ } // namespace svg
347
+ } // namespace rnoh
@@ -0,0 +1,42 @@
1
+ /*
2
+ * Copyright (c) 2024 Huawei Device Co., Ltd. All rights reserved
3
+ * Use of this source code is governed by a MIT license that can be
4
+ * found in the LICENSE file.
5
+ */
6
+
7
+ #include "SvgPath.h"
8
+ #include "utils/PathParserUtils.h"
9
+ #include <native_drawing/drawing_matrix.h>
10
+ #include "utils/PathParserUtils.h"
11
+
12
+ namespace rnoh {
13
+ namespace svg {
14
+
15
+ void SvgPath::setD(const std::string &d) {
16
+ d_ = d;
17
+ PathParserUtils parser;
18
+ parser.mScale = scale_;
19
+ try {
20
+ path_ = std::move(parser.parse(d.c_str()));
21
+ } catch (const std::runtime_error &e) {
22
+ LOG(ERROR) << "[svgPath] Svg path d invalid, error message: " << e.what();
23
+ return;
24
+ }
25
+ elements_ = std::move(parser.elements);
26
+ for (PathElement &elem : elements_) {
27
+ for (Point &point : elem.points) {
28
+ point.x *= scale_;
29
+ point.y *= scale_;
30
+ }
31
+ }
32
+ }
33
+
34
+ drawing::Path SvgPath::AsPath() {
35
+ if (path_.get()) {
36
+ return path_;
37
+ }
38
+ return drawing::Path();
39
+ }
40
+
41
+ } // namespace svg
42
+ } // namespace rnoh
@@ -0,0 +1,29 @@
1
+ /*
2
+ * Copyright (c) 2024 Huawei Device Co., Ltd. All rights reserved
3
+ * Use of this source code is governed by a MIT license that can be
4
+ * found in the LICENSE file.
5
+ */
6
+
7
+ #pragma once
8
+
9
+ #include "SvgGraphic.h"
10
+
11
+ namespace rnoh {
12
+ namespace svg {
13
+
14
+ class SvgPath : public SvgGraphic {
15
+ private:
16
+ std::string d_;
17
+ drawing::Path path_{};
18
+
19
+ public:
20
+ SvgPath() = default;
21
+ ~SvgPath() override = default;
22
+
23
+ void setD(const std::string &d);
24
+
25
+ drawing::Path AsPath() override;
26
+ };
27
+
28
+ } // namespace svg
29
+ } // namespace rnoh
@@ -0,0 +1,77 @@
1
+ /*
2
+ * Copyright (c) 2024 Huawei Device Co., Ltd. All rights reserved
3
+ * Use of this source code is governed by a MIT license that can be
4
+ * found in the LICENSE file.
5
+ */
6
+
7
+ #include "SvgPattern.h"
8
+
9
+ namespace rnoh {
10
+ namespace svg {
11
+
12
+ constexpr size_t PATTERN_TRANSFORM_MATRIX_SIZE = 6;
13
+ constexpr int TRANSFORM_SCALE_X_INDEX = 0;
14
+ constexpr int TRANSFORM_SKEW_Y_INDEX = 1;
15
+ constexpr int TRANSFORM_SKEW_X_INDEX = 2;
16
+ constexpr int TRANSFORM_SCALE_Y_INDEX = 3;
17
+ constexpr int TRANSFORM_TRANSLATE_X_INDEX = 4;
18
+ constexpr int TRANSFORM_TRANSLATE_Y_INDEX = 5;
19
+
20
+ SvgPattern::SvgPattern() { DLOG(INFO) << "[SvgPattern] init"; }
21
+
22
+ void SvgPattern::OnDrawTraversedBefore(OH_Drawing_Canvas *canvas) {
23
+ DLOG(INFO) << "[pattern] OnDrawTraversedBefore";
24
+ }
25
+
26
+ void SvgPattern::OnDrawTraversedAfter(OH_Drawing_Canvas *canvas) { DLOG(INFO) << "[pattern] OnDrawTraversedAfter"; }
27
+
28
+ std::shared_ptr<PatternAttr> SvgPattern::GetPatternAttr() { return patternAttr; }
29
+
30
+ void SvgPattern::setPatternX(Dimension x) { patternAttr->setPatternX(x); }
31
+
32
+ void SvgPattern::setPatternY(Dimension y) { patternAttr->setPatternY(y); }
33
+
34
+ void SvgPattern::setHeight(Dimension height) { patternAttr->setHeight(height); }
35
+
36
+ void SvgPattern::setWidth(Dimension width) { patternAttr->setWidth(width); }
37
+
38
+ void SvgPattern::setPatternContentUnits(int patternContentUnits) {
39
+ patternAttr->setPatternContentUnits(patternContentUnits);
40
+ }
41
+
42
+ void SvgPattern::setPatternUnits(int patternUnits) { patternAttr->setPatternUnits(patternUnits); }
43
+
44
+
45
+ void SvgPattern::setViewBox(Rect viewBox) { patternAttr->setViewBox(viewBox); }
46
+
47
+ void SvgPattern::setmMinX(float mMinX) { patternAttr->setmMinX(mMinX); }
48
+
49
+ void SvgPattern::setmMinY(float mMinY) { patternAttr->setmMinY(mMinY); }
50
+
51
+ void SvgPattern::setmVbWidth(float mVbWidth) { patternAttr->setmVbWidth(mVbWidth); }
52
+
53
+ void SvgPattern::setmVbHeight(float mVbHeight) { patternAttr->setmVbHeight(mVbHeight); }
54
+
55
+ void SvgPattern::setmAlign(std::string mAlign) { patternAttr->setmAlign(mAlign); }
56
+
57
+ void SvgPattern::setmMeetOrSlice(int mMeetOrSlice) { patternAttr->setmMeetOrSlice(mMeetOrSlice); }
58
+
59
+ void SvgPattern::setPatternTransforms(std::vector<Float> patternTransforms) {
60
+ std::vector<Float> newMatrix{
61
+ 1, 0, 0, 0, 1, 0, 0, 0, 1,
62
+ };
63
+ if (patternTransforms.size() == PATTERN_TRANSFORM_MATRIX_SIZE) {
64
+ newMatrix[0] = (Float)patternTransforms[TRANSFORM_SCALE_X_INDEX];
65
+ newMatrix[1] = (Float)patternTransforms[TRANSFORM_SKEW_X_INDEX];
66
+ newMatrix[2] = (Float)patternTransforms[TRANSFORM_TRANSLATE_X_INDEX] * scale_;
67
+ newMatrix[3] = (Float)patternTransforms[TRANSFORM_SKEW_Y_INDEX];
68
+ newMatrix[4] = (Float)patternTransforms[TRANSFORM_SCALE_Y_INDEX];
69
+ newMatrix[5] = (Float)patternTransforms[TRANSFORM_TRANSLATE_Y_INDEX] * scale_;
70
+ patternAttr->setPatternTransform(std::move(newMatrix));
71
+ }
72
+ }
73
+
74
+ void SvgPattern::setImage(OH_Drawing_Image *image) { patternAttr->setImage(image); }
75
+
76
+ } // namespace svg
77
+ } // namespace rnoh
@@ -0,0 +1,64 @@
1
+ /*
2
+ * Copyright (c) 2024 Huawei Device Co., Ltd. All rights reserved
3
+ * Use of this source code is governed by a MIT license that can be
4
+ * found in the LICENSE file.
5
+ */
6
+
7
+ #pragma once
8
+
9
+ #include <string>
10
+ #include "SvgQuote.h"
11
+ #include "utils/SvgAttributesParser.h"
12
+
13
+ namespace rnoh {
14
+ namespace svg {
15
+
16
+ class SvgPattern : public SvgQuote {
17
+
18
+ public:
19
+ using Float = facebook::react::Float;
20
+ SvgPattern();
21
+ ~SvgPattern() override = default;
22
+
23
+ void OnDrawTraversedBefore(OH_Drawing_Canvas *canvas) override;
24
+ void OnDrawTraversedAfter(OH_Drawing_Canvas *canvas) override;
25
+ void SaveDefinition(OH_Drawing_Canvas *canvas);
26
+ void ConcatMatrix(OH_Drawing_Canvas *canvas);
27
+ std::shared_ptr<PatternAttr> GetPatternAttr();
28
+
29
+ void setPatternX(Dimension x);
30
+
31
+ void setPatternY(Dimension y);
32
+
33
+ void setHeight(Dimension height);
34
+
35
+ void setWidth(Dimension width);
36
+
37
+ void setPatternUnits(int patternUnits);
38
+
39
+ void setPatternContentUnits(int patternContentUnits);
40
+
41
+ void setViewBox(Rect viewBox);
42
+
43
+ void setImage(OH_Drawing_Image *image);
44
+
45
+ void setmMinX(float mMinX);
46
+
47
+ void setmMinY(float mMinUY);
48
+
49
+ void setmVbWidth(float mVbWidth);
50
+
51
+ void setmVbHeight(float mVbHeight);
52
+
53
+ void setmAlign(std::string mAlign);
54
+
55
+ void setmMeetOrSlice(int mMeetOrSlice);
56
+
57
+ void setPatternTransforms(std::vector<Float> gradientTransforms);
58
+ private:
59
+ std::shared_ptr<PatternAttr> patternAttr = std::make_shared<PatternAttr>();
60
+ double scale_ = 3.25010318;
61
+ };
62
+
63
+ } // namespace svg
64
+ } // namespace rnoh
@@ -0,0 +1,87 @@
1
+ /*
2
+ * Copyright (c) 2024 Huawei Device Co., Ltd. All rights reserved
3
+ * Use of this source code is governed by a MIT license that can be
4
+ * found in the LICENSE file.
5
+ *
6
+ * This file incorporates from the OpenHarmony project, licensed under
7
+ * the Apache License, Version 2.0. Specifically:
8
+ * - [OpenHarmony/arkui_ace_engine] (https://gitee.com/openharmony/arkui_ace_engine)
9
+ *
10
+ * Licensed under the Apache License, Version 2.0 (the "License"); you may not
11
+ * use this file except in compliance with the License. You may obtain a copy
12
+ * of the License at:
13
+ * http://www.apache.org/licenses/LICENSE-2.0
14
+ *
15
+ * Unless required by applicable law or agreed to in writing, software
16
+ * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
17
+ * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
18
+ * License for the specific language governing permissions and limitations
19
+ * under the License.
20
+ */
21
+
22
+ #pragma once
23
+
24
+ #include "SvgNode.h"
25
+ #include <native_drawing/drawing_path.h>
26
+
27
+ namespace rnoh {
28
+ namespace svg {
29
+
30
+ class SvgQuote : public SvgNode {
31
+ public:
32
+ SvgQuote() : SvgNode() { InitHrefFlag(); }
33
+ ~SvgQuote() override = default;
34
+
35
+ drawing::Path getClipPath(drawing::Path path) {
36
+ DLOG(INFO) << "[SvgQuote] getClipPath";
37
+ for (const auto &child : children_) {
38
+ auto childPath = child->AsPath();
39
+ path.AddPath(childPath);
40
+ }
41
+ return path;
42
+ }
43
+
44
+ drawing::Path getClipPath(drawing::Path path, drawing::Path::OpMode op) {
45
+ DLOG(INFO) << "[SvgQuote] getClipPath with op, op = " << op;
46
+ for (const auto &child : children_) {
47
+ auto childPath = child->AsPath();
48
+ path.Op(childPath, op);
49
+ }
50
+ return path;
51
+ }
52
+
53
+ drawing::Path AsPath() override {
54
+ DLOG(INFO) << "[SvgQuote] AsPath";
55
+ drawing::Path path;
56
+
57
+ if (attributes_.clipState.IsEvenodd()) {
58
+ return getClipPath(path);
59
+ } else {
60
+ return getClipPath(path, drawing::Path::OpMode::PATH_OP_MODE_UNION);
61
+ }
62
+ }
63
+
64
+ void Draw(OH_Drawing_Canvas *canvas) override {
65
+ // render composition on other svg tags
66
+ DLOG(INFO) << "[SvgQuote] Draw";
67
+ OnDrawTraversedBefore(canvas);
68
+ OnDrawTraversed(canvas);
69
+ OnDrawTraversedAfter(canvas);
70
+ }
71
+
72
+ protected:
73
+ virtual void OnDrawTraversedBefore(OH_Drawing_Canvas *canvas) {}
74
+ virtual void OnDrawTraversedAfter(OH_Drawing_Canvas *canvas) {}
75
+
76
+ // mask/pattern/filter/clipPath
77
+ void InitHrefFlag() {
78
+ hrefFill_ = true;
79
+ hrefRender_ = false;
80
+ passStyle_ = true;
81
+ inheritStyle_ = false;
82
+ drawTraversed_ = false;
83
+ }
84
+ };
85
+
86
+ } // namespace svg
87
+ } // namespace rnoh