@visactor/vrender-core 0.21.0-alpha.3 → 0.21.0-alpha.5

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 (238) hide show
  1. package/cjs/animate/Ticker/default-ticker.d.ts +4 -2
  2. package/cjs/animate/Ticker/default-ticker.js +8 -5
  3. package/cjs/animate/Ticker/default-ticker.js.map +1 -1
  4. package/cjs/animate/custom-animate.d.ts +2 -0
  5. package/cjs/animate/custom-animate.js +11 -2
  6. package/cjs/animate/custom-animate.js.map +1 -1
  7. package/cjs/common/3d-interceptor.js +1 -2
  8. package/cjs/common/bounds-context.js +2 -1
  9. package/cjs/common/morphing-utils.js +1 -1
  10. package/cjs/common/path-svg.js +1 -1
  11. package/cjs/common/polygon.js +2 -2
  12. package/cjs/common/rect-utils.js +1 -1
  13. package/cjs/common/render-area.js +1 -1
  14. package/cjs/common/render-command-list.js +1 -2
  15. package/cjs/common/render-curve.js +1 -1
  16. package/cjs/common/render-utils.js +1 -1
  17. package/cjs/common/seg-context.js +1 -1
  18. package/cjs/common/simplify.js +1 -1
  19. package/cjs/common/sort.js +1 -1
  20. package/cjs/common/split-path.js +1 -1
  21. package/cjs/common/store.js +1 -1
  22. package/cjs/common/text.js.map +1 -1
  23. package/cjs/core/application.js +2 -1
  24. package/cjs/core/camera.js +1 -1
  25. package/cjs/core/constants.js +1 -1
  26. package/cjs/core/contributions/textMeasure/layout.js +1 -1
  27. package/cjs/core/contributions/textMeasure/layout.js.map +1 -1
  28. package/cjs/core/core-modules.js +1 -1
  29. package/cjs/core/global-module.js +2 -0
  30. package/cjs/core/global.js +1 -1
  31. package/cjs/core/graphic-utils.js +1 -1
  32. package/cjs/core/index.js +1 -1
  33. package/cjs/core/layer-service.js +1 -1
  34. package/cjs/core/layer.js +1 -1
  35. package/cjs/core/light.js +1 -1
  36. package/cjs/core/stage.d.ts +2 -0
  37. package/cjs/core/stage.js +10 -6
  38. package/cjs/core/stage.js.map +1 -1
  39. package/cjs/core/window.js +1 -1
  40. package/cjs/graphic/builtin-symbol/arrow.js +2 -2
  41. package/cjs/graphic/builtin-symbol/arrow.js.map +1 -1
  42. package/cjs/graphic/builtin-symbol/arrow2-down.js +2 -2
  43. package/cjs/graphic/builtin-symbol/arrow2-down.js.map +1 -1
  44. package/cjs/graphic/builtin-symbol/arrow2-left.js +2 -2
  45. package/cjs/graphic/builtin-symbol/arrow2-left.js.map +1 -1
  46. package/cjs/graphic/builtin-symbol/arrow2-right.js +2 -2
  47. package/cjs/graphic/builtin-symbol/arrow2-right.js.map +1 -1
  48. package/cjs/graphic/builtin-symbol/arrow2-up.js +2 -2
  49. package/cjs/graphic/builtin-symbol/arrow2-up.js.map +1 -1
  50. package/cjs/graphic/builtin-symbol/base.d.ts +1 -0
  51. package/cjs/graphic/builtin-symbol/base.js +3 -0
  52. package/cjs/graphic/builtin-symbol/base.js.map +1 -1
  53. package/cjs/graphic/builtin-symbol/circle.js +3 -3
  54. package/cjs/graphic/builtin-symbol/circle.js.map +1 -1
  55. package/cjs/graphic/builtin-symbol/close.js +3 -3
  56. package/cjs/graphic/builtin-symbol/close.js.map +1 -1
  57. package/cjs/graphic/builtin-symbol/cross.js +2 -2
  58. package/cjs/graphic/builtin-symbol/cross.js.map +1 -1
  59. package/cjs/graphic/builtin-symbol/diamond.js +3 -3
  60. package/cjs/graphic/builtin-symbol/diamond.js.map +1 -1
  61. package/cjs/graphic/builtin-symbol/line-h.js +3 -3
  62. package/cjs/graphic/builtin-symbol/line-h.js.map +1 -1
  63. package/cjs/graphic/builtin-symbol/line-v.js +3 -3
  64. package/cjs/graphic/builtin-symbol/line-v.js.map +1 -1
  65. package/cjs/graphic/builtin-symbol/square.js +2 -2
  66. package/cjs/graphic/builtin-symbol/square.js.map +1 -1
  67. package/cjs/graphic/builtin-symbol/star.js +2 -2
  68. package/cjs/graphic/builtin-symbol/star.js.map +1 -1
  69. package/cjs/graphic/builtin-symbol/stroke.js +2 -2
  70. package/cjs/graphic/builtin-symbol/stroke.js.map +1 -1
  71. package/cjs/graphic/builtin-symbol/thin-triangle.js +2 -2
  72. package/cjs/graphic/builtin-symbol/thin-triangle.js.map +1 -1
  73. package/cjs/graphic/builtin-symbol/triangle-down.js +2 -2
  74. package/cjs/graphic/builtin-symbol/triangle-down.js.map +1 -1
  75. package/cjs/graphic/builtin-symbol/triangle-left.js +2 -2
  76. package/cjs/graphic/builtin-symbol/triangle-left.js.map +1 -1
  77. package/cjs/graphic/builtin-symbol/triangle-right.js +2 -2
  78. package/cjs/graphic/builtin-symbol/triangle-right.js.map +1 -1
  79. package/cjs/graphic/builtin-symbol/triangle-up.js +2 -2
  80. package/cjs/graphic/builtin-symbol/triangle-up.js.map +1 -1
  81. package/cjs/graphic/builtin-symbol/utils.d.ts +1 -0
  82. package/cjs/graphic/builtin-symbol/utils.js +6 -3
  83. package/cjs/graphic/builtin-symbol/utils.js.map +1 -1
  84. package/cjs/graphic/builtin-symbol/wedge.js +2 -2
  85. package/cjs/graphic/builtin-symbol/wedge.js.map +1 -1
  86. package/cjs/graphic/builtin-symbol/wye.js +2 -2
  87. package/cjs/graphic/builtin-symbol/wye.js.map +1 -1
  88. package/cjs/graphic/config.js +2 -1
  89. package/cjs/graphic/config.js.map +1 -1
  90. package/cjs/graphic/richtext/paragraph.js +3 -1
  91. package/cjs/graphic/richtext/paragraph.js.map +1 -1
  92. package/cjs/graphic/text.js +10 -7
  93. package/cjs/graphic/text.js.map +1 -1
  94. package/cjs/interface/animate.d.ts +3 -1
  95. package/cjs/interface/animate.js.map +1 -1
  96. package/cjs/interface/context.d.ts +1 -0
  97. package/cjs/interface/context.js.map +1 -1
  98. package/cjs/interface/graphic/text.js.map +1 -1
  99. package/cjs/interface/graphic.d.ts +1 -0
  100. package/cjs/interface/graphic.js.map +1 -1
  101. package/cjs/interface/stage.d.ts +1 -0
  102. package/cjs/interface/stage.js.map +1 -1
  103. package/cjs/interface/text.d.ts +1 -0
  104. package/cjs/interface/text.js.map +1 -1
  105. package/cjs/render/contributions/render/contributions/arc-contribution-render.js +2 -2
  106. package/cjs/render/contributions/render/contributions/arc-contribution-render.js.map +1 -1
  107. package/cjs/render/contributions/render/contributions/circle-contribution-render.js +2 -2
  108. package/cjs/render/contributions/render/contributions/circle-contribution-render.js.map +1 -1
  109. package/cjs/render/contributions/render/contributions/rect-contribution-render.js +2 -2
  110. package/cjs/render/contributions/render/contributions/rect-contribution-render.js.map +1 -1
  111. package/cjs/render/contributions/render/contributions/symbol-contribution-render.js +2 -2
  112. package/cjs/render/contributions/render/contributions/symbol-contribution-render.js.map +1 -1
  113. package/cjs/render/contributions/render/text-render.d.ts +1 -1
  114. package/cjs/render/contributions/render/text-render.js +23 -23
  115. package/cjs/render/contributions/render/text-render.js.map +1 -1
  116. package/dist/index.es.js +145 -92
  117. package/es/animate/Ticker/default-ticker.d.ts +4 -2
  118. package/es/animate/Ticker/default-ticker.js +9 -6
  119. package/es/animate/Ticker/default-ticker.js.map +1 -1
  120. package/es/animate/custom-animate.d.ts +2 -0
  121. package/es/animate/custom-animate.js +11 -2
  122. package/es/animate/custom-animate.js.map +1 -1
  123. package/es/common/3d-interceptor.js +1 -2
  124. package/es/common/bounds-context.js +2 -1
  125. package/es/common/morphing-utils.js +1 -1
  126. package/es/common/path-svg.js +1 -1
  127. package/es/common/polygon.js +1 -1
  128. package/es/common/rect-utils.js +1 -1
  129. package/es/common/render-area.js +1 -1
  130. package/es/common/render-command-list.js +1 -2
  131. package/es/common/render-curve.js +1 -1
  132. package/es/common/render-utils.js +1 -1
  133. package/es/common/seg-context.js +1 -1
  134. package/es/common/simplify.js +1 -1
  135. package/es/common/sort.js +1 -1
  136. package/es/common/split-path.js +1 -1
  137. package/es/common/store.js +1 -1
  138. package/es/common/text.js.map +1 -1
  139. package/es/core/application.js +2 -1
  140. package/es/core/camera.js +1 -1
  141. package/es/core/constants.js +1 -1
  142. package/es/core/contributions/textMeasure/layout.js +1 -1
  143. package/es/core/contributions/textMeasure/layout.js.map +1 -1
  144. package/es/core/core-modules.js +1 -1
  145. package/es/core/global-module.js +2 -0
  146. package/es/core/global.js +1 -1
  147. package/es/core/graphic-utils.js +1 -1
  148. package/es/core/index.js +1 -1
  149. package/es/core/layer-service.js +1 -1
  150. package/es/core/layer.js +1 -1
  151. package/es/core/light.js +1 -1
  152. package/es/core/stage.d.ts +2 -0
  153. package/es/core/stage.js +10 -6
  154. package/es/core/stage.js.map +1 -1
  155. package/es/core/window.js +1 -1
  156. package/es/graphic/builtin-symbol/arrow.js +2 -2
  157. package/es/graphic/builtin-symbol/arrow.js.map +1 -1
  158. package/es/graphic/builtin-symbol/arrow2-down.js +2 -2
  159. package/es/graphic/builtin-symbol/arrow2-down.js.map +1 -1
  160. package/es/graphic/builtin-symbol/arrow2-left.js +2 -2
  161. package/es/graphic/builtin-symbol/arrow2-left.js.map +1 -1
  162. package/es/graphic/builtin-symbol/arrow2-right.js +2 -2
  163. package/es/graphic/builtin-symbol/arrow2-right.js.map +1 -1
  164. package/es/graphic/builtin-symbol/arrow2-up.js +2 -2
  165. package/es/graphic/builtin-symbol/arrow2-up.js.map +1 -1
  166. package/es/graphic/builtin-symbol/base.d.ts +1 -0
  167. package/es/graphic/builtin-symbol/base.js +3 -0
  168. package/es/graphic/builtin-symbol/base.js.map +1 -1
  169. package/es/graphic/builtin-symbol/circle.js +3 -3
  170. package/es/graphic/builtin-symbol/circle.js.map +1 -1
  171. package/es/graphic/builtin-symbol/close.js +3 -3
  172. package/es/graphic/builtin-symbol/close.js.map +1 -1
  173. package/es/graphic/builtin-symbol/cross.js +2 -2
  174. package/es/graphic/builtin-symbol/cross.js.map +1 -1
  175. package/es/graphic/builtin-symbol/diamond.js +3 -3
  176. package/es/graphic/builtin-symbol/diamond.js.map +1 -1
  177. package/es/graphic/builtin-symbol/line-h.js +3 -3
  178. package/es/graphic/builtin-symbol/line-h.js.map +1 -1
  179. package/es/graphic/builtin-symbol/line-v.js +3 -3
  180. package/es/graphic/builtin-symbol/line-v.js.map +1 -1
  181. package/es/graphic/builtin-symbol/square.js +2 -2
  182. package/es/graphic/builtin-symbol/square.js.map +1 -1
  183. package/es/graphic/builtin-symbol/star.js +2 -2
  184. package/es/graphic/builtin-symbol/star.js.map +1 -1
  185. package/es/graphic/builtin-symbol/stroke.js +2 -2
  186. package/es/graphic/builtin-symbol/stroke.js.map +1 -1
  187. package/es/graphic/builtin-symbol/thin-triangle.js +2 -2
  188. package/es/graphic/builtin-symbol/thin-triangle.js.map +1 -1
  189. package/es/graphic/builtin-symbol/triangle-down.js +2 -2
  190. package/es/graphic/builtin-symbol/triangle-down.js.map +1 -1
  191. package/es/graphic/builtin-symbol/triangle-left.js +2 -2
  192. package/es/graphic/builtin-symbol/triangle-left.js.map +1 -1
  193. package/es/graphic/builtin-symbol/triangle-right.js +2 -2
  194. package/es/graphic/builtin-symbol/triangle-right.js.map +1 -1
  195. package/es/graphic/builtin-symbol/triangle-up.js +2 -2
  196. package/es/graphic/builtin-symbol/triangle-up.js.map +1 -1
  197. package/es/graphic/builtin-symbol/utils.d.ts +1 -0
  198. package/es/graphic/builtin-symbol/utils.js +7 -4
  199. package/es/graphic/builtin-symbol/utils.js.map +1 -1
  200. package/es/graphic/builtin-symbol/wedge.js +2 -2
  201. package/es/graphic/builtin-symbol/wedge.js.map +1 -1
  202. package/es/graphic/builtin-symbol/wye.js +2 -2
  203. package/es/graphic/builtin-symbol/wye.js.map +1 -1
  204. package/es/graphic/config.js +2 -1
  205. package/es/graphic/config.js.map +1 -1
  206. package/es/graphic/richtext/paragraph.js +4 -2
  207. package/es/graphic/richtext/paragraph.js.map +1 -1
  208. package/es/graphic/text.js +10 -7
  209. package/es/graphic/text.js.map +1 -1
  210. package/es/interface/animate.d.ts +3 -1
  211. package/es/interface/animate.js.map +1 -1
  212. package/es/interface/context.d.ts +1 -0
  213. package/es/interface/context.js.map +1 -1
  214. package/es/interface/graphic/text.js.map +1 -1
  215. package/es/interface/graphic.d.ts +1 -0
  216. package/es/interface/graphic.js.map +1 -1
  217. package/es/interface/stage.d.ts +1 -0
  218. package/es/interface/stage.js.map +1 -1
  219. package/es/interface/text.d.ts +1 -0
  220. package/es/interface/text.js.map +1 -1
  221. package/es/render/contributions/render/contributions/arc-contribution-render.js +2 -2
  222. package/es/render/contributions/render/contributions/arc-contribution-render.js.map +1 -1
  223. package/es/render/contributions/render/contributions/circle-contribution-render.js +2 -2
  224. package/es/render/contributions/render/contributions/circle-contribution-render.js.map +1 -1
  225. package/es/render/contributions/render/contributions/rect-contribution-render.js +2 -2
  226. package/es/render/contributions/render/contributions/rect-contribution-render.js.map +1 -1
  227. package/es/render/contributions/render/contributions/symbol-contribution-render.js +2 -2
  228. package/es/render/contributions/render/contributions/symbol-contribution-render.js.map +1 -1
  229. package/es/render/contributions/render/text-render.d.ts +1 -1
  230. package/es/render/contributions/render/text-render.js +22 -22
  231. package/es/render/contributions/render/text-render.js.map +1 -1
  232. package/package.json +4 -3
  233. package/cjs/graphic/text2.d.ts +0 -81
  234. package/cjs/graphic/text2.js +0 -288
  235. package/cjs/graphic/text2.js.map +0 -1
  236. package/es/graphic/text2.d.ts +0 -81
  237. package/es/graphic/text2.js +0 -293
  238. package/es/graphic/text2.js.map +0 -1
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/render/contributions/render/contributions/arc-contribution-render.ts"],"names":[],"mappings":"AAWA,OAAO,EAAE,eAAe,EAAE,MAAM,iCAAiC,CAAC;AAClE,OAAO,EAAE,uCAAuC,EAAE,MAAM,4BAA4B,CAAC;AACrF,OAAO,EAAE,WAAW,EAAE,MAAM,UAAU,CAAC;AACvC,OAAO,EAAE,0BAA0B,EAAE,MAAM,0BAA0B,CAAC;AACtE,OAAO,EAAE,oCAAoC,EAAE,MAAM,oCAAoC,CAAC;AAE1F,MAAM,OAAO,4BAA4B;IAAzC;QACE,SAAI,GAA+B,0BAA0B,CAAC,eAAe,CAAC;QAC9E,aAAQ,GAAY,IAAI,CAAC;QACzB,UAAK,GAAW,CAAC,CAAC;IAo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AG,CAAC,CAAC,GAAG,MAAM,EACtB,YAAY,CAAC,GAAG,CAAQ,CACzB,CAAC;gBACD,YAAY,CAAC,GAAG,CAAS,CAAC,OAAO,GAAG,WAAW,CAAC;gBACjD,OAAO,CAAC,MAAM,EAAE,CAAC;aAClB;QACH,CAAC,CAAC;QAEF,aAAa,IAAI,YAAY,CAAC,WAAW,EAAE,aAAa,CAAC,CAAC;QAC1D,aAAa,IAAI,YAAY,CAAC,WAAW,EAAE,aAAa,CAAC,CAAC;QAC1D,GAAG,CAAC,aAAa,CAAC,EAAE,WAAW,EAAE,WAAW,EAAE,WAAW,EAAE,WAAW,EAAE,UAAU,EAAE,QAAQ,EAAS,CAAC,CAAC;IACzG,CAAC;CACF;AAED,MAAM,CAAC,MAAM,4BAA4B,GAAG,IAAI,4BAA4B,EAAE,CAAC;AAC/E,MAAM,CAAC,MAAM,mCAAmC,GAAG,oCAAoC,CAAC;AACxF,MAAM,CAAC,MAAM,sCAAsC,GAAG,uCAAuC,CAAC","file":"arc-contribution-render.js","sourcesContent":["import type {\n IGraphicAttribute,\n IContext2d,\n IMarkAttribute,\n IArc,\n IArcGraphicAttribute,\n IThemeAttribute,\n IArcRenderContribution,\n IDrawContext,\n IBorderStyle\n} from '../../../../interface';\nimport { getScaledStroke } from '../../../../common/canvas-utils';\nimport { defaultBaseBackgroundRenderContribution } from './base-contribution-render';\nimport { drawArcPath } from '../utils';\nimport { BaseRenderContributionTime } from '../../../../common/enums';\nimport { defaultBaseTextureRenderContribution } from './base-texture-contribution-render';\n\nexport class DefaultArcRenderContribution implements IArcRenderContribution {\n time: BaseRenderContributionTime = BaseRenderContributionTime.afterFillStroke;\n useStyle: boolean = true;\n order: number = 0;\n drawShape(\n arc: IArc,\n context: IContext2d,\n x: number,\n y: number,\n doFill: boolean,\n doStroke: boolean,\n fVisible: boolean,\n sVisible: boolean,\n arcAttribute: Required<IArcGraphicAttribute>,\n drawContext: IDrawContext,\n fillCb?: (\n ctx: IContext2d,\n markAttribute: Partial<IMarkAttribute & IGraphicAttribute>,\n themeAttribute: IThemeAttribute\n ) => boolean,\n strokeCb?: (\n ctx: IContext2d,\n markAttribute: Partial<IMarkAttribute & IGraphicAttribute>,\n themeAttribute: IThemeAttribute\n ) => boolean\n ) {\n const { outerBorder, innerBorder } = arc.attribute;\n const doOuterBorder = outerBorder && outerBorder.visible !== false;\n const doInnerBorder = innerBorder && innerBorder.visible !== false;\n if (!(doOuterBorder || doInnerBorder)) {\n return;\n }\n const {\n innerPadding = arcAttribute.innerPadding,\n outerPadding = arcAttribute.outerPadding,\n startAngle = arcAttribute.startAngle,\n endAngle = arcAttribute.endAngle,\n opacity = arcAttribute.opacity,\n x: originX = arcAttribute.x,\n y: originY = arcAttribute.y,\n scaleX = arcAttribute.scaleX,\n scaleY = arcAttribute.scaleY\n } = arc.attribute;\n let { innerRadius = arcAttribute.innerRadius, outerRadius = arcAttribute.outerRadius } = arc.attribute;\n outerRadius += outerPadding;\n innerRadius -= innerPadding;\n\n const renderBorder = (borderStyle: Partial<IBorderStyle>, key: 'outerBorder' | 'innerBorder') => {\n const doStroke = !!(borderStyle && borderStyle.stroke);\n\n const { distance = arcAttribute[key].distance } = borderStyle;\n const d = getScaledStroke(context, distance as number, context.dpr);\n const deltaAngle = (distance as number) / outerRadius;\n const sign = key === 'outerBorder' ? 1 : -1;\n arc.setAttributes({\n outerRadius: outerRadius + sign * d,\n innerRadius: innerRadius - sign * d,\n startAngle: startAngle - sign * deltaAngle,\n endAngle: endAngle + sign * deltaAngle\n } as any);\n context.beginPath();\n drawArcPath(arc, context, x, y, outerRadius + sign * d, innerRadius - sign * d);\n // shadow\n context.setShadowBlendStyle && context.setShadowBlendStyle(arc, arc.attribute, arcAttribute);\n\n if (strokeCb) {\n strokeCb(context, borderStyle, arcAttribute[key]);\n } else if (doStroke) {\n // 存在stroke\n const lastOpacity = (arcAttribute[key] as any).opacity;\n (arcAttribute[key] as any).opacity = opacity;\n context.setStrokeStyle(\n arc,\n borderStyle,\n (originX - x) / scaleX,\n (originY - y) / scaleY,\n arcAttribute[key] as any\n );\n (arcAttribute[key] as any).opacity = lastOpacity;\n context.stroke();\n }\n };\n\n doOuterBorder && renderBorder(outerBorder, 'outerBorder');\n doInnerBorder && renderBorder(innerBorder, 'innerBorder');\n arc.setAttributes({ outerRadius: outerRadius, innerRadius: innerRadius, startAngle, endAngle } as any);\n }\n}\n\nexport const defaultArcRenderContribution = new DefaultArcRenderContribution();\nexport const defaultArcTextureRenderContribution = defaultBaseTextureRenderContribution;\nexport const defaultArcBackgroundRenderContribution = defaultBaseBackgroundRenderContribution;\n"]}
1
+ {"version":3,"sources":["../src/render/contributions/render/contributions/arc-contribution-render.ts"],"names":[],"mappings":"AAWA,OAAO,EAAE,eAAe,EAAE,MAAM,iCAAiC,CAAC;AAClE,OAAO,EAAE,uCAAuC,EAAE,MAAM,4BAA4B,CAAC;AACrF,OAAO,EAAE,WAAW,EAAE,MAAM,UAAU,CAAC;AACvC,OAAO,EAAE,0BAA0B,EAAE,MAAM,0BAA0B,CAAC;AACtE,OAAO,EAAE,oCAAoC,EAAE,MAAM,oCAAoC,CAAC;AAE1F,MAAM,OAAO,4BAA4B;IAAzC;QACE,SAAI,GAA+B,0BAA0B,CAAC,eAAe,CAAC;QAC9E,aAAQ,GAAY,IAAI,CAAC;QACzB,UAAK,GAAW,CAAC,CAAC;IAqFpB,CAAC;IApFC,SAAS,CACP,GAAS,EACT,OAAmB,EACnB,CAAS,EACT,CAAS,EACT,MAAe,EACf,QAAiB,EACjB,QAAiB,EACjB,QAAiB,EACjB,YAA4C,EAC5C,WAAyB,EACzB,MAIY,EACZ,QAIY;QAEZ,MAAM,EAAE,WAAW,EAAE,WAAW,EAAE,GAAG,GAAG,CAAC,SAAS,CAAC;QACnD,MAAM,aAAa,GAAG,WAAW,IAAI,WAAW,CAAC,OAAO,KAAK,KAAK,CAAC;QACnE,MAAM,aAAa,GAAG,WAAW,IAAI,WAAW,CAAC,OAAO,KAAK,KAAK,CA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Aa,CAAC,CAAC;QAC1D,GAAG,CAAC,aAAa,CAAC,EAAE,WAAW,EAAE,WAAW,EAAE,WAAW,EAAE,WAAW,EAAE,UAAU,EAAE,QAAQ,EAAS,CAAC,CAAC;IACzG,CAAC;CACF;AAED,MAAM,CAAC,MAAM,4BAA4B,GAAG,IAAI,4BAA4B,EAAE,CAAC;AAC/E,MAAM,CAAC,MAAM,mCAAmC,GAAG,oCAAoC,CAAC;AACxF,MAAM,CAAC,MAAM,sCAAsC,GAAG,uCAAuC,CAAC","file":"arc-contribution-render.js","sourcesContent":["import type {\n IGraphicAttribute,\n IContext2d,\n IMarkAttribute,\n IArc,\n IArcGraphicAttribute,\n IThemeAttribute,\n IArcRenderContribution,\n IDrawContext,\n IBorderStyle\n} from '../../../../interface';\nimport { getScaledStroke } from '../../../../common/canvas-utils';\nimport { defaultBaseBackgroundRenderContribution } from './base-contribution-render';\nimport { drawArcPath } from '../utils';\nimport { BaseRenderContributionTime } from '../../../../common/enums';\nimport { defaultBaseTextureRenderContribution } from './base-texture-contribution-render';\n\nexport class DefaultArcRenderContribution implements IArcRenderContribution {\n time: BaseRenderContributionTime = BaseRenderContributionTime.afterFillStroke;\n useStyle: boolean = true;\n order: number = 0;\n drawShape(\n arc: IArc,\n context: IContext2d,\n x: number,\n y: number,\n doFill: boolean,\n doStroke: boolean,\n fVisible: boolean,\n sVisible: boolean,\n arcAttribute: Required<IArcGraphicAttribute>,\n drawContext: IDrawContext,\n fillCb?: (\n ctx: IContext2d,\n markAttribute: Partial<IMarkAttribute & IGraphicAttribute>,\n themeAttribute: IThemeAttribute\n ) => boolean,\n strokeCb?: (\n ctx: IContext2d,\n markAttribute: Partial<IMarkAttribute & IGraphicAttribute>,\n themeAttribute: IThemeAttribute\n ) => boolean\n ) {\n const { outerBorder, innerBorder } = arc.attribute;\n const doOuterBorder = outerBorder && outerBorder.visible !== false;\n const doInnerBorder = innerBorder && innerBorder.visible !== false;\n if (!(doOuterBorder || doInnerBorder)) {\n return;\n }\n const {\n innerPadding = arcAttribute.innerPadding,\n outerPadding = arcAttribute.outerPadding,\n startAngle = arcAttribute.startAngle,\n endAngle = arcAttribute.endAngle,\n opacity = arcAttribute.opacity,\n x: originX = arcAttribute.x,\n y: originY = arcAttribute.y,\n scaleX = arcAttribute.scaleX,\n scaleY = arcAttribute.scaleY,\n keepStrokeScale = arcAttribute.keepStrokeScale\n } = arc.attribute;\n let { innerRadius = arcAttribute.innerRadius, outerRadius = arcAttribute.outerRadius } = arc.attribute;\n outerRadius += outerPadding;\n innerRadius -= innerPadding;\n\n const renderBorder = (borderStyle: Partial<IBorderStyle>, key: 'outerBorder' | 'innerBorder') => {\n const doStroke = !!(borderStyle && borderStyle.stroke);\n\n const { distance = arcAttribute[key].distance } = borderStyle;\n const d = keepStrokeScale ? (distance as number) : getScaledStroke(context, distance as number, context.dpr);\n const deltaAngle = (distance as number) / outerRadius;\n const sign = key === 'outerBorder' ? 1 : -1;\n arc.setAttributes({\n outerRadius: outerRadius + sign * d,\n innerRadius: innerRadius - sign * d,\n startAngle: startAngle - sign * deltaAngle,\n endAngle: endAngle + sign * deltaAngle\n } as any);\n context.beginPath();\n drawArcPath(arc, context, x, y, outerRadius + sign * d, innerRadius - sign * d);\n // shadow\n context.setShadowBlendStyle && context.setShadowBlendStyle(arc, arc.attribute, arcAttribute);\n\n if (strokeCb) {\n strokeCb(context, borderStyle, arcAttribute[key]);\n } else if (doStroke) {\n // 存在stroke\n const lastOpacity = (arcAttribute[key] as any).opacity;\n (arcAttribute[key] as any).opacity = opacity;\n context.setStrokeStyle(\n arc,\n borderStyle,\n (originX - x) / scaleX,\n (originY - y) / scaleY,\n arcAttribute[key] as any\n );\n (arcAttribute[key] as any).opacity = lastOpacity;\n context.stroke();\n }\n };\n\n doOuterBorder && renderBorder(outerBorder, 'outerBorder');\n doInnerBorder && renderBorder(innerBorder, 'innerBorder');\n arc.setAttributes({ outerRadius: outerRadius, innerRadius: innerRadius, startAngle, endAngle } as any);\n }\n}\n\nexport const defaultArcRenderContribution = new DefaultArcRenderContribution();\nexport const defaultArcTextureRenderContribution = defaultBaseTextureRenderContribution;\nexport const defaultArcBackgroundRenderContribution = defaultBaseBackgroundRenderContribution;\n"]}
@@ -13,8 +13,8 @@ export class DefaultCircleRenderContribution {
13
13
  drawShape(circle, context, x, y, doFill, doStroke, fVisible, sVisible, circleAttribute, drawContext, fillCb, strokeCb) {
14
14
  const {outerBorder: outerBorder, innerBorder: innerBorder} = circle.attribute, doOuterBorder = outerBorder && !1 !== outerBorder.visible, doInnerBorder = innerBorder && !1 !== innerBorder.visible;
15
15
  if (!doOuterBorder && !doInnerBorder) return;
16
- const {radius: radius = circleAttribute.radius, startAngle: startAngle = circleAttribute.startAngle, endAngle: endAngle = circleAttribute.endAngle, opacity: opacity = circleAttribute.opacity, x: originX = circleAttribute.x, y: originY = circleAttribute.y, scaleX: scaleX = circleAttribute.scaleX, scaleY: scaleY = circleAttribute.scaleY} = circle.attribute, renderBorder = (borderStyle, key) => {
17
- const doStroke = !(!borderStyle || !borderStyle.stroke), {distance: distance = circleAttribute[key].distance} = borderStyle, d = getScaledStroke(context, distance, context.dpr), sign = "outerBorder" === key ? 1 : -1;
16
+ const {radius: radius = circleAttribute.radius, startAngle: startAngle = circleAttribute.startAngle, endAngle: endAngle = circleAttribute.endAngle, opacity: opacity = circleAttribute.opacity, x: originX = circleAttribute.x, y: originY = circleAttribute.y, scaleX: scaleX = circleAttribute.scaleX, scaleY: scaleY = circleAttribute.scaleY, keepStrokeScale: keepStrokeScale = circleAttribute.keepStrokeScale} = circle.attribute, renderBorder = (borderStyle, key) => {
17
+ const doStroke = !(!borderStyle || !borderStyle.stroke), {distance: distance = circleAttribute[key].distance} = borderStyle, d = keepStrokeScale ? distance : getScaledStroke(context, distance, context.dpr), sign = "outerBorder" === key ? 1 : -1;
18
18
  if (context.beginPath(), context.arc(x, y, radius + sign * d, startAngle, endAngle),
19
19
  context.closePath(), context.setShadowBlendStyle && context.setShadowBlendStyle(circle, circle.attribute, circleAttribute),
20
20
  strokeCb) strokeCb(context, borderStyle, circleAttribute[key]); else if (doStroke) {
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/render/contributions/render/contributions/circle-contribution-render.ts"],"names":[],"mappings":"AAWA,OAAO,EAAE,eAAe,EAAE,MAAM,iCAAiC,CAAC;AAClE,OAAO,EAAE,uCAAuC,EAAE,MAAM,4BAA4B,CAAC;AACrF,OAAO,EAAE,0BAA0B,EAAE,MAAM,0BAA0B,CAAC;AACtE,OAAO,EAAE,oCAAoC,EAAE,MAAM,oCAAoC,CAAC;AAE1F,MAAM,OAAO,+BAA+B;IAA5C;QACE,SAAI,GAA+B,0BAA0B,CAAC,eAAe,CAAC;QAC9E,aAAQ,GAAY,IAAI,CAAC;QACzB,UAAK,GAAW,CAAC,CAAC;IA0EpB,CAAC;IAzEC,SAAS,CACP,MAAe,EACf,OAAmB,EACnB,CAAS,EACT,CAAS,EACT,MAAe,EACf,QAAiB,EACjB,QAAiB,EACjB,QAAiB,EACjB,eAAkD,EAClD,WAAyB,EACzB,MAIY,EACZ,QAIY;QAEZ,MAAM,EAAE,WAAW,EAAE,WAAW,EAAE,GAAG,MAAM,CAAC,SAAS,CAAC;QACtD,MAAM,aAAa,GAAG,WAAW,IAAI,WAAW,CAAC,OAAO,KAAK,KAAK,CAAC;QACnE,MAAM,aAAa,GAAG,WAAW,IAAI,WAAW,CAAC,OAAO,KAAK,KAAK,CAAC;QACnE,IAAI,CAAC,CAAC,aAAa,IAAI,aAAa,CAAC,EAAE;YACrC,OAAO;SACR;QACD,MAAM,EACJ,MAAM,GAAG,eAAe,CAAC,MAAM,EAC/B,UAAU,GAAG,eAAe,CAAC,UAAU,EACvC,QAAQ,GAAG,eAAe,CAAC,QAAQ,EACnC,OAAO,GAAG,eAAe,CAAC,OAAO,EACjC,CAAC,EAAE,OAAO,GAAG,eAAe,CAAC,CAAC,EAC9B,CAAC,EAAE,OAAO,GAAG,eAAe,CAAC,CAAC,EAC9B,MA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AAG,CAAC,CAAC,GAAG,MAAM,EACtB,eAAe,CAAC,GAAG,CAAQ,CAC5B,CAAC;gBACD,eAAe,CAAC,GAAG,CAAS,CAAC,OAAO,GAAG,WAAW,CAAC;gBACpD,OAAO,CAAC,MAAM,EAAE,CAAC;aAClB;QACH,CAAC,CAAC;QAEF,aAAa,IAAI,YAAY,CAAC,WAAW,EAAE,aAAa,CAAC,CAAC;QAC1D,aAAa,IAAI,YAAY,CAAC,WAAW,EAAE,aAAa,CAAC,CAAC;IAC5D,CAAC;CACF;AAED,MAAM,CAAC,MAAM,+BAA+B,GAAG,IAAI,+BAA+B,EAAE,CAAC;AACrF,MAAM,CAAC,MAAM,sCAAsC,GAAG,oCAAoC,CAAC;AAC3F,MAAM,CAAC,MAAM,yCAAyC,GAAG,uCAAuC,CAAC","file":"circle-contribution-render.js","sourcesContent":["import type {\n IGraphicAttribute,\n IContext2d,\n IMarkAttribute,\n ICircle,\n ICircleGraphicAttribute,\n IThemeAttribute,\n ICircleRenderContribution,\n IDrawContext,\n IBorderStyle\n} from '../../../../interface';\nimport { getScaledStroke } from '../../../../common/canvas-utils';\nimport { defaultBaseBackgroundRenderContribution } from './base-contribution-render';\nimport { BaseRenderContributionTime } from '../../../../common/enums';\nimport { defaultBaseTextureRenderContribution } from './base-texture-contribution-render';\n\nexport class DefaultCircleRenderContribution implements ICircleRenderContribution {\n time: BaseRenderContributionTime = BaseRenderContributionTime.afterFillStroke;\n useStyle: boolean = true;\n order: number = 0;\n drawShape(\n circle: ICircle,\n context: IContext2d,\n x: number,\n y: number,\n doFill: boolean,\n doStroke: boolean,\n fVisible: boolean,\n sVisible: boolean,\n circleAttribute: Required<ICircleGraphicAttribute>,\n drawContext: IDrawContext,\n fillCb?: (\n ctx: IContext2d,\n markAttribute: Partial<IMarkAttribute & IGraphicAttribute>,\n themeAttribute: IThemeAttribute\n ) => boolean,\n strokeCb?: (\n ctx: IContext2d,\n markAttribute: Partial<IMarkAttribute & IGraphicAttribute>,\n themeAttribute: IThemeAttribute\n ) => boolean\n ) {\n const { outerBorder, innerBorder } = circle.attribute;\n const doOuterBorder = outerBorder && outerBorder.visible !== false;\n const doInnerBorder = innerBorder && innerBorder.visible !== false;\n if (!(doOuterBorder || doInnerBorder)) {\n return;\n }\n const {\n radius = circleAttribute.radius,\n startAngle = circleAttribute.startAngle,\n endAngle = circleAttribute.endAngle,\n opacity = circleAttribute.opacity,\n x: originX = circleAttribute.x,\n y: originY = circleAttribute.y,\n scaleX = circleAttribute.scaleX,\n scaleY = circleAttribute.scaleY\n } = circle.attribute;\n\n const renderBorder = (borderStyle: Partial<IBorderStyle>, key: 'outerBorder' | 'innerBorder') => {\n const doStroke = !!(borderStyle && borderStyle.stroke);\n\n const { distance = circleAttribute[key].distance } = borderStyle;\n const d = getScaledStroke(context, distance as number, context.dpr);\n const sign = key === 'outerBorder' ? 1 : -1;\n context.beginPath();\n context.arc(x, y, radius + sign * d, startAngle, endAngle);\n context.closePath();\n\n // shadow\n context.setShadowBlendStyle && context.setShadowBlendStyle(circle, circle.attribute, circleAttribute);\n\n if (strokeCb) {\n strokeCb(context, borderStyle, circleAttribute[key]);\n } else if (doStroke) {\n // 存在stroke\n const lastOpacity = (circleAttribute[key] as any).opacity;\n (circleAttribute[key] as any).opacity = opacity;\n context.setStrokeStyle(\n circle,\n borderStyle,\n (originX - x) / scaleX,\n (originY - y) / scaleY,\n circleAttribute[key] as any\n );\n (circleAttribute[key] as any).opacity = lastOpacity;\n context.stroke();\n }\n };\n\n doOuterBorder && renderBorder(outerBorder, 'outerBorder');\n doInnerBorder && renderBorder(innerBorder, 'innerBorder');\n }\n}\n\nexport const defaultCircleRenderContribution = new DefaultCircleRenderContribution();\nexport const defaultCircleTextureRenderContribution = defaultBaseTextureRenderContribution;\nexport const defaultCircleBackgroundRenderContribution = defaultBaseBackgroundRenderContribution;\n"]}
1
+ {"version":3,"sources":["../src/render/contributions/render/contributions/circle-contribution-render.ts"],"names":[],"mappings":"AAWA,OAAO,EAA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AAe,CAAC,GAAG,CAAS,CAAC,OAAO,GAAG,WAAW,CAAC;gBACpD,OAAO,CAAC,MAAM,EAAE,CAAC;aAClB;QACH,CAAC,CAAC;QAEF,aAAa,IAAI,YAAY,CAAC,WAAW,EAAE,aAAa,CAAC,CAAC;QAC1D,aAAa,IAAI,YAAY,CAAC,WAAW,EAAE,aAAa,CAAC,CAAC;IAC5D,CAAC;CACF;AAED,MAAM,CAAC,MAAM,+BAA+B,GAAG,IAAI,+BAA+B,EAAE,CAAC;AACrF,MAAM,CAAC,MAAM,sCAAsC,GAAG,oCAAoC,CAAC;AAC3F,MAAM,CAAC,MAAM,yCAAyC,GAAG,uCAAuC,CAAC","file":"circle-contribution-render.js","sourcesContent":["import type {\n IGraphicAttribute,\n IContext2d,\n IMarkAttribute,\n ICircle,\n ICircleGraphicAttribute,\n IThemeAttribute,\n ICircleRenderContribution,\n IDrawContext,\n IBorderStyle\n} from '../../../../interface';\nimport { getScaledStroke } from '../../../../common/canvas-utils';\nimport { defaultBaseBackgroundRenderContribution } from './base-contribution-render';\nimport { BaseRenderContributionTime } from '../../../../common/enums';\nimport { defaultBaseTextureRenderContribution } from './base-texture-contribution-render';\n\nexport class DefaultCircleRenderContribution implements ICircleRenderContribution {\n time: BaseRenderContributionTime = BaseRenderContributionTime.afterFillStroke;\n useStyle: boolean = true;\n order: number = 0;\n drawShape(\n circle: ICircle,\n context: IContext2d,\n x: number,\n y: number,\n doFill: boolean,\n doStroke: boolean,\n fVisible: boolean,\n sVisible: boolean,\n circleAttribute: Required<ICircleGraphicAttribute>,\n drawContext: IDrawContext,\n fillCb?: (\n ctx: IContext2d,\n markAttribute: Partial<IMarkAttribute & IGraphicAttribute>,\n themeAttribute: IThemeAttribute\n ) => boolean,\n strokeCb?: (\n ctx: IContext2d,\n markAttribute: Partial<IMarkAttribute & IGraphicAttribute>,\n themeAttribute: IThemeAttribute\n ) => boolean\n ) {\n const { outerBorder, innerBorder } = circle.attribute;\n const doOuterBorder = outerBorder && outerBorder.visible !== false;\n const doInnerBorder = innerBorder && innerBorder.visible !== false;\n if (!(doOuterBorder || doInnerBorder)) {\n return;\n }\n const {\n radius = circleAttribute.radius,\n startAngle = circleAttribute.startAngle,\n endAngle = circleAttribute.endAngle,\n opacity = circleAttribute.opacity,\n x: originX = circleAttribute.x,\n y: originY = circleAttribute.y,\n scaleX = circleAttribute.scaleX,\n scaleY = circleAttribute.scaleY,\n keepStrokeScale = circleAttribute.keepStrokeScale\n } = circle.attribute;\n\n const renderBorder = (borderStyle: Partial<IBorderStyle>, key: 'outerBorder' | 'innerBorder') => {\n const doStroke = !!(borderStyle && borderStyle.stroke);\n\n const { distance = circleAttribute[key].distance } = borderStyle;\n const d = keepStrokeScale ? (distance as number) : getScaledStroke(context, distance as number, context.dpr);\n const sign = key === 'outerBorder' ? 1 : -1;\n context.beginPath();\n context.arc(x, y, radius + sign * d, startAngle, endAngle);\n context.closePath();\n\n // shadow\n context.setShadowBlendStyle && context.setShadowBlendStyle(circle, circle.attribute, circleAttribute);\n\n if (strokeCb) {\n strokeCb(context, borderStyle, circleAttribute[key]);\n } else if (doStroke) {\n // 存在stroke\n const lastOpacity = (circleAttribute[key] as any).opacity;\n (circleAttribute[key] as any).opacity = opacity;\n context.setStrokeStyle(\n circle,\n borderStyle,\n (originX - x) / scaleX,\n (originY - y) / scaleY,\n circleAttribute[key] as any\n );\n (circleAttribute[key] as any).opacity = lastOpacity;\n context.stroke();\n }\n };\n\n doOuterBorder && renderBorder(outerBorder, 'outerBorder');\n doInnerBorder && renderBorder(innerBorder, 'innerBorder');\n }\n}\n\nexport const defaultCircleRenderContribution = new DefaultCircleRenderContribution();\nexport const defaultCircleTextureRenderContribution = defaultBaseTextureRenderContribution;\nexport const defaultCircleBackgroundRenderContribution = defaultBaseBackgroundRenderContribution;\n"]}
@@ -25,11 +25,11 @@ export class DefaultRectRenderContribution {
25
25
  drawShape(rect, context, x, y, doFill, doStroke, fVisible, sVisible, rectAttribute, drawContext, fillCb, strokeCb) {
26
26
  const {outerBorder: outerBorder, innerBorder: innerBorder} = rect.attribute, doOuterBorder = outerBorder && !1 !== outerBorder.visible, doInnerBorder = innerBorder && !1 !== innerBorder.visible;
27
27
  if (!doOuterBorder && !doInnerBorder) return;
28
- const {cornerRadius: cornerRadius = rectAttribute.cornerRadius, opacity: opacity = rectAttribute.opacity, x: originX = rectAttribute.x, y: originY = rectAttribute.y, scaleX: scaleX = rectAttribute.scaleX, scaleY: scaleY = rectAttribute.scaleY, x1: x1, y1: y1} = rect.attribute;
28
+ const {cornerRadius: cornerRadius = rectAttribute.cornerRadius, opacity: opacity = rectAttribute.opacity, x: originX = rectAttribute.x, y: originY = rectAttribute.y, scaleX: scaleX = rectAttribute.scaleX, scaleY: scaleY = rectAttribute.scaleY, x1: x1, y1: y1, keepStrokeScale: keepStrokeScale = rectAttribute.keepStrokeScale} = rect.attribute;
29
29
  let {width: width, height: height} = rect.attribute;
30
30
  width = (null != width ? width : x1 - x) || 0, height = (null != height ? height : y1 - y) || 0;
31
31
  const renderBorder = (borderStyle, key) => {
32
- const doStroke = !(!borderStyle || !borderStyle.stroke), sign = "outerBorder" === key ? -1 : 1, {distance: distance = rectAttribute[key].distance} = borderStyle, d = getScaledStroke(context, distance, context.dpr), nextX = x + sign * d, nextY = y + sign * d, dw = 2 * d;
32
+ const doStroke = !(!borderStyle || !borderStyle.stroke), sign = "outerBorder" === key ? -1 : 1, {distance: distance = rectAttribute[key].distance} = borderStyle, d = keepStrokeScale ? distance : getScaledStroke(context, distance, context.dpr), nextX = x + sign * d, nextY = y + sign * d, dw = 2 * d;
33
33
  if (0 === cornerRadius || isArray(cornerRadius) && cornerRadius.every((num => 0 === num)) ? (context.beginPath(),
34
34
  context.rect(nextX, nextY, width - sign * dw, height - sign * dw)) : (context.beginPath(),
35
35
  createRectPath(context, nextX, nextY, width - sign * dw, height - sign * dw, cornerRadius)),
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/render/contributions/render/contributions/rect-contribution-render.ts"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AED,IAAI,MAAM,CAAC,CAAC,CAAC,EAAE;YAEb,MAAM,OAAO,GAAG,MAAM,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,GAAG,OAAO,CAAC,SAAS,GAAG,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC;YAC1D,OAAO,CAAC,MAAM,CAAC,CAAC,EAAE,OAAO,CAAC,CAAC;SAC5B;aAAM;YACL,OAAO,CAAC,MAAM,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC;SACtB;QAED,OAAO,CAAC,MAAM,EAAE,CAAC;IACnB,CAAC;CACF,CAAA;AA9GY,gCAAgC;IAD5C,UAAU,EAAE;GACA,gCAAgC,CA8G5C;SA9GY,gCAAgC;AAgH7C,MAAM,CAAC,MAAM,6BAA6B,GAAG,IAAI,6BAA6B,EAAE,CAAC;AAGjF,MAAM,CAAC,MAAM,oCAAoC,GAAG,oCAAoC,CAAC;AACzF,MAAM,CAAC,MAAM,uCAAuC,GAAG,uCAAuC,CAAC","file":"rect-contribution-render.js","sourcesContent":["import { isArray } from '@visactor/vutils';\nimport { injectable } from '../../../../common/inversify-lite';\nimport type {\n IGraphicAttribute,\n IContext2d,\n IMarkAttribute,\n IRect,\n IRectGraphicAttribute,\n IThemeAttribute,\n IRectRenderContribution,\n IDrawContext,\n IBorderStyle\n} from '../../../../interface';\nimport { getScaledStroke } from '../../../../common/canvas-utils';\nimport { defaultBaseBackgroundRenderContribution } from './base-contribution-render';\nimport { createRectPath } from '../../../../common/shape/rect';\nimport { BaseRenderContributionTime } from '../../../../common/enums';\nimport { defaultBaseTextureRenderContribution } from './base-texture-contribution-render';\n\nexport class DefaultRectRenderContribution implements IRectRenderContribution {\n time: BaseRenderContributionTime = BaseRenderContributionTime.afterFillStroke;\n useStyle: boolean = true;\n order: number = 0;\n drawShape(\n rect: IRect,\n context: IContext2d,\n x: number,\n y: number,\n doFill: boolean,\n doStroke: boolean,\n fVisible: boolean,\n sVisible: boolean,\n rectAttribute: Required<IRectGraphicAttribute>,\n drawContext: IDrawContext,\n fillCb?: (\n ctx: IContext2d,\n markAttribute: Partial<IMarkAttribute & IGraphicAttribute>,\n themeAttribute: IThemeAttribute\n ) => boolean,\n strokeCb?: (\n ctx: IContext2d,\n markAttribute: Partial<IMarkAttribute & IGraphicAttribute>,\n themeAttribute: IThemeAttribute\n ) => boolean\n ) {\n const { outerBorder, innerBorder } = rect.attribute;\n const doOuterBorder = outerBorder && outerBorder.visible !== false;\n const doInnerBorder = innerBorder && innerBorder.visible !== false;\n if (!(doOuterBorder || doInnerBorder)) {\n return;\n }\n const {\n cornerRadius = rectAttribute.cornerRadius,\n opacity = rectAttribute.opacity,\n x: originX = rectAttribute.x,\n y: originY = rectAttribute.y,\n scaleX = rectAttribute.scaleX,\n scaleY = rectAttribute.scaleY,\n x1,\n y1\n } = rect.attribute;\n\n let { width, height } = rect.attribute;\n\n width = (width ?? x1 - x) || 0;\n height = (height ?? y1 - y) || 0;\n\n const renderBorder = (borderStyle: Partial<IBorderStyle>, key: 'outerBorder' | 'innerBorder') => {\n const doStroke = !!(borderStyle && borderStyle.stroke);\n\n const sign = key === 'outerBorder' ? -1 : 1;\n const { distance = rectAttribute[key].distance } = borderStyle;\n const d = getScaledStroke(context, distance as number, context.dpr);\n const nextX = x + sign * d;\n const nextY = y + sign * d;\n const dw = d * 2;\n if (cornerRadius === 0 || (isArray(cornerRadius) && (<number[]>cornerRadius).every(num => num === 0))) {\n // 不需要处理圆角\n context.beginPath();\n context.rect(nextX, nextY, width - sign * dw, height - sign * dw);\n } else {\n context.beginPath();\n\n // 测试后,cache对于重绘性能提升不大,但是在首屏有一定性能损耗,因此rect不再使用cache\n createRectPath(context, nextX, nextY, width - sign * dw, height - sign * dw, cornerRadius);\n }\n\n // shadow\n context.setShadowBlendStyle && context.setShadowBlendStyle(rect, rect.attribute, rectAttribute);\n\n if (strokeCb) {\n strokeCb(context, borderStyle, rectAttribute[key]);\n } else if (doStroke) {\n // 存在stroke\n const lastOpacity = (rectAttribute[key] as any).opacity;\n (rectAttribute[key] as any).opacity = opacity;\n context.setStrokeStyle(\n rect,\n borderStyle,\n (originX - x) / scaleX,\n (originY - y) / scaleY,\n rectAttribute[key] as any\n );\n (rectAttribute[key] as any).opacity = lastOpacity;\n context.stroke();\n }\n };\n\n doOuterBorder && renderBorder(outerBorder, 'outerBorder');\n doInnerBorder && renderBorder(innerBorder, 'innerBorder');\n }\n}\n\n@injectable()\nexport class SplitRectBeforeRenderContribution implements IRectRenderContribution {\n time: BaseRenderContributionTime = BaseRenderContributionTime.beforeFillStroke;\n useStyle: boolean = true;\n order: number = 0;\n drawShape(\n group: IRect,\n context: IContext2d,\n x: number,\n y: number,\n doFill: boolean,\n doStroke: boolean,\n fVisible: boolean,\n sVisible: boolean,\n groupAttribute: Required<IRectGraphicAttribute>,\n drawContext: IDrawContext,\n fillCb?: (\n ctx: IContext2d,\n markAttribute: Partial<IMarkAttribute & IGraphicAttribute>,\n themeAttribute: IThemeAttribute\n ) => boolean,\n strokeCb?: (\n ctx: IContext2d,\n markAttribute: Partial<IMarkAttribute & IGraphicAttribute>,\n themeAttribute: IThemeAttribute\n ) => boolean,\n doFillOrStroke?: { doFill: boolean; doStroke: boolean }\n ) {\n const { stroke = groupAttribute.stroke } = group.attribute as any;\n\n // 数组且存在为false的项目,那就不绘制\n if (Array.isArray(stroke) && stroke.some(s => s === false)) {\n doFillOrStroke.doStroke = false;\n }\n }\n}\n\n@injectable()\nexport class SplitRectAfterRenderContribution implements IRectRenderContribution {\n time: BaseRenderContributionTime = BaseRenderContributionTime.afterFillStroke;\n useStyle: boolean = true;\n order: number = 0;\n drawShape(\n rect: IRect,\n context: IContext2d,\n x: number,\n y: number,\n doFill: boolean,\n doStroke: boolean,\n fVisible: boolean,\n sVisible: boolean,\n groupAttribute: Required<IRectGraphicAttribute>,\n drawContext: IDrawContext,\n fillCb?: (\n ctx: IContext2d,\n markAttribute: Partial<IMarkAttribute & IGraphicAttribute>,\n themeAttribute: IThemeAttribute\n ) => boolean,\n strokeCb?: (\n ctx: IContext2d,\n markAttribute: Partial<IMarkAttribute & IGraphicAttribute>,\n themeAttribute: IThemeAttribute\n ) => boolean\n ) {\n const {\n x1,\n y1,\n x: originX = groupAttribute.x,\n y: originY = groupAttribute.y,\n stroke = groupAttribute.stroke,\n cornerRadius = groupAttribute.cornerRadius\n } = rect.attribute as any;\n\n let { width, height } = rect.attribute;\n width = (width ?? x1 - originX) || 0;\n height = (height ?? y1 - originY) || 0;\n\n // 不是数组\n if (!(Array.isArray(stroke) && stroke.some(s => s === false))) {\n return;\n }\n\n context.setStrokeStyle(rect, rect.attribute, x, y, groupAttribute);\n\n // 带不同stroke边框\n if (!(cornerRadius === 0 || (isArray(cornerRadius) && (<number[]>cornerRadius).every(num => num === 0)))) {\n let lastStrokeI = 0;\n let lastStroke: any;\n createRectPath(\n context,\n x,\n y,\n width,\n height,\n cornerRadius,\n new Array(4).fill(0).map((_, i) => (x1: number, y1: number, x2: number, y2: number) => {\n if (stroke[i]) {\n if (!(lastStrokeI === i - 1 && stroke[i] === lastStroke)) {\n context.setStrokeStyle(rect, { ...rect.attribute, stroke: stroke[i] }, x, y, groupAttribute);\n context.beginPath();\n context.moveTo(x1, y1);\n lastStroke = stroke[i];\n }\n lastStrokeI = i;\n context.lineTo(x2, y2);\n context.stroke();\n if (i === 3) {\n context.beginPath();\n }\n }\n })\n );\n context.stroke();\n return;\n }\n\n // 单独处理每条边界,目前不考虑圆角\n context.beginPath();\n context.moveTo(x, y);\n // top\n if (stroke[0]) {\n context.lineTo(x + width, y);\n } else {\n context.moveTo(x + width, y);\n }\n // right\n if (stroke[1]) {\n context.lineTo(x + width, y + height);\n } else {\n context.moveTo(x + width, y + height);\n }\n // bottom\n if (stroke[2]) {\n context.lineTo(x, y + height);\n } else {\n context.moveTo(x, y + height);\n }\n // left\n if (stroke[3]) {\n // 没有close path是,起点和终点不连续,需要调整y保证不出现缺口\n const adjustY = stroke[0] ? y - context.lineWidth / 2 : y;\n context.lineTo(x, adjustY);\n } else {\n context.moveTo(x, y);\n }\n\n context.stroke();\n }\n}\n\nexport const defaultRectRenderContribution = new DefaultRectRenderContribution();\n// export const splitRectBeforeRenderContribution = new SplitRectBeforeRenderContribution();\n// export const splitRectAfterRenderContribution = new SplitRectAfterRenderContribution();\nexport const defaultRectTextureRenderContribution = defaultBaseTextureRenderContribution;\nexport const defaultRectBackgroundRenderContribution = defaultBaseBackgroundRenderContribution;\n"]}
1
+ {"version":3,"sources":["../src/render/contributions/render/contributions/rect-contribution-render.ts"],"names":[],"mappings":";;;;;;AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,kBAAkB,CAAC;AAC3C,OAAO,EAAE,UAAU,EAAE,MAAM,mCAAmC,CAAC;AAY/D,OAAO,EAAE,eAAe,EAAE,MAAM,iCAAiC,CAAC;AAClE,OAAO,EAAE,uCAAuC,EAAE,MAAM,4BAA4B,CAAC;AACrF,OAAO,EAAE,cAAc,EAAE,MAAM,+BAA+B,CAAC;AAC/D,OAAO,EAAE,0BAA0B,EAAE,MAAM,0BAA0B,CAAC;AACtE,OAAO,EAAE,oCAAoC,EAAE,MAAM,oCAAoC,CAAC;AAE1F,MAAM,OAAO,6BAA6B;IAA1C;QACE,SAAI,GAA+B,0BAA0B,CAAC,eAAe,CAAC;QAC9E,aAAQ,GAAY,IAAI,CAAC;QACzB,UAAK,GAAW,CAAC,CAAC;IA0FpB,CAAC;IAzFC,SAAS,CACP,IAAW,EACX,OAAmB,EACnB,CAAS,EACT,CAAS,EACT,MAAe,EACf,QAAiB,EACjB,QAAiB,EACjB,QAAiB,EACjB,aAA8C,EAC9C,WAAyB,EACzB,MAIY,EACZ,QAIY;QAEZ,MAAM,EAAE,WAAW,EAAE,WAAW,EAAE,GAAG,IAAI,CAAC,SAAS,CAAC;QACpD,MAAM,aAAa,GAAG,WAAW,IAAI,WAAW,CAAC,OAAO,KAAK,KAAK,CAAC;QACnE,MAAM,aAAa,GAAG,WAAW,IAAI,WAAW,CAAC,O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AI,MAAM,CAAC,CAAC,CAAC,EAAE;YACb,OAAO,CAAC,MAAM,CAAC,CAAC,GAAG,KAAK,EAAE,CAAC,GAAG,MAAM,CAAC,CAAC;SACvC;aAAM;YACL,OAAO,CAAC,MAAM,CAAC,CAAC,GAAG,KAAK,EAAE,CAAC,GAAG,MAAM,CAAC,CAAC;SACvC;QAED,IAAI,MAAM,CAAC,CAAC,CAAC,EAAE;YACb,OAAO,CAAC,MAAM,CAAC,CAAC,EAAE,CAAC,GAAG,MAAM,CAAC,CAAC;SAC/B;aAAM;YACL,OAAO,CAAC,MAAM,CAAC,CAAC,EAAE,CAAC,GAAG,MAAM,CAAC,CAAC;SAC/B;QAED,IAAI,MAAM,CAAC,CAAC,CAAC,EAAE;YAEb,MAAM,OAAO,GAAG,MAAM,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,GAAG,OAAO,CAAC,SAAS,GAAG,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC;YAC1D,OAAO,CAAC,MAAM,CAAC,CAAC,EAAE,OAAO,CAAC,CAAC;SAC5B;aAAM;YACL,OAAO,CAAC,MAAM,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC;SACtB;QAED,OAAO,CAAC,MAAM,EAAE,CAAC;IACnB,CAAC;CACF,CAAA;AA9GY,gCAAgC;IAD5C,UAAU,EAAE;GACA,gCAAgC,CA8G5C;SA9GY,gCAAgC;AAgH7C,MAAM,CAAC,MAAM,6BAA6B,GAAG,IAAI,6BAA6B,EAAE,CAAC;AAGjF,MAAM,CAAC,MAAM,oCAAoC,GAAG,oCAAoC,CAAC;AACzF,MAAM,CAAC,MAAM,uCAAuC,GAAG,uCAAuC,CAAC","file":"rect-contribution-render.js","sourcesContent":["import { isArray } from '@visactor/vutils';\nimport { injectable } from '../../../../common/inversify-lite';\nimport type {\n IGraphicAttribute,\n IContext2d,\n IMarkAttribute,\n IRect,\n IRectGraphicAttribute,\n IThemeAttribute,\n IRectRenderContribution,\n IDrawContext,\n IBorderStyle\n} from '../../../../interface';\nimport { getScaledStroke } from '../../../../common/canvas-utils';\nimport { defaultBaseBackgroundRenderContribution } from './base-contribution-render';\nimport { createRectPath } from '../../../../common/shape/rect';\nimport { BaseRenderContributionTime } from '../../../../common/enums';\nimport { defaultBaseTextureRenderContribution } from './base-texture-contribution-render';\n\nexport class DefaultRectRenderContribution implements IRectRenderContribution {\n time: BaseRenderContributionTime = BaseRenderContributionTime.afterFillStroke;\n useStyle: boolean = true;\n order: number = 0;\n drawShape(\n rect: IRect,\n context: IContext2d,\n x: number,\n y: number,\n doFill: boolean,\n doStroke: boolean,\n fVisible: boolean,\n sVisible: boolean,\n rectAttribute: Required<IRectGraphicAttribute>,\n drawContext: IDrawContext,\n fillCb?: (\n ctx: IContext2d,\n markAttribute: Partial<IMarkAttribute & IGraphicAttribute>,\n themeAttribute: IThemeAttribute\n ) => boolean,\n strokeCb?: (\n ctx: IContext2d,\n markAttribute: Partial<IMarkAttribute & IGraphicAttribute>,\n themeAttribute: IThemeAttribute\n ) => boolean\n ) {\n const { outerBorder, innerBorder } = rect.attribute;\n const doOuterBorder = outerBorder && outerBorder.visible !== false;\n const doInnerBorder = innerBorder && innerBorder.visible !== false;\n if (!(doOuterBorder || doInnerBorder)) {\n return;\n }\n const {\n cornerRadius = rectAttribute.cornerRadius,\n opacity = rectAttribute.opacity,\n x: originX = rectAttribute.x,\n y: originY = rectAttribute.y,\n scaleX = rectAttribute.scaleX,\n scaleY = rectAttribute.scaleY,\n x1,\n y1,\n keepStrokeScale = rectAttribute.keepStrokeScale\n } = rect.attribute;\n\n let { width, height } = rect.attribute;\n\n width = (width ?? x1 - x) || 0;\n height = (height ?? y1 - y) || 0;\n\n const renderBorder = (borderStyle: Partial<IBorderStyle>, key: 'outerBorder' | 'innerBorder') => {\n const doStroke = !!(borderStyle && borderStyle.stroke);\n\n const sign = key === 'outerBorder' ? -1 : 1;\n const { distance = rectAttribute[key].distance } = borderStyle;\n const d = keepStrokeScale ? (distance as number) : getScaledStroke(context, distance as number, context.dpr);\n const nextX = x + sign * d;\n const nextY = y + sign * d;\n const dw = d * 2;\n if (cornerRadius === 0 || (isArray(cornerRadius) && (<number[]>cornerRadius).every(num => num === 0))) {\n // 不需要处理圆角\n context.beginPath();\n context.rect(nextX, nextY, width - sign * dw, height - sign * dw);\n } else {\n context.beginPath();\n\n // 测试后,cache对于重绘性能提升不大,但是在首屏有一定性能损耗,因此rect不再使用cache\n createRectPath(context, nextX, nextY, width - sign * dw, height - sign * dw, cornerRadius);\n }\n\n // shadow\n context.setShadowBlendStyle && context.setShadowBlendStyle(rect, rect.attribute, rectAttribute);\n\n if (strokeCb) {\n strokeCb(context, borderStyle, rectAttribute[key]);\n } else if (doStroke) {\n // 存在stroke\n const lastOpacity = (rectAttribute[key] as any).opacity;\n (rectAttribute[key] as any).opacity = opacity;\n context.setStrokeStyle(\n rect,\n borderStyle,\n (originX - x) / scaleX,\n (originY - y) / scaleY,\n rectAttribute[key] as any\n );\n (rectAttribute[key] as any).opacity = lastOpacity;\n context.stroke();\n }\n };\n\n doOuterBorder && renderBorder(outerBorder, 'outerBorder');\n doInnerBorder && renderBorder(innerBorder, 'innerBorder');\n }\n}\n\n@injectable()\nexport class SplitRectBeforeRenderContribution implements IRectRenderContribution {\n time: BaseRenderContributionTime = BaseRenderContributionTime.beforeFillStroke;\n useStyle: boolean = true;\n order: number = 0;\n drawShape(\n group: IRect,\n context: IContext2d,\n x: number,\n y: number,\n doFill: boolean,\n doStroke: boolean,\n fVisible: boolean,\n sVisible: boolean,\n groupAttribute: Required<IRectGraphicAttribute>,\n drawContext: IDrawContext,\n fillCb?: (\n ctx: IContext2d,\n markAttribute: Partial<IMarkAttribute & IGraphicAttribute>,\n themeAttribute: IThemeAttribute\n ) => boolean,\n strokeCb?: (\n ctx: IContext2d,\n markAttribute: Partial<IMarkAttribute & IGraphicAttribute>,\n themeAttribute: IThemeAttribute\n ) => boolean,\n doFillOrStroke?: { doFill: boolean; doStroke: boolean }\n ) {\n const { stroke = groupAttribute.stroke } = group.attribute as any;\n\n // 数组且存在为false的项目,那就不绘制\n if (Array.isArray(stroke) && stroke.some(s => s === false)) {\n doFillOrStroke.doStroke = false;\n }\n }\n}\n\n@injectable()\nexport class SplitRectAfterRenderContribution implements IRectRenderContribution {\n time: BaseRenderContributionTime = BaseRenderContributionTime.afterFillStroke;\n useStyle: boolean = true;\n order: number = 0;\n drawShape(\n rect: IRect,\n context: IContext2d,\n x: number,\n y: number,\n doFill: boolean,\n doStroke: boolean,\n fVisible: boolean,\n sVisible: boolean,\n groupAttribute: Required<IRectGraphicAttribute>,\n drawContext: IDrawContext,\n fillCb?: (\n ctx: IContext2d,\n markAttribute: Partial<IMarkAttribute & IGraphicAttribute>,\n themeAttribute: IThemeAttribute\n ) => boolean,\n strokeCb?: (\n ctx: IContext2d,\n markAttribute: Partial<IMarkAttribute & IGraphicAttribute>,\n themeAttribute: IThemeAttribute\n ) => boolean\n ) {\n const {\n x1,\n y1,\n x: originX = groupAttribute.x,\n y: originY = groupAttribute.y,\n stroke = groupAttribute.stroke,\n cornerRadius = groupAttribute.cornerRadius\n } = rect.attribute as any;\n\n let { width, height } = rect.attribute;\n width = (width ?? x1 - originX) || 0;\n height = (height ?? y1 - originY) || 0;\n\n // 不是数组\n if (!(Array.isArray(stroke) && stroke.some(s => s === false))) {\n return;\n }\n\n context.setStrokeStyle(rect, rect.attribute, x, y, groupAttribute);\n\n // 带不同stroke边框\n if (!(cornerRadius === 0 || (isArray(cornerRadius) && (<number[]>cornerRadius).every(num => num === 0)))) {\n let lastStrokeI = 0;\n let lastStroke: any;\n createRectPath(\n context,\n x,\n y,\n width,\n height,\n cornerRadius,\n new Array(4).fill(0).map((_, i) => (x1: number, y1: number, x2: number, y2: number) => {\n if (stroke[i]) {\n if (!(lastStrokeI === i - 1 && stroke[i] === lastStroke)) {\n context.setStrokeStyle(rect, { ...rect.attribute, stroke: stroke[i] }, x, y, groupAttribute);\n context.beginPath();\n context.moveTo(x1, y1);\n lastStroke = stroke[i];\n }\n lastStrokeI = i;\n context.lineTo(x2, y2);\n context.stroke();\n if (i === 3) {\n context.beginPath();\n }\n }\n })\n );\n context.stroke();\n return;\n }\n\n // 单独处理每条边界,目前不考虑圆角\n context.beginPath();\n context.moveTo(x, y);\n // top\n if (stroke[0]) {\n context.lineTo(x + width, y);\n } else {\n context.moveTo(x + width, y);\n }\n // right\n if (stroke[1]) {\n context.lineTo(x + width, y + height);\n } else {\n context.moveTo(x + width, y + height);\n }\n // bottom\n if (stroke[2]) {\n context.lineTo(x, y + height);\n } else {\n context.moveTo(x, y + height);\n }\n // left\n if (stroke[3]) {\n // 没有close path是,起点和终点不连续,需要调整y保证不出现缺口\n const adjustY = stroke[0] ? y - context.lineWidth / 2 : y;\n context.lineTo(x, adjustY);\n } else {\n context.moveTo(x, y);\n }\n\n context.stroke();\n }\n}\n\nexport const defaultRectRenderContribution = new DefaultRectRenderContribution();\n// export const splitRectBeforeRenderContribution = new SplitRectBeforeRenderContribution();\n// export const splitRectAfterRenderContribution = new SplitRectAfterRenderContribution();\nexport const defaultRectTextureRenderContribution = defaultBaseTextureRenderContribution;\nexport const defaultRectBackgroundRenderContribution = defaultBaseBackgroundRenderContribution;\n"]}
@@ -15,8 +15,8 @@ export class DefaultSymbolRenderContribution {
15
15
  if (!parsedPath) return;
16
16
  const {outerBorder: outerBorder, innerBorder: innerBorder} = symbol.attribute, doOuterBorder = outerBorder && !1 !== outerBorder.visible, doInnerBorder = innerBorder && !1 !== innerBorder.visible;
17
17
  if (!doOuterBorder && !doInnerBorder) return;
18
- const {size: size = symbolAttribute.size, opacity: opacity = symbolAttribute.opacity, x: originX = symbolAttribute.x, y: originY = symbolAttribute.y, scaleX: scaleX = symbolAttribute.scaleX, scaleY: scaleY = symbolAttribute.scaleY} = symbol.attribute, renderBorder = (borderStyle, key) => {
19
- const doStroke = !(!borderStyle || !borderStyle.stroke), {distance: distance = symbolAttribute[key].distance} = borderStyle, d = getScaledStroke(context, distance, context.dpr), sign = "outerBorder" === key ? 1 : -1;
18
+ const {size: size = symbolAttribute.size, opacity: opacity = symbolAttribute.opacity, x: originX = symbolAttribute.x, y: originY = symbolAttribute.y, scaleX: scaleX = symbolAttribute.scaleX, scaleY: scaleY = symbolAttribute.scaleY, keepStrokeScale: keepStrokeScale = symbolAttribute.keepStrokeScale} = symbol.attribute, renderBorder = (borderStyle, key) => {
19
+ const doStroke = !(!borderStyle || !borderStyle.stroke), {distance: distance = symbolAttribute[key].distance} = borderStyle, d = keepStrokeScale ? distance : getScaledStroke(context, distance, context.dpr), sign = "outerBorder" === key ? 1 : -1;
20
20
  if (context.beginPath(), !1 === parsedPath.drawOffset(context, size, x, y, sign * d) && context.closePath(),
21
21
  context.setShadowBlendStyle && context.setShadowBlendStyle(symbol, symbol.attribute, symbolAttribute),
22
22
  strokeCb) strokeCb(context, borderStyle, symbolAttribute[key]); else if (doStroke) {
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/render/contributions/render/contributions/symbol-contribution-render.ts"],"names":[],"mappings":"AAWA,OAAO,EAAE,eAAe,EAAE,MAAM,iCAAiC,CAAC;AAClE,OAAO,EAAE,uCAAuC,EAAE,MAAM,4BAA4B,CAAC;AACrF,OAAO,EAAE,0BAA0B,EAAE,MAAM,0BAA0B,CAAC;AACtE,OAAO,EAAE,oCAAoC,EAAE,MAAM,oCAAoC,CAAC;AAE1F,MAAM,OAAO,+BAA+B;IAA5C;QACE,SAAI,GAA+B,0BAA0B,CAAC,eAAe,CAAC;QAC9E,aAAQ,GAAY,IAAI,CAAC;QACzB,UAAK,GAAW,CAAC,CAAC;IAiFpB,CAAC;IAhFC,SAAS,CACP,MAAe,EACf,OAAmB,EACnB,CAAS,EACT,CAAS,EACT,MAAe,EACf,QAAiB,EACjB,QAAiB,EACjB,QAAiB,EACjB,eAAkD,EAClD,WAAyB,EACzB,MAIY,EACZ,QAIY;QAEZ,MAAM,UAAU,GAAG,MAAM,CAAC,aAAa,EAAE,CAAC;QAE1C,IAA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C,SAAS,EAAE,CAAC;aACrB;YAGD,OAAO,CAAC,mBAAmB,IAAI,OAAO,CAAC,mBAAmB,CAAC,MAAM,EAAE,MAAM,CAAC,SAAS,EAAE,eAAe,CAAC,CAAC;YAEtG,IAAI,QAAQ,EAAE;gBACZ,QAAQ,CAAC,OAAO,EAAE,WAAW,EAAE,eAAe,CAAC,GAAG,CAAC,CAAC,CAAC;aACtD;iBAAM,IAAI,QAAQ,EAAE;gBAEnB,MAAM,WAAW,GAAI,eAAe,CAAC,GAAG,CAAS,CAAC,OAAO,CAAC;gBACzD,eAAe,CAAC,GAAG,CAAS,CAAC,OAAO,GAAG,OAAO,CAAC;gBAChD,OAAO,CAAC,cAAc,CACpB,MAAM,EACN,WAAW,EACX,CAAC,OAAO,GAAG,CAAC,CAAC,GAAG,MAAM,EACtB,CAAC,OAAO,GAAG,CAAC,CAAC,GAAG,MAAM,EACtB,eAAe,CAAC,GAAG,CAAQ,CAC5B,CAAC;gBACD,eAAe,CAAC,GAAG,CAAS,CAAC,OAAO,GAAG,WAAW,CAAC;gBACpD,OAAO,CAAC,MAAM,EAAE,CAAC;aAClB;QACH,CAAC,CAAC;QAEF,aAAa,IAAI,YAAY,CAAC,WAAW,EAAE,aAAa,CAAC,CAAC;QAC1D,aAAa,IAAI,YAAY,CAAC,WAAW,EAAE,aAAa,CAAC,CAAC;IAC5D,CAAC;CACF;AAED,MAAM,CAAC,MAAM,+BAA+B,GAAG,IAAI,+BAA+B,EAAE,CAAC;AACrF,MAAM,CAAC,MAAM,sCAAsC,GAAG,oCAAoC,CAAC;AAC3F,MAAM,CAAC,MAAM,yCAAyC,GAAG,uCAAuC,CAAC","file":"symbol-contribution-render.js","sourcesContent":["import type {\n IGraphicAttribute,\n IContext2d,\n IMarkAttribute,\n ISymbol,\n ISymbolGraphicAttribute,\n IThemeAttribute,\n ISymbolRenderContribution,\n IDrawContext,\n IBorderStyle\n} from '../../../../interface';\nimport { getScaledStroke } from '../../../../common/canvas-utils';\nimport { defaultBaseBackgroundRenderContribution } from './base-contribution-render';\nimport { BaseRenderContributionTime } from '../../../../common/enums';\nimport { defaultBaseTextureRenderContribution } from './base-texture-contribution-render';\n\nexport class DefaultSymbolRenderContribution implements ISymbolRenderContribution {\n time: BaseRenderContributionTime = BaseRenderContributionTime.afterFillStroke;\n useStyle: boolean = true;\n order: number = 0;\n drawShape(\n symbol: ISymbol,\n context: IContext2d,\n x: number,\n y: number,\n doFill: boolean,\n doStroke: boolean,\n fVisible: boolean,\n sVisible: boolean,\n symbolAttribute: Required<ISymbolGraphicAttribute>,\n drawContext: IDrawContext,\n fillCb?: (\n ctx: IContext2d,\n markAttribute: Partial<IMarkAttribute & IGraphicAttribute>,\n themeAttribute: IThemeAttribute\n ) => boolean,\n strokeCb?: (\n ctx: IContext2d,\n markAttribute: Partial<IMarkAttribute & IGraphicAttribute>,\n themeAttribute: IThemeAttribute\n ) => boolean\n ) {\n const parsedPath = symbol.getParsedPath();\n // todo: 考虑使用path\n if (!parsedPath) {\n return;\n }\n\n const { outerBorder, innerBorder } = symbol.attribute;\n const doOuterBorder = outerBorder && outerBorder.visible !== false;\n const doInnerBorder = innerBorder && innerBorder.visible !== false;\n if (!(doOuterBorder || doInnerBorder)) {\n return;\n }\n\n const {\n size = symbolAttribute.size,\n opacity = symbolAttribute.opacity,\n x: originX = symbolAttribute.x,\n y: originY = symbolAttribute.y,\n scaleX = symbolAttribute.scaleX,\n scaleY = symbolAttribute.scaleY\n } = symbol.attribute;\n\n const renderBorder = (borderStyle: Partial<IBorderStyle>, key: 'outerBorder' | 'innerBorder') => {\n const doStroke = !!(borderStyle && borderStyle.stroke);\n\n const { distance = symbolAttribute[key].distance } = borderStyle;\n const d = getScaledStroke(context, distance as number, context.dpr);\n const sign = key === 'outerBorder' ? 1 : -1;\n\n context.beginPath();\n if (parsedPath.drawOffset(context, size, x, y, sign * d) === false) {\n context.closePath();\n }\n\n // shadow\n context.setShadowBlendStyle && context.setShadowBlendStyle(symbol, symbol.attribute, symbolAttribute);\n\n if (strokeCb) {\n strokeCb(context, borderStyle, symbolAttribute[key]);\n } else if (doStroke) {\n // 存在stroke\n const lastOpacity = (symbolAttribute[key] as any).opacity;\n (symbolAttribute[key] as any).opacity = opacity;\n context.setStrokeStyle(\n symbol,\n borderStyle,\n (originX - x) / scaleX,\n (originY - y) / scaleY,\n symbolAttribute[key] as any\n );\n (symbolAttribute[key] as any).opacity = lastOpacity;\n context.stroke();\n }\n };\n\n doOuterBorder && renderBorder(outerBorder, 'outerBorder');\n doInnerBorder && renderBorder(innerBorder, 'innerBorder');\n }\n}\n\nexport const defaultSymbolRenderContribution = new DefaultSymbolRenderContribution();\nexport const defaultSymbolTextureRenderContribution = defaultBaseTextureRenderContribution;\nexport const defaultSymbolBackgroundRenderContribution = defaultBaseBackgroundRenderContribution;\n"]}
1
+ {"version":3,"sources":["../src/render/contributions/render/contributions/symbol-contribution-render.ts"],"names":[],"mappings":"AAWA,OAAO,EAAE,eAAe,EAAE,MAAM,iCAAiC,CAAC;AAClE,OAAO,EAAE,uCAAuC,EAAE,MAAM,4BAA4B,CAAC;AACrF,OAAO,EAAE,0BAA0B,EAAE,MAAM,0BAA0B,CAAC;AACtE,OAAO,EAAE,oCAAoC,EAAE,MAAM,oCAAoC,CAAC;AAE1F,MAAM,OAAO,+BAA+B;IAA5C;QACE,SAAI,GAA+B,0BAA0B,CAAC,eAAe,CAAC;QAC9E,aAAQ,GAAY,IAAI,CAAC;QACzB,UAAK,GAAW,CAAC,CAAC;IAkFpB,CAAC;IAjFC,SAAS,CACP,MAAe,EACf,OAAmB,EACnB,CAAS,EACT,CAAS,EACT,MAAe,EACf,QAAiB,EACjB,QAAiB,EACjB,QAAiB,EACjB,eAAkD,EAClD,WAAyB,EACzB,MAIY,EACZ,QAIY;QAEZ,MAAM,UAAU,GAAG,MAAM,CAAC,aAAa,EAAE,CAAC;QAE1C,IAAI,CAAC,UAAU,EAAE;YACf,OAAO;SACR;QAED,MAAM,EAAE,WAAW,EAAE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,EAAE;gBAClE,OAAO,CAAC,SAAS,EAAE,CAAC;aACrB;YAGD,OAAO,CAAC,mBAAmB,IAAI,OAAO,CAAC,mBAAmB,CAAC,MAAM,EAAE,MAAM,CAAC,SAAS,EAAE,eAAe,CAAC,CAAC;YAEtG,IAAI,QAAQ,EAAE;gBACZ,QAAQ,CAAC,OAAO,EAAE,WAAW,EAAE,eAAe,CAAC,GAAG,CAAC,CAAC,CAAC;aACtD;iBAAM,IAAI,QAAQ,EAAE;gBAEnB,MAAM,WAAW,GAAI,eAAe,CAAC,GAAG,CAAS,CAAC,OAAO,CAAC;gBACzD,eAAe,CAAC,GAAG,CAAS,CAAC,OAAO,GAAG,OAAO,CAAC;gBAChD,OAAO,CAAC,cAAc,CACpB,MAAM,EACN,WAAW,EACX,CAAC,OAAO,GAAG,CAAC,CAAC,GAAG,MAAM,EACtB,CAAC,OAAO,GAAG,CAAC,CAAC,GAAG,MAAM,EACtB,eAAe,CAAC,GAAG,CAAQ,CAC5B,CAAC;gBACD,eAAe,CAAC,GAAG,CAAS,CAAC,OAAO,GAAG,WAAW,CAAC;gBACpD,OAAO,CAAC,MAAM,EAAE,CAAC;aAClB;QACH,CAAC,CAAC;QAEF,aAAa,IAAI,YAAY,CAAC,WAAW,EAAE,aAAa,CAAC,CAAC;QAC1D,aAAa,IAAI,YAAY,CAAC,WAAW,EAAE,aAAa,CAAC,CAAC;IAC5D,CAAC;CACF;AAED,MAAM,CAAC,MAAM,+BAA+B,GAAG,IAAI,+BAA+B,EAAE,CAAC;AACrF,MAAM,CAAC,MAAM,sCAAsC,GAAG,oCAAoC,CAAC;AAC3F,MAAM,CAAC,MAAM,yCAAyC,GAAG,uCAAuC,CAAC","file":"symbol-contribution-render.js","sourcesContent":["import type {\n IGraphicAttribute,\n IContext2d,\n IMarkAttribute,\n ISymbol,\n ISymbolGraphicAttribute,\n IThemeAttribute,\n ISymbolRenderContribution,\n IDrawContext,\n IBorderStyle\n} from '../../../../interface';\nimport { getScaledStroke } from '../../../../common/canvas-utils';\nimport { defaultBaseBackgroundRenderContribution } from './base-contribution-render';\nimport { BaseRenderContributionTime } from '../../../../common/enums';\nimport { defaultBaseTextureRenderContribution } from './base-texture-contribution-render';\n\nexport class DefaultSymbolRenderContribution implements ISymbolRenderContribution {\n time: BaseRenderContributionTime = BaseRenderContributionTime.afterFillStroke;\n useStyle: boolean = true;\n order: number = 0;\n drawShape(\n symbol: ISymbol,\n context: IContext2d,\n x: number,\n y: number,\n doFill: boolean,\n doStroke: boolean,\n fVisible: boolean,\n sVisible: boolean,\n symbolAttribute: Required<ISymbolGraphicAttribute>,\n drawContext: IDrawContext,\n fillCb?: (\n ctx: IContext2d,\n markAttribute: Partial<IMarkAttribute & IGraphicAttribute>,\n themeAttribute: IThemeAttribute\n ) => boolean,\n strokeCb?: (\n ctx: IContext2d,\n markAttribute: Partial<IMarkAttribute & IGraphicAttribute>,\n themeAttribute: IThemeAttribute\n ) => boolean\n ) {\n const parsedPath = symbol.getParsedPath();\n // todo: 考虑使用path\n if (!parsedPath) {\n return;\n }\n\n const { outerBorder, innerBorder } = symbol.attribute;\n const doOuterBorder = outerBorder && outerBorder.visible !== false;\n const doInnerBorder = innerBorder && innerBorder.visible !== false;\n if (!(doOuterBorder || doInnerBorder)) {\n return;\n }\n\n const {\n size = symbolAttribute.size,\n opacity = symbolAttribute.opacity,\n x: originX = symbolAttribute.x,\n y: originY = symbolAttribute.y,\n scaleX = symbolAttribute.scaleX,\n scaleY = symbolAttribute.scaleY,\n keepStrokeScale = symbolAttribute.keepStrokeScale\n } = symbol.attribute;\n\n const renderBorder = (borderStyle: Partial<IBorderStyle>, key: 'outerBorder' | 'innerBorder') => {\n const doStroke = !!(borderStyle && borderStyle.stroke);\n\n const { distance = symbolAttribute[key].distance } = borderStyle;\n const d = keepStrokeScale ? (distance as number) : getScaledStroke(context, distance as number, context.dpr);\n const sign = key === 'outerBorder' ? 1 : -1;\n\n context.beginPath();\n if (parsedPath.drawOffset(context, size, x, y, sign * d) === false) {\n context.closePath();\n }\n\n // shadow\n context.setShadowBlendStyle && context.setShadowBlendStyle(symbol, symbol.attribute, symbolAttribute);\n\n if (strokeCb) {\n strokeCb(context, borderStyle, symbolAttribute[key]);\n } else if (doStroke) {\n // 存在stroke\n const lastOpacity = (symbolAttribute[key] as any).opacity;\n (symbolAttribute[key] as any).opacity = opacity;\n context.setStrokeStyle(\n symbol,\n borderStyle,\n (originX - x) / scaleX,\n (originY - y) / scaleY,\n symbolAttribute[key] as any\n );\n (symbolAttribute[key] as any).opacity = lastOpacity;\n context.stroke();\n }\n };\n\n doOuterBorder && renderBorder(outerBorder, 'outerBorder');\n doInnerBorder && renderBorder(innerBorder, 'innerBorder');\n }\n}\n\nexport const defaultSymbolRenderContribution = new DefaultSymbolRenderContribution();\nexport const defaultSymbolTextureRenderContribution = defaultBaseTextureRenderContribution;\nexport const defaultSymbolBackgroundRenderContribution = defaultBaseBackgroundRenderContribution;\n"]}
@@ -8,7 +8,7 @@ export declare class DefaultCanvasTextRender extends BaseRender<IText> implement
8
8
  constructor(textRenderContribitions: IContributionProvider<ITextRenderContribution>);
9
9
  drawShape(text: IText, context: IContext2d, x: number, y: number, drawContext: IDrawContext, params?: IGraphicRenderDrawParams, fillCb?: (ctx: IContext2d, markAttribute: Partial<IMarkAttribute & IGraphicAttribute>, themeAttribute: IThemeAttribute) => boolean, strokeCb?: (ctx: IContext2d, markAttribute: Partial<IMarkAttribute & IGraphicAttribute>, themeAttribute: IThemeAttribute) => boolean): void;
10
10
  draw(text: IText, renderService: IRenderService, drawContext: IDrawContext, params?: IGraphicRenderDrawParams): void;
11
- drawUnderLine(underline: number, lineThrough: number, text: IText, x: number, y: number, z: number, textAttribute: Required<ITextGraphicAttribute>, context: IContext2d, multiOption?: {
11
+ drawUnderLine(underline: number, lineThrough: number, text: IText, anchorX: number, anchorY: number, offsetUnderLineY: number, offsetThroughLineY: number, z: number, textAttribute: Required<ITextGraphicAttribute>, context: IContext2d, multiOption?: {
12
12
  width: number;
13
13
  }): void;
14
14
  }
@@ -16,7 +16,7 @@ import { getTheme } from "../../../graphic/theme";
16
16
 
17
17
  import { TEXT_NUMBER_TYPE } from "../../../graphic/constants";
18
18
 
19
- import { textDrawOffsetX, textDrawOffsetY, textLayoutOffsetY } from "../../../common/text";
19
+ import { textDrawOffsetX } from "../../../common/text";
20
20
 
21
21
  import { BaseRender } from "./base-render";
22
22
 
@@ -39,14 +39,7 @@ let DefaultCanvasTextRender = class extends BaseRender {
39
39
  }
40
40
  drawShape(text, context, x, y, drawContext, params, fillCb, strokeCb) {
41
41
  var _a, _b, _c;
42
- const textAttribute = getTheme(text, null == params ? void 0 : params.theme).text, {text: str, underline: underline = textAttribute.underline, lineThrough: lineThrough = textAttribute.lineThrough, keepDirIn3d: keepDirIn3d = textAttribute.keepDirIn3d, direction: direction = textAttribute.direction, fontSize: fontSize = textAttribute.fontSize, verticalMode: verticalMode = textAttribute.verticalMode, x: originX = textAttribute.x, y: originY = textAttribute.y} = text.attribute;
43
- let {textAlign: textAlign = textAttribute.textAlign, textBaseline: textBaseline = textAttribute.textBaseline} = text.attribute;
44
- if (!verticalMode && "vertical" === direction) {
45
- const t = textAlign;
46
- textAlign = null !== (_a = text.getBaselineMapAlign()[textBaseline]) && void 0 !== _a ? _a : "left",
47
- textBaseline = null !== (_b = text.getAlignMapBaseline()[t]) && void 0 !== _b ? _b : "top";
48
- }
49
- const lineHeight = null !== (_c = calculateLineHeight(text.attribute.lineHeight, fontSize)) && void 0 !== _c ? _c : fontSize, data = this.valid(text, textAttribute, fillCb, strokeCb);
42
+ const textAttribute = getTheme(text, null == params ? void 0 : params.theme).text, {text: str, underline: underline = textAttribute.underline, lineThrough: lineThrough = textAttribute.lineThrough, keepDirIn3d: keepDirIn3d = textAttribute.keepDirIn3d, direction: direction = textAttribute.direction, fontSize: fontSize = textAttribute.fontSize, verticalMode: verticalMode = textAttribute.verticalMode, x: originX = textAttribute.x, y: originY = textAttribute.y} = text.attribute, lineHeight = null !== (_a = calculateLineHeight(text.attribute.lineHeight, fontSize)) && void 0 !== _a ? _a : fontSize, data = this.valid(text, textAttribute, fillCb, strokeCb);
50
43
  if (!data) return;
51
44
  const {fVisible: fVisible, sVisible: sVisible, doFill: doFill, doStroke: doStroke} = data, transform3dMatrixToContextMatrix = !keepDirIn3d, z = this.z || 0;
52
45
  context.beginPath(), context.setShadowBlendStyle && context.setShadowBlendStyle(text, text.attribute, textAttribute),
@@ -63,8 +56,8 @@ let DefaultCanvasTextRender = class extends BaseRender {
63
56
  }
64
57
  doStroke && (strokeCb ? strokeCb(context, text.attribute, textAttribute) : sVisible && (context.setStrokeStyle(text, text.attribute, originX - x, originY - y, textAttribute),
65
58
  context.strokeText(t, _x, _y, z))), doFill && (fillCb ? fillCb(context, text.attribute, textAttribute) : fVisible && (context.setCommonStyle(text, text.attribute, originX - x, originY - y, textAttribute),
66
- context.fillText(t, _x, _y, z), this.drawUnderLine(underline, lineThrough, text, _x, _y, z, textAttribute, context))),
67
- direction && (context.highPerformanceRestore(), context.setTransformForCurrent());
59
+ context.fillText(t, _x, _y, z))), direction && (context.highPerformanceRestore(),
60
+ context.setTransformForCurrent());
68
61
  };
69
62
  if (context.setTextStyleWithoutAlignBaseline(text.attribute, textAttribute, z),
70
63
  "horizontal" === direction) {
@@ -77,11 +70,17 @@ let DefaultCanvasTextRender = class extends BaseRender {
77
70
  })))), doFill && (fillCb ? fillCb(context, text.attribute, textAttribute) : fVisible && (context.setCommonStyle(text, text.attribute, originX - x, originY - y, textAttribute),
78
71
  multilineLayout.lines.forEach((line => {
79
72
  context.fillText(line.str, (line.leftOffset || 0) + xOffset + x, (line.topOffset || 0) + yOffset + y, z),
80
- this.drawUnderLine(underline, lineThrough, text, (line.leftOffset || 0) + xOffset + x, (line.topOffset || 0) + yOffset + y - textDrawOffsetY("bottom", fontSize) - .05 * fontSize, z, textAttribute, context, {
73
+ this.drawUnderLine(underline, lineThrough, text, (line.leftOffset || 0) + xOffset + x, (line.topOffset || 0) + yOffset + y, line.descent, (line.descent - line.ascent) / 2, z, textAttribute, context, {
81
74
  width: line.width
82
75
  });
83
76
  }))));
84
77
  } else {
78
+ let {textAlign: textAlign = textAttribute.textAlign, textBaseline: textBaseline = textAttribute.textBaseline} = text.attribute;
79
+ if (!verticalMode) {
80
+ const t = textAlign;
81
+ textAlign = null !== (_b = text.getBaselineMapAlign()[textBaseline]) && void 0 !== _b ? _b : "left",
82
+ textBaseline = null !== (_c = text.getAlignMapBaseline()[t]) && void 0 !== _c ? _c : "top";
83
+ }
85
84
  text.tryUpdateAABBBounds();
86
85
  const cache = text.cache, {verticalList: verticalList} = cache;
87
86
  context.textAlign = "left", context.textBaseline = "top";
@@ -112,26 +111,27 @@ let DefaultCanvasTextRender = class extends BaseRender {
112
111
  const textAttribute = getTheme(text, null == params ? void 0 : params.theme).text, {keepDirIn3d: keepDirIn3d = textAttribute.keepDirIn3d} = text.attribute, computed3dMatrix = !keepDirIn3d;
113
112
  this._draw(text, textAttribute, computed3dMatrix, drawContext, params);
114
113
  }
115
- drawUnderLine(underline, lineThrough, text, x, y, z, textAttribute, context, multiOption) {
114
+ drawUnderLine(underline, lineThrough, text, anchorX, anchorY, offsetUnderLineY, offsetThroughLineY, z, textAttribute, context, multiOption) {
116
115
  if (lineThrough + underline <= 0) return;
117
- const {textAlign: textAlign = textAttribute.textAlign, textBaseline: textBaseline = textAttribute.textBaseline, fontSize: fontSize = textAttribute.fontSize, fill: fill = textAttribute.fill, opacity: opacity = textAttribute.opacity, underlineOffset: underlineOffset = textAttribute.underlineOffset, underlineDash: underlineDash = textAttribute.underlineDash, fillOpacity: fillOpacity = textAttribute.fillOpacity} = text.attribute, isMulti = !isNil(multiOption), w = isMulti ? multiOption.width : text.clipedWidth, offsetX = isMulti ? 0 : textDrawOffsetX(textAlign, w), offsetY = textLayoutOffsetY(isMulti ? "alphabetic" : textBaseline, fontSize, fontSize), attribute = {
116
+ const {textAlign: textAlign = textAttribute.textAlign, fill: fill = textAttribute.fill, opacity: opacity = textAttribute.opacity, underlineOffset: underlineOffset = textAttribute.underlineOffset, underlineDash: underlineDash = textAttribute.underlineDash, fillOpacity: fillOpacity = textAttribute.fillOpacity} = text.attribute, isMulti = !isNil(multiOption), w = isMulti ? multiOption.width : text.clipedWidth, offsetX = isMulti ? 0 : textDrawOffsetX(textAlign, w), attribute = {
118
117
  lineWidth: 0,
119
118
  stroke: fill,
120
119
  opacity: opacity,
121
120
  strokeOpacity: fillOpacity
122
121
  };
123
- let deltaY = isMulti ? -3 : 0;
124
122
  if (underline) {
125
- attribute.lineWidth = underline, context.setStrokeStyle(text, attribute, x, y, textAttribute),
123
+ attribute.lineWidth = underline, context.setStrokeStyle(text, attribute, anchorX, anchorY, textAttribute),
126
124
  underlineDash && context.setLineDash(underlineDash), context.beginPath();
127
- const dy = y + offsetY + fontSize + underlineOffset + deltaY;
128
- context.moveTo(x + offsetX, dy, z), context.lineTo(x + offsetX + w, dy, z), context.stroke();
125
+ const dy = anchorY + offsetUnderLineY + underlineOffset;
126
+ context.moveTo(anchorX + offsetX, dy, z), context.lineTo(anchorX + offsetX + w, dy, z),
127
+ context.stroke();
129
128
  }
130
- if (isMulti && (deltaY = -1), lineThrough) {
131
- attribute.lineWidth = lineThrough, context.setStrokeStyle(text, attribute, x, y, textAttribute),
129
+ if (lineThrough) {
130
+ attribute.lineWidth = lineThrough, context.setStrokeStyle(text, attribute, anchorX, anchorY, textAttribute),
132
131
  context.beginPath();
133
- const dy = y + offsetY + fontSize / 2 + deltaY;
134
- context.moveTo(x + offsetX, dy, z), context.lineTo(x + offsetX + w, dy, z), context.stroke();
132
+ const dy = anchorY + offsetThroughLineY;
133
+ context.moveTo(anchorX + offsetX, dy, z), context.lineTo(anchorX + offsetX + w, dy, z),
134
+ context.stroke();
135
135
  }
136
136
  }
137
137
  };
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/render/contributions/render/text-render.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,OAAO,EAAE,MAAM,EAA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E,EAAE,EAAE,CAAC,CAAC,CAAC;YACnC,OAAO,CAAC,MAAM,CAAC,CAAC,GAAG,OAAO,GAAG,CAAC,EAAE,EAAE,EAAE,CAAC,CAAC,CAAC;YACvC,OAAO,CAAC,MAAM,EAAE,CAAC;SAClB;IACH,CAAC;CACF,CAAA;AAhSY,uBAAuB;IADnC,UAAU,EAAE;IAMR,WAAA,MAAM,CAAC,oBAAoB,CAAC,CAAA;IAC5B,WAAA,KAAK,CAAC,sBAAsB,CAAC,CAAA;;GANrB,uBAAuB,CAgSnC;SAhSY,uBAAuB","file":"text-render.js","sourcesContent":["import { inject, injectable, named } from '../../../common/inversify-lite';\nimport { getTheme } from '../../../graphic/theme';\nimport { TEXT_NUMBER_TYPE } from '../../../graphic/constants';\nimport type {\n IGraphicAttribute,\n IContext2d,\n IMarkAttribute,\n IThemeAttribute,\n IDrawContext,\n IRenderService,\n IGraphicRender,\n IGraphicRenderDrawParams,\n ITextRenderContribution,\n IContributionProvider\n} from '../../../interface';\nimport { textDrawOffsetX, textDrawOffsetY, textLayoutOffsetY } from '../../../common/text';\nimport type { IText, ITextGraphicAttribute } from '../../../interface/graphic/text';\nimport { BaseRender } from './base-render';\nimport { ContributionProvider } from '../../../common/contribution-provider';\nimport { TextRenderContribution } from './contributions/constants';\nimport { matrixAllocate } from '../../../allocator/matrix-allocate';\nimport { isNil, max } from '@visactor/vutils';\nimport { calculateLineHeight } from '../../../common/utils';\nimport { defaultTextBackgroundRenderContribution } from './contributions/text-contribution-render';\n\n@injectable()\nexport class DefaultCanvasTextRender extends BaseRender<IText> implements IGraphicRender {\n type: 'text';\n numberType: number = TEXT_NUMBER_TYPE;\n\n constructor(\n @inject(ContributionProvider)\n @named(TextRenderContribution)\n protected readonly textRenderContribitions: IContributionProvider<ITextRenderContribution>\n ) {\n super();\n this.builtinContributions = [defaultTextBackgroundRenderContribution as any];\n this.init(textRenderContribitions);\n }\n\n drawShape(\n text: IText,\n context: IContext2d,\n x: number,\n y: number,\n drawContext: IDrawContext,\n params?: IGraphicRenderDrawParams,\n fillCb?: (\n ctx: IContext2d,\n markAttribute: Partial<IMarkAttribute & IGraphicAttribute>,\n themeAttribute: IThemeAttribute\n ) => boolean,\n strokeCb?: (\n ctx: IContext2d,\n markAttribute: Partial<IMarkAttribute & IGraphicAttribute>,\n themeAttribute: IThemeAttribute\n ) => boolean\n ) {\n const textAttribute = getTheme(text, params?.theme).text;\n const {\n text: str,\n underline = textAttribute.underline,\n lineThrough = textAttribute.lineThrough,\n keepDirIn3d = textAttribute.keepDirIn3d,\n direction = textAttribute.direction,\n // lineHeight = textAttribute.lineHeight,\n // whiteSpace = textAttribute.whiteSpace,\n fontSize = textAttribute.fontSize,\n verticalMode = textAttribute.verticalMode,\n x: originX = textAttribute.x,\n y: originY = textAttribute.y\n } = text.attribute;\n\n let { textAlign = textAttribute.textAlign, textBaseline = textAttribute.textBaseline } = text.attribute;\n if (!verticalMode && direction === 'vertical') {\n const t = textAlign;\n textAlign = text.getBaselineMapAlign()[textBaseline] ?? ('left' as any);\n textBaseline = text.getAlignMapBaseline()[t] ?? ('top' as any);\n }\n const lineHeight = calculateLineHeight(text.attribute.lineHeight, fontSize) ?? fontSize;\n\n const data = this.valid(text, textAttribute, fillCb, strokeCb);\n if (!data) {\n return;\n }\n const { fVisible, sVisible, doFill, doStroke } = data;\n\n // 文字如果需要变换,那就需要将3dmatrix转成context的2dmatrix\n const transform3dMatrixToContextMatrix = !keepDirIn3d;\n\n const z = this.z || 0;\n\n context.beginPath();\n\n // shadow\n context.setShadowBlendStyle && context.setShadowBlendStyle(text, text.attribute, textAttribute);\n\n this.beforeRenderStep(\n text,\n context,\n x,\n y,\n doFill,\n doStroke,\n fVisible,\n sVisible,\n textAttribute,\n drawContext,\n fillCb,\n strokeCb\n );\n\n transform3dMatrixToContextMatrix && this.transformUseContext2d(text, textAttribute, z, context);\n\n const drawText = (t: string, offsetX: number, offsetY: number, direction: number) => {\n let _x = x + offsetX;\n const _y = y + offsetY;\n if (direction) {\n context.highPerformanceSave();\n _x += fontSize;\n const matrix = matrixAllocate.allocate(1, 0, 0, 1, 0, 0);\n // matrix.translate(fontSize, 0);\n matrix.rotateByCenter(Math.PI / 2, _x, _y);\n context.transformFromMatrix(matrix, true);\n matrixAllocate.free(matrix);\n }\n\n if (doStroke) {\n if (strokeCb) {\n strokeCb(context, text.attribute, textAttribute);\n } else if (sVisible) {\n context.setStrokeStyle(text, text.attribute, originX - x, originY - y, textAttribute);\n context.strokeText(t, _x, _y, z);\n }\n }\n if (doFill) {\n if (fillCb) {\n fillCb(context, text.attribute, textAttribute);\n } else if (fVisible) {\n context.setCommonStyle(text, text.attribute, originX - x, originY - y, textAttribute);\n context.fillText(t, _x, _y, z);\n this.drawUnderLine(underline, lineThrough, text, _x, _y, z, textAttribute, context);\n }\n }\n\n if (direction) {\n context.highPerformanceRestore();\n context.setTransformForCurrent();\n }\n };\n context.setTextStyleWithoutAlignBaseline(text.attribute, textAttribute, z);\n if (direction === 'horizontal') {\n const { multilineLayout } = text;\n if (!multilineLayout) {\n context.highPerformanceRestore();\n return;\n } // 如果不存在的话,需要render层自行布局\n const { xOffset, yOffset } = multilineLayout.bbox;\n if (doStroke) {\n if (strokeCb) {\n strokeCb(context, text.attribute, textAttribute);\n } else if (sVisible) {\n context.setStrokeStyle(text, text.attribute, originX - x, originY - y, textAttribute);\n multilineLayout.lines.forEach(line => {\n context.strokeText(line.str, (line.leftOffset || 0) + xOffset + x, (line.topOffset || 0) + yOffset + y, z);\n });\n }\n }\n if (doFill) {\n if (fillCb) {\n fillCb(context, text.attribute, textAttribute);\n } else if (fVisible) {\n context.setCommonStyle(text, text.attribute, originX - x, originY - y, textAttribute);\n multilineLayout.lines.forEach(line => {\n context.fillText(line.str, (line.leftOffset || 0) + xOffset + x, (line.topOffset || 0) + yOffset + y, z);\n this.drawUnderLine(\n underline,\n lineThrough,\n text,\n (line.leftOffset || 0) + xOffset + x,\n // y是基于alphabetic对齐的,这里-0.05是为了和不换行的文字保持效果一致\n (line.topOffset || 0) + yOffset + y - textDrawOffsetY('bottom', fontSize) - 0.05 * fontSize,\n z,\n textAttribute,\n context,\n {\n width: line.width\n }\n );\n });\n }\n }\n } else {\n text.tryUpdateAABBBounds(); // 更新cache\n const cache = text.cache;\n const { verticalList } = cache;\n context.textAlign = 'left';\n context.textBaseline = 'top';\n const totalHeight = lineHeight * verticalList.length;\n let totalW = 0;\n verticalList.forEach(verticalData => {\n const _w = verticalData.reduce((a, b) => a + (b.width || 0), 0);\n totalW = max(_w, totalW);\n });\n let offsetY = 0;\n let offsetX = 0;\n if (textBaseline === 'bottom') {\n offsetX = -totalHeight;\n } else if (textBaseline === 'middle') {\n offsetX = -totalHeight / 2;\n }\n if (textAlign === 'center') {\n offsetY -= totalW / 2;\n } else if (textAlign === 'right') {\n offsetY -= totalW;\n }\n verticalList.forEach((verticalData, i) => {\n const currentW = verticalData.reduce((a, b) => a + (b.width || 0), 0);\n const dw = totalW - currentW;\n let currentOffsetY = offsetY;\n if (textAlign === 'center') {\n currentOffsetY += dw / 2;\n } else if (textAlign === 'right') {\n currentOffsetY += dw;\n }\n verticalData.forEach(item => {\n const { text, width, direction } = item;\n drawText(text, totalHeight - (i + 1) * lineHeight + offsetX, currentOffsetY, direction);\n currentOffsetY += width;\n });\n });\n }\n transform3dMatrixToContextMatrix && this.restoreTransformUseContext2d(text, textAttribute, z, context);\n\n this.afterRenderStep(\n text,\n context,\n x,\n y,\n doFill,\n doStroke,\n fVisible,\n sVisible,\n textAttribute,\n drawContext,\n fillCb,\n strokeCb\n );\n }\n\n draw(text: IText, renderService: IRenderService, drawContext: IDrawContext, params?: IGraphicRenderDrawParams) {\n const textAttribute = getTheme(text, params?.theme).text;\n const { keepDirIn3d = textAttribute.keepDirIn3d } = text.attribute;\n // 文字如果需要变换,那就一定要计算3d矩阵\n const computed3dMatrix = !keepDirIn3d;\n this._draw(text, textAttribute, computed3dMatrix, drawContext, params);\n }\n\n drawUnderLine(\n underline: number,\n lineThrough: number,\n text: IText,\n x: number,\n y: number,\n z: number,\n textAttribute: Required<ITextGraphicAttribute>,\n context: IContext2d,\n multiOption?: {\n width: number;\n }\n ) {\n if (lineThrough + underline <= 0) {\n return;\n }\n\n const {\n textAlign = textAttribute.textAlign,\n textBaseline = textAttribute.textBaseline,\n fontSize = textAttribute.fontSize,\n fill = textAttribute.fill,\n opacity = textAttribute.opacity,\n underlineOffset = textAttribute.underlineOffset,\n underlineDash = textAttribute.underlineDash,\n fillOpacity = textAttribute.fillOpacity\n } = text.attribute;\n const isMulti = !isNil(multiOption);\n const w = isMulti ? multiOption!.width : text.clipedWidth;\n const offsetX = isMulti ? 0 : textDrawOffsetX(textAlign, w);\n const offsetY = textLayoutOffsetY(isMulti ? 'alphabetic' : textBaseline, fontSize, fontSize);\n const attribute = { lineWidth: 0, stroke: fill, opacity, strokeOpacity: fillOpacity };\n let deltaY = isMulti ? -3 : 0;\n if (underline) {\n attribute.lineWidth = underline;\n context.setStrokeStyle(text, attribute, x, y, textAttribute);\n underlineDash && context.setLineDash(underlineDash);\n context.beginPath();\n const dy = y + offsetY + fontSize + underlineOffset + deltaY;\n context.moveTo(x + offsetX, dy, z);\n context.lineTo(x + offsetX + w, dy, z);\n context.stroke();\n }\n if (isMulti) {\n deltaY = -1;\n }\n if (lineThrough) {\n attribute.lineWidth = lineThrough;\n context.setStrokeStyle(text, attribute, x, y, textAttribute);\n context.beginPath();\n const dy = y + offsetY + fontSize / 2 + deltaY;\n context.moveTo(x + offsetX, dy, z);\n context.lineTo(x + offsetX + w, dy, z);\n context.stroke();\n }\n }\n}\n"]}
1
+ {"version":3,"sources":["../src/render/contributions/render/text-render.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,OAAO,EAAE,MAAM,EAAE,UAAU,EAAE,KAAK,EAAE,MAAM,gCAAgC,CAAC;AAC3E,OAAO,EAAE,QAAQ,EAAE,MAAM,wBAAwB,CAAC;AAClD,OAAO,EAAE,gBAAgB,EAAE,MAAM,4BAA4B,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GAAG,eAAe,CAAC;YACxD,OAAO,CAAC,MAAM,CAAC,OAAO,GAAG,OAAO,EAAE,EAAE,EAAE,CAAC,CAAC,CAAC;YACzC,OAAO,CAAC,MAAM,CAAC,OAAO,GAAG,OAAO,GAAG,CAAC,EAAE,EAAE,EAAE,CAAC,CAAC,CAAC;YAC7C,OAAO,CAAC,MAAM,EAAE,CAAC;SAClB;QAID,IAAI,WAAW,EAAE;YACf,SAAS,CAAC,SAAS,GAAG,WAAW,CAAC;YAClC,OAAO,CAAC,cAAc,CAAC,IAAI,EAAE,SAAS,EAAE,OAAO,EAAE,OAAO,EAAE,aAAa,CAAC,CAAC;YACzE,OAAO,CAAC,SAAS,EAAE,CAAC;YAEpB,MAAM,EAAE,GAAG,OAAO,GAAG,kBAAkB,CAAC;YACxC,OAAO,CAAC,MAAM,CAAC,OAAO,GAAG,OAAO,EAAE,EAAE,EAAE,CAAC,CAAC,CAAC;YACzC,OAAO,CAAC,MAAM,CAAC,OAAO,GAAG,OAAO,GAAG,CAAC,EAAE,EAAE,EAAE,CAAC,CAAC,CAAC;YAC7C,OAAO,CAAC,MAAM,EAAE,CAAC;SAClB;IACH,CAAC;CACF,CAAA;AAtSY,uBAAuB;IADnC,UAAU,EAAE;IAMR,WAAA,MAAM,CAAC,oBAAoB,CAAC,CAAA;IAC5B,WAAA,KAAK,CAAC,sBAAsB,CAAC,CAAA;;GANrB,uBAAuB,CAsSnC;SAtSY,uBAAuB","file":"text-render.js","sourcesContent":["import { inject, injectable, named } from '../../../common/inversify-lite';\nimport { getTheme } from '../../../graphic/theme';\nimport { TEXT_NUMBER_TYPE } from '../../../graphic/constants';\nimport type {\n IGraphicAttribute,\n IContext2d,\n IMarkAttribute,\n IThemeAttribute,\n IDrawContext,\n IRenderService,\n IGraphicRender,\n IGraphicRenderDrawParams,\n ITextRenderContribution,\n IContributionProvider\n} from '../../../interface';\nimport { textDrawOffsetX, textDrawOffsetY, textLayoutOffsetY } from '../../../common/text';\nimport type { IText, ITextGraphicAttribute } from '../../../interface/graphic/text';\nimport { BaseRender } from './base-render';\nimport { ContributionProvider } from '../../../common/contribution-provider';\nimport { TextRenderContribution } from './contributions/constants';\nimport { matrixAllocate } from '../../../allocator/matrix-allocate';\nimport { isNil, max } from '@visactor/vutils';\nimport { calculateLineHeight } from '../../../common/utils';\nimport { defaultTextBackgroundRenderContribution } from './contributions/text-contribution-render';\n\n@injectable()\nexport class DefaultCanvasTextRender extends BaseRender<IText> implements IGraphicRender {\n type: 'text';\n numberType: number = TEXT_NUMBER_TYPE;\n\n constructor(\n @inject(ContributionProvider)\n @named(TextRenderContribution)\n protected readonly textRenderContribitions: IContributionProvider<ITextRenderContribution>\n ) {\n super();\n this.builtinContributions = [defaultTextBackgroundRenderContribution as any];\n this.init(textRenderContribitions);\n }\n\n drawShape(\n text: IText,\n context: IContext2d,\n x: number,\n y: number,\n drawContext: IDrawContext,\n params?: IGraphicRenderDrawParams,\n fillCb?: (\n ctx: IContext2d,\n markAttribute: Partial<IMarkAttribute & IGraphicAttribute>,\n themeAttribute: IThemeAttribute\n ) => boolean,\n strokeCb?: (\n ctx: IContext2d,\n markAttribute: Partial<IMarkAttribute & IGraphicAttribute>,\n themeAttribute: IThemeAttribute\n ) => boolean\n ) {\n const textAttribute = getTheme(text, params?.theme).text;\n const {\n text: str,\n underline = textAttribute.underline,\n lineThrough = textAttribute.lineThrough,\n keepDirIn3d = textAttribute.keepDirIn3d,\n direction = textAttribute.direction,\n // lineHeight = textAttribute.lineHeight,\n // whiteSpace = textAttribute.whiteSpace,\n fontSize = textAttribute.fontSize,\n verticalMode = textAttribute.verticalMode,\n x: originX = textAttribute.x,\n y: originY = textAttribute.y\n } = text.attribute;\n\n const lineHeight = calculateLineHeight(text.attribute.lineHeight, fontSize) ?? fontSize;\n\n const data = this.valid(text, textAttribute, fillCb, strokeCb);\n if (!data) {\n return;\n }\n const { fVisible, sVisible, doFill, doStroke } = data;\n\n // 文字如果需要变换,那就需要将3dmatrix转成context的2dmatrix\n const transform3dMatrixToContextMatrix = !keepDirIn3d;\n\n const z = this.z || 0;\n\n context.beginPath();\n\n // shadow\n context.setShadowBlendStyle && context.setShadowBlendStyle(text, text.attribute, textAttribute);\n\n this.beforeRenderStep(\n text,\n context,\n x,\n y,\n doFill,\n doStroke,\n fVisible,\n sVisible,\n textAttribute,\n drawContext,\n fillCb,\n strokeCb\n );\n\n transform3dMatrixToContextMatrix && this.transformUseContext2d(text, textAttribute, z, context);\n\n const drawText = (t: string, offsetX: number, offsetY: number, direction: number) => {\n let _x = x + offsetX;\n const _y = y + offsetY;\n if (direction) {\n context.highPerformanceSave();\n _x += fontSize;\n const matrix = matrixAllocate.allocate(1, 0, 0, 1, 0, 0);\n // matrix.translate(fontSize, 0);\n matrix.rotateByCenter(Math.PI / 2, _x, _y);\n context.transformFromMatrix(matrix, true);\n matrixAllocate.free(matrix);\n }\n\n if (doStroke) {\n if (strokeCb) {\n strokeCb(context, text.attribute, textAttribute);\n } else if (sVisible) {\n context.setStrokeStyle(text, text.attribute, originX - x, originY - y, textAttribute);\n context.strokeText(t, _x, _y, z);\n }\n }\n if (doFill) {\n if (fillCb) {\n fillCb(context, text.attribute, textAttribute);\n } else if (fVisible) {\n context.setCommonStyle(text, text.attribute, originX - x, originY - y, textAttribute);\n context.fillText(t, _x, _y, z);\n // 垂直布局的情况下不支持下划线和中划线\n // this.drawUnderLine(underline, lineThrough, text, _x, _y, 0, 0, z, textAttribute, context);\n }\n }\n\n if (direction) {\n context.highPerformanceRestore();\n context.setTransformForCurrent();\n }\n };\n context.setTextStyleWithoutAlignBaseline(text.attribute, textAttribute, z);\n if (direction === 'horizontal') {\n const { multilineLayout } = text;\n if (!multilineLayout) {\n context.highPerformanceRestore();\n return;\n } // 如果不存在的话,需要render层自行布局\n const { xOffset, yOffset } = multilineLayout.bbox;\n if (doStroke) {\n if (strokeCb) {\n strokeCb(context, text.attribute, textAttribute);\n } else if (sVisible) {\n context.setStrokeStyle(text, text.attribute, originX - x, originY - y, textAttribute);\n multilineLayout.lines.forEach(line => {\n context.strokeText(line.str, (line.leftOffset || 0) + xOffset + x, (line.topOffset || 0) + yOffset + y, z);\n });\n }\n }\n if (doFill) {\n if (fillCb) {\n fillCb(context, text.attribute, textAttribute);\n } else if (fVisible) {\n context.setCommonStyle(text, text.attribute, originX - x, originY - y, textAttribute);\n multilineLayout.lines.forEach(line => {\n context.fillText(line.str, (line.leftOffset || 0) + xOffset + x, (line.topOffset || 0) + yOffset + y, z);\n this.drawUnderLine(\n underline,\n lineThrough,\n text,\n (line.leftOffset || 0) + xOffset + x,\n (line.topOffset || 0) + yOffset + y,\n line.descent,\n (line.descent - line.ascent) / 2,\n z,\n textAttribute,\n context,\n {\n width: line.width\n }\n );\n });\n }\n }\n } else {\n let { textAlign = textAttribute.textAlign, textBaseline = textAttribute.textBaseline } = text.attribute;\n if (!verticalMode) {\n const t = textAlign;\n textAlign = text.getBaselineMapAlign()[textBaseline] ?? ('left' as any);\n textBaseline = text.getAlignMapBaseline()[t] ?? ('top' as any);\n }\n text.tryUpdateAABBBounds(); // 更新cache\n const cache = text.cache;\n const { verticalList } = cache;\n context.textAlign = 'left';\n context.textBaseline = 'top';\n const totalHeight = lineHeight * verticalList.length;\n let totalW = 0;\n verticalList.forEach(verticalData => {\n const _w = verticalData.reduce((a, b) => a + (b.width || 0), 0);\n totalW = max(_w, totalW);\n });\n let offsetY = 0;\n let offsetX = 0;\n if (textBaseline === 'bottom') {\n offsetX = -totalHeight;\n } else if (textBaseline === 'middle') {\n offsetX = -totalHeight / 2;\n }\n if (textAlign === 'center') {\n offsetY -= totalW / 2;\n } else if (textAlign === 'right') {\n offsetY -= totalW;\n }\n verticalList.forEach((verticalData, i) => {\n const currentW = verticalData.reduce((a, b) => a + (b.width || 0), 0);\n const dw = totalW - currentW;\n let currentOffsetY = offsetY;\n if (textAlign === 'center') {\n currentOffsetY += dw / 2;\n } else if (textAlign === 'right') {\n currentOffsetY += dw;\n }\n verticalData.forEach(item => {\n const { text, width, direction } = item;\n drawText(text, totalHeight - (i + 1) * lineHeight + offsetX, currentOffsetY, direction);\n currentOffsetY += width;\n });\n });\n }\n transform3dMatrixToContextMatrix && this.restoreTransformUseContext2d(text, textAttribute, z, context);\n\n this.afterRenderStep(\n text,\n context,\n x,\n y,\n doFill,\n doStroke,\n fVisible,\n sVisible,\n textAttribute,\n drawContext,\n fillCb,\n strokeCb\n );\n }\n\n draw(text: IText, renderService: IRenderService, drawContext: IDrawContext, params?: IGraphicRenderDrawParams) {\n const textAttribute = getTheme(text, params?.theme).text;\n const { keepDirIn3d = textAttribute.keepDirIn3d } = text.attribute;\n // 文字如果需要变换,那就一定要计算3d矩阵\n const computed3dMatrix = !keepDirIn3d;\n this._draw(text, textAttribute, computed3dMatrix, drawContext, params);\n }\n\n drawUnderLine(\n underline: number,\n lineThrough: number,\n text: IText,\n anchorX: number,\n anchorY: number,\n offsetUnderLineY: number,\n offsetThroughLineY: number,\n z: number,\n textAttribute: Required<ITextGraphicAttribute>,\n context: IContext2d,\n multiOption?: {\n width: number;\n }\n ) {\n if (lineThrough + underline <= 0) {\n return;\n }\n\n const {\n textAlign = textAttribute.textAlign,\n // textBaseline = textAttribute.textBaseline,\n // fontSize = textAttribute.fontSize,\n fill = textAttribute.fill,\n opacity = textAttribute.opacity,\n underlineOffset = textAttribute.underlineOffset,\n underlineDash = textAttribute.underlineDash,\n fillOpacity = textAttribute.fillOpacity\n } = text.attribute;\n const isMulti = !isNil(multiOption);\n const w = isMulti ? multiOption!.width : text.clipedWidth;\n const offsetX = isMulti ? 0 : textDrawOffsetX(textAlign, w);\n // const offsetY = textLayoutOffsetY(isMulti ? 'alphabetic' : textBaseline, fontSize, fontSize);\n const attribute = { lineWidth: 0, stroke: fill, opacity, strokeOpacity: fillOpacity };\n // let deltaY = isMulti ? -3 : 0;\n if (underline) {\n attribute.lineWidth = underline;\n context.setStrokeStyle(text, attribute, anchorX, anchorY, textAttribute);\n underlineDash && context.setLineDash(underlineDash);\n context.beginPath();\n // const dy = y + offsetY + fontSize + underlineOffset + deltaY;\n const dy = anchorY + offsetUnderLineY + underlineOffset;\n context.moveTo(anchorX + offsetX, dy, z);\n context.lineTo(anchorX + offsetX + w, dy, z);\n context.stroke();\n }\n // if (isMulti) {\n // deltaY = -1;\n // }\n if (lineThrough) {\n attribute.lineWidth = lineThrough;\n context.setStrokeStyle(text, attribute, anchorX, anchorY, textAttribute);\n context.beginPath();\n // const dy = y + offsetY + fontSize / 2 + deltaY;\n const dy = anchorY + offsetThroughLineY;\n context.moveTo(anchorX + offsetX, dy, z);\n context.lineTo(anchorX + offsetX + w, dy, z);\n context.stroke();\n }\n }\n}\n"]}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@visactor/vrender-core",
3
- "version": "0.21.0-alpha.3",
3
+ "version": "0.21.0-alpha.5",
4
4
  "description": "",
5
5
  "sideEffects": [
6
6
  "./src/modules.ts",
@@ -17,7 +17,7 @@
17
17
  ],
18
18
  "dependencies": {
19
19
  "color-convert": "2.0.1",
20
- "@visactor/vutils": "~0.18.18"
20
+ "@visactor/vutils": "~0.19.0"
21
21
  },
22
22
  "devDependencies": {
23
23
  "@rushstack/eslint-patch": "~1.1.4",
@@ -76,6 +76,7 @@
76
76
  "test": "jest",
77
77
  "test-live": "npm run test-watch __tests__/unit/theme/line.test.ts",
78
78
  "test-watch": "cross-env DEBUG_MODE=1 jest --watch",
79
- "test-cov": "jest -w 16 --coverage"
79
+ "test-cov": "jest -w 16 --coverage",
80
+ "build:spec-types": "rm -rf ./spec-types && tsc -p ./tsconfig.spec.json --declaration --emitDeclarationOnly --outDir ./spec-types"
80
81
  }
81
82
  }
@@ -1,81 +0,0 @@
1
- import type { IAABBBounds } from '@visactor/vutils';
2
- import type { IText, ITextCache, ITextGraphicAttribute, LayoutType } from '../interface';
3
- import { Graphic } from './graphic';
4
- export declare class Text extends Graphic<ITextGraphicAttribute> implements IText {
5
- type: 'text';
6
- static NOWORK_ANIMATE_ATTR: {
7
- strokeSeg: number;
8
- boundsPadding: number;
9
- pickMode: number;
10
- boundsMode: number;
11
- customPickShape: number;
12
- pickable: number;
13
- childrenPickable: number;
14
- visible: number;
15
- zIndex: number;
16
- layout: number;
17
- keepDirIn3d: number;
18
- globalZIndex: number;
19
- outerBorder: number;
20
- innerBorder: number;
21
- lineDash: number;
22
- lineCap: number;
23
- lineJoin: number;
24
- miterLimit: number;
25
- strokeBoundsBuffer: number;
26
- scaleCenter: number;
27
- anchor: number;
28
- anchor3d: number;
29
- postMatrix: number;
30
- backgroundMode: number;
31
- background: number;
32
- texture: number;
33
- cursor: number;
34
- html: number;
35
- ellipsis: number;
36
- wordBreak: number;
37
- direction: number;
38
- textAlign: number;
39
- textBaseline: number;
40
- fontFamily: number;
41
- fontWeight: number;
42
- };
43
- cache: ITextCache;
44
- _font: string;
45
- get font(): string;
46
- get clipedText(): string | undefined;
47
- get clipedWidth(): number | undefined;
48
- get cliped(): boolean | undefined;
49
- get multilineLayout(): LayoutType | undefined;
50
- get isMultiLine(): boolean;
51
- constructor(params?: ITextGraphicAttribute);
52
- isValid(): boolean;
53
- protected _isValid(): boolean;
54
- getGraphicTheme(): Required<ITextGraphicAttribute>;
55
- protected updateAABBBounds(attribute: ITextGraphicAttribute, textTheme: Required<ITextGraphicAttribute>, aabbBounds: IAABBBounds): import("@visactor/vutils").IBounds;
56
- updateSingallineAABBBounds(text: number | string): IAABBBounds;
57
- protected updateMultilineAABBBounds(text: (number | string)[]): IAABBBounds;
58
- updateHorizontalMultilineAABBBounds(text: (number | string)[]): IAABBBounds;
59
- updateWrapAABBBounds(text: (number | string) | (number | string)[]): import("@visactor/vutils").IBounds;
60
- updateVerticalMultilineAABBBounds(text: (number | string)[]): IAABBBounds;
61
- protected isSinglelineAndHorizontal(): boolean;
62
- protected getMaxWidth(theme: ITextGraphicAttribute): number;
63
- protected getLineHeight(attribute: ITextGraphicAttribute, textTheme: ITextGraphicAttribute): number;
64
- protected needUpdateTags(keys: string[], k?: string[]): boolean;
65
- protected needUpdateTag(key: string, k?: string[]): boolean;
66
- clone(): Text;
67
- getNoWorkAnimateAttr(): Record<string, number>;
68
- getBaselineMapAlign(): Record<string, string>;
69
- getAlignMapBaseline(): Record<string, string>;
70
- static baselineMapAlign: {
71
- top: string;
72
- bottom: string;
73
- middle: string;
74
- };
75
- static alignMapBaseline: {
76
- left: string;
77
- right: string;
78
- center: string;
79
- };
80
- }
81
- export declare function createText(attributes: ITextGraphicAttribute): IText;