@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,50 @@
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 "Brush.h"
8
+
9
+ namespace rnoh::drawing {
10
+
11
+ Brush::Brush() : brush_(UniqueNativeBrush(OH_Drawing_BrushCreate(), &OH_Drawing_BrushDestroy)) {}
12
+
13
+ Brush::Brush(Brush const &other)
14
+ : brush_(UniqueNativeBrush(OH_Drawing_BrushCopy(other.brush_.get()), &OH_Drawing_BrushDestroy)) {}
15
+
16
+ Brush &Brush::operator=(Brush const &) {
17
+ brush_ = UniqueNativeBrush(OH_Drawing_BrushCopy(brush_.get()), &OH_Drawing_BrushDestroy);
18
+ return *this;
19
+ }
20
+
21
+ void Brush::SetAntiAlias(bool antiAlias) { OH_Drawing_BrushSetAntiAlias(brush_.get(), antiAlias); }
22
+
23
+ void Brush::SetColor(uint32_t color) { OH_Drawing_BrushSetColor(brush_.get(), color); }
24
+
25
+ void Brush::SetAlpha(uint8_t alpha) { OH_Drawing_BrushSetAlpha(brush_.get(), alpha); }
26
+
27
+ void Brush::SetLinearShaderEffect(const OH_Drawing_Point2D *startPt, const OH_Drawing_Point2D *endPt,
28
+ const uint32_t *colors, const float *pos, uint32_t size, OH_Drawing_TileMode mode,
29
+ const OH_Drawing_Matrix *mat) {
30
+ brushShaderEffect_.ShaderEffectCreateLinearGradient(startPt, endPt, colors, pos, size, mode, mat);
31
+ OH_Drawing_BrushSetShaderEffect(brush_.get(), brushShaderEffect_.get());
32
+ }
33
+
34
+ void Brush::SetRadialShaderEffect(const OH_Drawing_Point2D *startPt, float startRadius, const OH_Drawing_Point2D *endPt,
35
+ float endRadius, const uint32_t *colors, const float *pos, uint32_t size,
36
+ OH_Drawing_TileMode mode, const OH_Drawing_Matrix *mat) {
37
+ brushShaderEffect_.ShaderEffectCreateRadialGradient(startPt, startRadius, endPt, endRadius, colors, pos, size, mode,
38
+ mat);
39
+ OH_Drawing_BrushSetShaderEffect(brush_.get(), brushShaderEffect_.get());
40
+ }
41
+
42
+ void Brush::SetImageShaderEffect(OH_Drawing_Image *image, OH_Drawing_TileMode tileX, OH_Drawing_TileMode tileY,
43
+ const OH_Drawing_SamplingOptions *opt, const OH_Drawing_Matrix *mat) {
44
+ brushShaderEffect_.ShaderEffectCreateImageShader(image, tileX, tileY, opt, mat);
45
+ OH_Drawing_BrushSetShaderEffect(brush_.get(), brushShaderEffect_.get());
46
+ }
47
+
48
+ void Brush::Reset() { OH_Drawing_BrushReset(brush_.get()); }
49
+
50
+ } // namespace rnoh::drawing
@@ -0,0 +1,52 @@
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 <memory>
10
+ #include <native_drawing/drawing_brush.h>
11
+ #include "ShaderEffect.h"
12
+
13
+ namespace rnoh::drawing {
14
+
15
+ class Brush final {
16
+
17
+ using UniqueNativeBrush = std::unique_ptr<OH_Drawing_Brush, decltype(&OH_Drawing_BrushDestroy)>;
18
+
19
+ public:
20
+ Brush();
21
+
22
+ Brush(Brush const &);
23
+ Brush &operator=(Brush const &);
24
+
25
+ Brush(Brush &&) = default;
26
+ Brush &operator=(Brush &&) = default;
27
+
28
+ ~Brush() noexcept = default;
29
+
30
+ void SetAntiAlias(bool antiAlias);
31
+ void SetColor(uint32_t color);
32
+ void SetAlpha(uint8_t alpha);
33
+
34
+ void SetLinearShaderEffect(const OH_Drawing_Point2D *startPt, const OH_Drawing_Point2D *endPt,
35
+ const uint32_t *colors, const float *pos, uint32_t size, OH_Drawing_TileMode mode,
36
+ const OH_Drawing_Matrix *mat);
37
+ void SetRadialShaderEffect(const OH_Drawing_Point2D *startPt, float startRadius, const OH_Drawing_Point2D *endPt,
38
+ float endRadius, const uint32_t *colors, const float *pos, uint32_t size,
39
+ OH_Drawing_TileMode mode, const OH_Drawing_Matrix *mat);
40
+ void SetImageShaderEffect(OH_Drawing_Image *image, OH_Drawing_TileMode tileX, OH_Drawing_TileMode tileY,
41
+ const OH_Drawing_SamplingOptions *opt, const OH_Drawing_Matrix *mat);
42
+
43
+ void Reset();
44
+
45
+ OH_Drawing_Brush *get() const { return brush_.get(); }
46
+
47
+ private:
48
+ UniqueNativeBrush brush_;
49
+ ShaderEffect brushShaderEffect_;
50
+ };
51
+
52
+ } // namespace rnoh::drawing
@@ -0,0 +1,20 @@
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 "GlyPathBag.h"
8
+ #include "Path.h"
9
+
10
+ namespace rnoh::drawing {
11
+
12
+
13
+ int GlyPathBag::getIndex(char ch) {
14
+ auto it = data.find(ch);
15
+ return it == data.end() ? 0 : it->second;
16
+ }
17
+
18
+ drawing::Path GlyPathBag::getOrCreateAndCache(const char &ch, const std::string &current) { return drawing::Path(); }
19
+
20
+ } // namespace rnoh::drawing
@@ -0,0 +1,31 @@
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 <unordered_map>
10
+ #include <vector>
11
+ #include "drawing/Path.h"
12
+ #include "drawing/Pen.h"
13
+
14
+ namespace rnoh::drawing {
15
+
16
+ class GlyPathBag {
17
+ private:
18
+ int getIndex(char ch);
19
+ std::vector<drawing::Path> paths;
20
+ std::unordered_map<char, int> data;
21
+ drawing::Pen paint;
22
+
23
+ public:
24
+ GlyPathBag(drawing::Pen const &paint) {
25
+ // Make indexed-by-one, to allow zero to represent non-cached
26
+ paths.push_back(drawing::Path());
27
+ }
28
+ drawing::Path getOrCreateAndCache(const char &ch, const std::string &current);
29
+ };
30
+
31
+ } // namespace rnoh::drawing
@@ -0,0 +1,100 @@
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 "Matrix.h"
8
+
9
+ namespace rnoh::drawing {
10
+
11
+ Matrix::Matrix() : matrix_(UniqueNativeMatrix(OH_Drawing_MatrixCreate(), &OH_Drawing_MatrixDestroy)) {}
12
+
13
+ Matrix::Matrix(Matrix const &other) : Matrix() { *this = other; }
14
+
15
+ Matrix &Matrix::operator=(Matrix const &other) {
16
+ if (this != &other) {
17
+ auto scaleX = OH_Drawing_MatrixGetValue(other.matrix_.get(), 0);
18
+ auto skewX = OH_Drawing_MatrixGetValue(other.matrix_.get(), 1);
19
+ auto transX = OH_Drawing_MatrixGetValue(other.matrix_.get(), 2);
20
+ auto skewY = OH_Drawing_MatrixGetValue(other.matrix_.get(), 3);
21
+ auto scaleY = OH_Drawing_MatrixGetValue(other.matrix_.get(), 4);
22
+ auto transY = OH_Drawing_MatrixGetValue(other.matrix_.get(), 5);
23
+ auto persp0 = OH_Drawing_MatrixGetValue(other.matrix_.get(), 6);
24
+ auto persp1 = OH_Drawing_MatrixGetValue(other.matrix_.get(), 7);
25
+ auto persp2 = OH_Drawing_MatrixGetValue(other.matrix_.get(), 8);
26
+ OH_Drawing_MatrixSetMatrix(matrix_.get(), scaleX, skewX, transX, skewY, scaleY, transY, persp0, persp1, persp2);
27
+ }
28
+ return *this;
29
+ }
30
+
31
+
32
+ Matrix Matrix::CreateRotation(float deg, float x, float y) {
33
+ return Matrix(OH_Drawing_MatrixCreateRotation(deg, x, y));
34
+ }
35
+ Matrix Matrix::CreateScale(float sx, float sy, float px, float py) {
36
+ return Matrix(OH_Drawing_MatrixCreateScale(sx, sy, px, py));
37
+ }
38
+ Matrix Matrix::CreateTranslation(float dx, float dy) { return Matrix(OH_Drawing_MatrixCreateTranslation(dx, dy)); }
39
+
40
+ void Matrix::PreRotate(float degree, float px, float py) { OH_Drawing_MatrixPreRotate(matrix_.get(), degree, px, py); }
41
+ void Matrix::PreScale(float sx, float sy, float px, float py) {
42
+ OH_Drawing_MatrixPreScale(matrix_.get(), sx, sy, px, py);
43
+ }
44
+ void Matrix::PreTranslate(float dx, float dy) { OH_Drawing_MatrixPreTranslate(matrix_.get(), dx, dy); }
45
+
46
+ void Matrix::PostRotate(float degree, float px, float py) {
47
+ OH_Drawing_MatrixPostRotate(matrix_.get(), degree, px, py);
48
+ }
49
+ void Matrix::PostScale(float sx, float sy, float px, float py) {
50
+ OH_Drawing_MatrixPostScale(matrix_.get(), sx, sy, px, py);
51
+ }
52
+ void Matrix::PostTranslate(float dx, float dy) { OH_Drawing_MatrixPostTranslate(matrix_.get(), dx, dy); }
53
+
54
+ void Matrix::Rotate(float degree, float px, float py) { OH_Drawing_MatrixRotate(matrix_.get(), degree, px, py); }
55
+ void Matrix::Translate(float dx, float dy) { OH_Drawing_MatrixTranslate(matrix_.get(), dx, dy); }
56
+ void Matrix::Scale(float sx, float sy, float px, float py) { OH_Drawing_MatrixScale(matrix_.get(), sx, sy, px, py); }
57
+
58
+ Matrix Matrix::Concat(const Matrix &other) const {
59
+ Matrix result;
60
+ OH_Drawing_MatrixConcat(result.matrix_.get(), matrix_.get(), other.matrix_.get());
61
+ return result;
62
+ }
63
+
64
+ std::optional<Matrix> Matrix::Invert() const {
65
+ Matrix result;
66
+ if (OH_Drawing_MatrixInvert(matrix_.get(), result.matrix_.get())) {
67
+ return result;
68
+ }
69
+ return std::nullopt;
70
+ }
71
+
72
+ float Matrix::GetValue(int index) const { return OH_Drawing_MatrixGetValue(matrix_.get(), index); }
73
+
74
+ void Matrix::SetMatrix(float scaleX, float skewX, float transX, float skewY, float scaleY, float transY, float persp0,
75
+ float persp1, float persp2) {
76
+ OH_Drawing_MatrixSetMatrix(matrix_.get(), scaleX, skewX, transX, skewY, scaleY, transY, persp0, persp1, persp2);
77
+ }
78
+
79
+ Matrix::Point drawing::Matrix::MapPoint(const Matrix::Point &point) const {
80
+ Point result;
81
+ OH_Drawing_MatrixMapPoints(matrix_.get(), &point, &result, 1);
82
+ return result;
83
+ }
84
+
85
+ std::vector<Matrix::Point> drawing::Matrix::MapPoints(const std::vector<Matrix::Point> &points) const {
86
+ std::vector<Matrix::Point> result(points.size());
87
+ OH_Drawing_MatrixMapPoints(matrix_.get(), points.data(), result.data(), points.size());
88
+ return result;
89
+ }
90
+
91
+ drawing::Rect drawing::Matrix::MapRect(const drawing::Rect &rect) const {
92
+ Rect result;
93
+ OH_Drawing_MatrixMapRect(matrix_.get(), rect.get(), result.get());
94
+ return result;
95
+ }
96
+
97
+ void Matrix::Reset() { OH_Drawing_MatrixReset(matrix_.get()); }
98
+
99
+
100
+ } // namespace rnoh::drawing
@@ -0,0 +1,68 @@
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 "Rect.h"
10
+ #include <memory>
11
+ #include <optional>
12
+ #include <vector>
13
+ #include <native_drawing/drawing_matrix.h>
14
+
15
+ namespace rnoh::drawing {
16
+
17
+ class Matrix final {
18
+ using UniqueNativeMatrix = std::unique_ptr<OH_Drawing_Matrix, decltype(&OH_Drawing_MatrixDestroy)>;
19
+ using Point = OH_Drawing_Point2D;
20
+
21
+ public:
22
+ Matrix();
23
+
24
+ Matrix(Matrix const &);
25
+ Matrix &operator=(Matrix const &);
26
+
27
+ Matrix(Matrix &&) = default;
28
+ Matrix &operator=(Matrix &&) = default;
29
+
30
+ ~Matrix() noexcept = default;
31
+
32
+ static Matrix CreateRotation(float deg, float x, float y);
33
+ static Matrix CreateScale(float sx, float sy, float px, float py);
34
+ static Matrix CreateTranslation(float dx, float dy);
35
+ void PreRotate(float degree, float px, float py);
36
+ void PreScale(float sx, float sy, float px, float py);
37
+ void PreTranslate(float dx, float dy);
38
+ void PostRotate(float degree, float px, float py);
39
+ void PostScale(float sx, float sy, float px, float py);
40
+ void PostTranslate(float dx, float dy);
41
+ void Rotate(float degree, float px, float py);
42
+ void Translate(float dx, float dy);
43
+ void Scale(float sx, float sy, float px, float py);
44
+
45
+ Matrix Concat(const Matrix &other) const;
46
+ std::optional<Matrix> Invert() const;
47
+
48
+ float GetValue(int index) const;
49
+
50
+ void SetMatrix(float scaleX, float skewX, float transX, float skewY, float scaleY, float transY, float persp0,
51
+ float persp1, float persp2);
52
+
53
+ Point MapPoint(const Point &point) const;
54
+ std::vector<Point> MapPoints(const std::vector<Point> &points) const;
55
+
56
+ drawing::Rect MapRect(const drawing::Rect &rect) const;
57
+
58
+ void Reset();
59
+
60
+ OH_Drawing_Matrix *get() const { return matrix_.get(); }
61
+
62
+ private:
63
+ Matrix(OH_Drawing_Matrix *rawMatrix) : matrix_(UniqueNativeMatrix(rawMatrix, &OH_Drawing_MatrixDestroy)) {}
64
+
65
+ UniqueNativeMatrix matrix_;
66
+ };
67
+
68
+ } // namespace rnoh::drawing
@@ -0,0 +1,173 @@
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 "Path.h"
8
+ #include <native_drawing/drawing_rect.h>
9
+
10
+ namespace rnoh {
11
+ namespace drawing {
12
+
13
+ Path::Path() : path_(UniqueNativePath(OH_Drawing_PathCreate(), &OH_Drawing_PathDestroy)) {}
14
+
15
+ Path::Path(Path const &other)
16
+ : path_(UniqueNativePath(OH_Drawing_PathCopy(other.path_.get()), &OH_Drawing_PathDestroy)) {}
17
+
18
+ Path &Path::operator=(Path const &other) {
19
+ if (this != &other) {
20
+ path_ = UniqueNativePath(OH_Drawing_PathCopy(other.path_.get()), &OH_Drawing_PathDestroy);
21
+ }
22
+ return *this;
23
+ }
24
+
25
+ void Path::Reset() { OH_Drawing_PathReset(path_.get()); }
26
+
27
+ void Path::MoveTo(float x, float y) { OH_Drawing_PathMoveTo(get(), x, y); }
28
+
29
+ void Path::LineTo(float x, float y) { OH_Drawing_PathLineTo(get(), x, y); }
30
+
31
+ void Path::ArcTo(float x1, float y1, float x2, float y2, float startDeg, float sweepDeg) {
32
+ OH_Drawing_PathArcTo(get(), x1, y1, x2, y2, startDeg, sweepDeg);
33
+ }
34
+
35
+ void Path::QuadTo(float ctrlX, float ctrlY, float endX, float endY) {
36
+ OH_Drawing_PathQuadTo(get(), ctrlX, ctrlY, endX, endY);
37
+ }
38
+
39
+ void Path::ConicTo(float ctrlX, float ctrlY, float endX, float endY, float weight) {
40
+ OH_Drawing_PathConicTo(get(), ctrlX, ctrlY, endX, endY, weight);
41
+ }
42
+
43
+ void Path::CubicTo(float ctrlX1, float ctrlY1, float ctrlX2, float ctrlY2, float endX, float endY) {
44
+ OH_Drawing_PathCubicTo(get(), ctrlX1, ctrlY1, ctrlX2, ctrlY2, endX, endY);
45
+ }
46
+
47
+ void Path::RMoveTo(float x, float y) { OH_Drawing_PathRMoveTo(get(), x, y); }
48
+
49
+ void Path::RLineTo(float x, float y) { OH_Drawing_PathRLineTo(get(), x, y); }
50
+
51
+ void Path::RQuadTo(float ctrlX, float ctrlY, float endX, float endY) {
52
+ OH_Drawing_PathRQuadTo(get(), ctrlX, ctrlY, endX, endY);
53
+ }
54
+
55
+ void Path::RConicTo(float ctrlX, float ctrlY, float endX, float endY, float weight) {
56
+ OH_Drawing_PathRConicTo(get(), ctrlX, ctrlY, endX, endY, weight);
57
+ }
58
+
59
+ void Path::RCubicTo(float ctrlX1, float ctrlY1, float ctrlX2, float ctrlY2, float endX, float endY) {
60
+ OH_Drawing_PathRCubicTo(get(), ctrlX1, ctrlY1, ctrlX2, ctrlY2, endX, endY);
61
+ }
62
+
63
+ void Path::AddRect(float left, float top, float right, float bottom, Direction direction) {
64
+ OH_Drawing_PathAddRect(get(), left, top, right, bottom, direction);
65
+ }
66
+
67
+ void Path::AddRectWithInitialCorner(const Rect &rect, Direction direction, uint32_t start) {
68
+ OH_Drawing_PathAddRectWithInitialCorner(get(), rect.get(), direction, start);
69
+ }
70
+
71
+ void Path::AddRoundRect(const RoundRect &roundRect, Direction direction) {
72
+ OH_Drawing_PathAddRoundRect(get(), roundRect.get(), direction);
73
+ }
74
+
75
+ void Path::AddOvalWithInitialPoint(const Rect &rect, uint32_t start, Direction direction) {
76
+ OH_Drawing_PathAddOvalWithInitialPoint(get(), rect.get(), start, direction);
77
+ }
78
+
79
+ void Path::AddOval(const Rect &rect, Direction direction) { OH_Drawing_PathAddOval(get(), rect.get(), direction); }
80
+
81
+ void Path::AddArc(const Rect &rect, float startAngle, float sweepAngle) {
82
+ OH_Drawing_PathAddArc(get(), rect.get(), startAngle, sweepAngle);
83
+ }
84
+
85
+ void Path::AddPath(const Path &src) { OH_Drawing_PathAddPath(get(), src.get(), nullptr); }
86
+
87
+ void Path::AddPath(const Path &src, const Matrix &matrix) { OH_Drawing_PathAddPath(get(), src.get(), matrix.get()); }
88
+
89
+ void Path::AddPathWithMatrixAndMode(const Path &src, const Matrix &matrix, AddMode mode) {
90
+ OH_Drawing_PathAddPathWithMatrixAndMode(get(), src.get(), matrix.get(), mode);
91
+ }
92
+
93
+ void Path::AddPathWithMode(const Path &src, AddMode mode) { OH_Drawing_PathAddPathWithMode(get(), src.get(), mode); }
94
+
95
+ void Path::AddPathWithOffsetAndMode(const Path &src, float dx, float dy, AddMode mode) {
96
+ OH_Drawing_PathAddPathWithOffsetAndMode(get(), src.get(), dx, dy, mode);
97
+ }
98
+
99
+ void Path::AddPolygon(const OH_Drawing_Point2D *points, uint32_t count, bool isClosed) {
100
+ OH_Drawing_PathAddPolygon(get(), points, count, isClosed);
101
+ }
102
+
103
+ void Path::AddCircle(float x, float y, float radius, Direction direction) {
104
+ OH_Drawing_PathAddCircle(get(), x, y, radius, direction);
105
+ }
106
+
107
+ std::optional<Path> Path::BuildFromSvgString(const char *str) {
108
+ Path path;
109
+ if (OH_Drawing_PathBuildFromSvgString(path.get(), str)) {
110
+ return path;
111
+ } else {
112
+ return std::nullopt;
113
+ }
114
+ }
115
+
116
+ bool Path::Contains(float x, float y) { return OH_Drawing_PathContains(get(), x, y); }
117
+
118
+ void Path::Transform(const Matrix &matrix) { OH_Drawing_PathTransform(get(), matrix.get()); }
119
+
120
+ Path Path::TransformWithPerspectiveClip(const Matrix &matrix, bool applyPerspectiveClip) {
121
+ Path path;
122
+ OH_Drawing_PathTransformWithPerspectiveClip(get(), matrix.get(), path.get(), applyPerspectiveClip);
123
+ return path;
124
+ }
125
+
126
+ void Path::SetFillType(FillType fillType) { OH_Drawing_PathSetFillType(get(), fillType); }
127
+
128
+ float Path::GetLength(bool forceClosed) { return OH_Drawing_PathGetLength(get(), forceClosed); }
129
+
130
+ Rect Path::GetBounds() {
131
+ Rect bounds;
132
+ OH_Drawing_PathGetBounds(get(), bounds.get());
133
+ return bounds;
134
+ }
135
+
136
+ void Path::Close() { OH_Drawing_PathClose(get()); }
137
+
138
+ Path Path::Offset(float dx, float dy) {
139
+ Path path;
140
+ OH_Drawing_PathOffset(get(), path.get(), dx, dy);
141
+ return path;
142
+ }
143
+
144
+ bool Path::IsClosed(bool forceClosed) { return OH_Drawing_PathIsClosed(get(), forceClosed); }
145
+
146
+ bool Path::GetPositionTangent(bool forceClosed, float distance, OH_Drawing_Point2D *position,
147
+ OH_Drawing_Point2D *tangent) {
148
+ return OH_Drawing_PathGetPositionTangent(get(), forceClosed, distance, position, tangent);
149
+ }
150
+
151
+ bool Path::Op(Path &source, OpMode mode) { return OH_Drawing_PathOp(get(), source.get(), mode); }
152
+
153
+ bool Path::Difference(Path &source) { return Op(source, PATH_OP_MODE_DIFFERENCE); }
154
+
155
+ bool Path::Intersect(Path &source) { return Op(source, PATH_OP_MODE_INTERSECT); }
156
+
157
+ bool Path::Union(Path &source) { return Op(source, PATH_OP_MODE_UNION); }
158
+
159
+ bool Path::Xor(Path &source) { return Op(source, PATH_OP_MODE_XOR); }
160
+
161
+ bool Path::ReverseDifference(Path &source) { return Op(source, PATH_OP_MODE_REVERSE_DIFFERENCE); }
162
+
163
+ std::optional<Matrix> Path::GetMatrix(bool forceClosed, float distance, MeasureMatrixFlags flag) {
164
+ Matrix matrix;
165
+ if (OH_Drawing_PathGetMatrix(get(), forceClosed, distance, matrix.get(), flag)) {
166
+ return matrix;
167
+ } else {
168
+ return std::nullopt;
169
+ }
170
+ }
171
+
172
+ } // namespace drawing
173
+ } // namespace rnoh
@@ -0,0 +1,127 @@
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 <memory>
10
+ #include <native_drawing/drawing_path.h>
11
+ #include "Matrix.h"
12
+ #include "Rect.h"
13
+ #include "RoundRect.h"
14
+
15
+ namespace rnoh::drawing {
16
+
17
+ class Path final {
18
+ using UniqueNativePath = std::unique_ptr<OH_Drawing_Path, decltype(&OH_Drawing_PathDestroy)>;
19
+
20
+ public:
21
+ using Direction = OH_Drawing_PathDirection;
22
+ using AddMode = OH_Drawing_PathAddMode;
23
+ using FillType = OH_Drawing_PathFillType;
24
+ using MeasureMatrixFlags = OH_Drawing_PathMeasureMatrixFlags;
25
+ using OpMode = OH_Drawing_PathOpMode;
26
+
27
+ Path();
28
+
29
+ Path(Path const &);
30
+ Path &operator=(Path const &);
31
+
32
+ Path(Path &&) = default;
33
+ Path &operator=(Path &&) = default;
34
+
35
+ ~Path() noexcept = default;
36
+
37
+ void Reset();
38
+
39
+ void MoveTo(float x, float y);
40
+
41
+ void LineTo(float x, float y);
42
+
43
+ void ArcTo(float x1, float y1, float x2, float y2, float startDeg, float sweepDeg);
44
+
45
+ void QuadTo(float ctrlX, float ctrlY, float endX, float endY);
46
+
47
+ void ConicTo(float ctrlX, float ctrlY, float endX, float endY, float weight);
48
+
49
+ void CubicTo(float ctrlX1, float ctrlY1, float ctrlX2, float ctrlY2, float endX, float endY);
50
+
51
+ void RMoveTo(float x, float y);
52
+
53
+ void RLineTo(float x, float y);
54
+
55
+ void RQuadTo(float ctrlX, float ctrlY, float endX, float endY);
56
+
57
+ void RConicTo(float ctrlX, float ctrlY, float endX, float endY, float weight);
58
+
59
+ void RCubicTo(float ctrlX1, float ctrlY1, float ctrlX2, float ctrlY2, float endX, float endY);
60
+
61
+ void AddRect(float left, float top, float right, float bottom, Direction);
62
+ void AddRectWithInitialCorner(const Rect &, Direction, uint32_t start);
63
+ void AddRoundRect(const RoundRect &roundRect, Direction);
64
+
65
+ void AddOvalWithInitialPoint(const Rect &, uint32_t start, Direction);
66
+ void AddOval(const Rect &, Direction);
67
+
68
+ void AddArc(const Rect &, float startAngle, float sweepAngle);
69
+
70
+ void AddPath(const Path &src);
71
+ void AddPath(const Path &src, const Matrix &);
72
+
73
+ void AddPathWithMatrixAndMode(const Path &src, const Matrix &, AddMode);
74
+ void AddPathWithMode(const Path &src, AddMode);
75
+
76
+ void AddPathWithOffsetAndMode(const Path &src, float dx, float dy, AddMode);
77
+ void AddPolygon(const OH_Drawing_Point2D *points, uint32_t count, bool isClosed);
78
+
79
+ void AddCircle(float x, float y, float radius, Direction);
80
+
81
+ static std::optional<Path> BuildFromSvgString(const char *str);
82
+
83
+ bool Contains(float x, float y);
84
+
85
+
86
+ void Transform(const Matrix &);
87
+
88
+
89
+ Path TransformWithPerspectiveClip(const Matrix &, bool applyPerspectiveClip);
90
+
91
+
92
+ void SetFillType(FillType);
93
+
94
+ float GetLength(bool forceClosed);
95
+
96
+ Rect GetBounds();
97
+
98
+ void Close();
99
+
100
+ Path Offset(float dx, float dy);
101
+
102
+ bool IsClosed(bool forceClosed);
103
+
104
+ bool GetPositionTangent(bool forceClosed, float distance, OH_Drawing_Point2D *position,
105
+ OH_Drawing_Point2D *tangent);
106
+
107
+ bool Op(Path &source, OpMode mode);
108
+
109
+ bool Difference(Path &source);
110
+
111
+ bool Intersect(Path &source);
112
+
113
+ bool Union(Path &source);
114
+
115
+ bool Xor(Path &source);
116
+
117
+ bool ReverseDifference(Path &source);
118
+
119
+ std::optional<Matrix> GetMatrix(bool forceClosed, float distance, MeasureMatrixFlags flag);
120
+
121
+ OH_Drawing_Path *get() const { return path_.get(); }
122
+
123
+ private:
124
+ UniqueNativePath path_;
125
+ };
126
+
127
+ } // namespace rnoh::drawing
@@ -0,0 +1,57 @@
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 "Pen.h"
8
+
9
+ namespace rnoh::drawing {
10
+
11
+ Pen::Pen() : pen_(UniqueNativePen(OH_Drawing_PenCreate(), &OH_Drawing_PenDestroy)) {}
12
+
13
+ Pen::Pen(Pen const &other) : pen_(UniqueNativePen(OH_Drawing_PenCopy(other.pen_.get()), &OH_Drawing_PenDestroy)) {}
14
+
15
+ Pen &Pen::operator=(Pen const &) {
16
+ pen_ = UniqueNativePen(OH_Drawing_PenCopy(pen_.get()), &OH_Drawing_PenDestroy);
17
+ return *this;
18
+ }
19
+
20
+ void Pen::SetAntiAlias(bool antiAlias) { OH_Drawing_PenSetAntiAlias(pen_.get(), antiAlias); }
21
+
22
+ void Pen::SetColor(uint32_t color) { OH_Drawing_PenSetColor(pen_.get(), color); }
23
+
24
+ void Pen::SetAlpha(uint8_t alpha) { OH_Drawing_PenSetAlpha(pen_.get(), alpha); }
25
+
26
+ void Pen::SetWidth(double width) { OH_Drawing_PenSetWidth(pen_.get(), width); }
27
+
28
+ void Pen::SetMiterLimit(float miterLimit) { OH_Drawing_PenSetMiterLimit(pen_.get(), miterLimit); }
29
+
30
+ void Pen::SetLineCap(LineCapStyle lineCap) { OH_Drawing_PenSetCap(pen_.get(), lineCap); }
31
+
32
+ void Pen::SetLineJoin(LineJoinStyle lineJoin) { OH_Drawing_PenSetJoin(pen_.get(), lineJoin); }
33
+
34
+ void Pen::SetLinearShaderEffect(const OH_Drawing_Point2D *startPt, const OH_Drawing_Point2D *endPt,
35
+ const uint32_t *colors, const float *pos, uint32_t size, OH_Drawing_TileMode mode,
36
+ const OH_Drawing_Matrix *mat) {
37
+ penShaderEffect_.ShaderEffectCreateLinearGradient(startPt, endPt, colors, pos, size, mode, mat);
38
+ OH_Drawing_PenSetShaderEffect(pen_.get(), penShaderEffect_.get());
39
+ }
40
+
41
+ void Pen::SetRadialShaderEffect(const OH_Drawing_Point2D *startPt, float startRadius, const OH_Drawing_Point2D *endPt,
42
+ float endRadius, const uint32_t *colors, const float *pos, uint32_t size,
43
+ OH_Drawing_TileMode mode, const OH_Drawing_Matrix *mat) {
44
+ penShaderEffect_.ShaderEffectCreateRadialGradient(startPt, startRadius, endPt, endRadius, colors, pos, size, mode,
45
+ mat);
46
+ OH_Drawing_PenSetShaderEffect(pen_.get(), penShaderEffect_.get());
47
+ }
48
+
49
+ void Pen::SetImageShaderEffect(OH_Drawing_Image *image, OH_Drawing_TileMode tileX, OH_Drawing_TileMode tileY,
50
+ const OH_Drawing_SamplingOptions *opt, const OH_Drawing_Matrix *mat) {
51
+ penShaderEffect_.ShaderEffectCreateImageShader(image, tileX, tileY, opt, mat);
52
+ OH_Drawing_PenSetShaderEffect(pen_.get(), penShaderEffect_.get());
53
+ }
54
+
55
+ void Pen::Reset() {}
56
+
57
+ } // namespace rnoh::drawing