@visactor/vrender-core 0.21.7 → 0.22.0-vstory.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (342) hide show
  1. package/cjs/animate/Ticker/default-ticker.d.ts +2 -0
  2. package/cjs/animate/Ticker/default-ticker.js +7 -1
  3. package/cjs/animate/Ticker/default-ticker.js.map +1 -1
  4. package/cjs/animate/animate.js +1 -1
  5. package/cjs/animate/animate.js.map +1 -1
  6. package/cjs/animate/custom-animate.js +14 -25
  7. package/cjs/animate/custom-animate.js.map +1 -1
  8. package/cjs/animate/easing-func.d.ts +1 -0
  9. package/cjs/animate/easing-func.js +16 -0
  10. package/cjs/animate/easing-func.js.map +1 -0
  11. package/cjs/animate/easing.d.ts +4 -0
  12. package/cjs/animate/easing.js +24 -1
  13. package/cjs/animate/easing.js.map +1 -1
  14. package/cjs/animate/index.d.ts +1 -0
  15. package/cjs/animate/index.js +1 -1
  16. package/cjs/animate/index.js.map +1 -1
  17. package/cjs/color-string/store.js +1 -2
  18. package/cjs/common/3d-interceptor.js +2 -1
  19. package/cjs/common/bezier-utils.d.ts +3 -0
  20. package/cjs/common/bezier-utils.js +17 -2
  21. package/cjs/common/bezier-utils.js.map +1 -1
  22. package/cjs/common/custom-path2d.d.ts +4 -0
  23. package/cjs/common/custom-path2d.js +43 -11
  24. package/cjs/common/custom-path2d.js.map +1 -1
  25. package/cjs/common/render-area.js +0 -1
  26. package/cjs/common/render-command-list.js +2 -1
  27. package/cjs/common/segment/curve/arc.d.ts +4 -1
  28. package/cjs/common/segment/curve/arc.js +10 -1
  29. package/cjs/common/segment/curve/arc.js.map +1 -1
  30. package/cjs/common/segment/curve/base.d.ts +4 -1
  31. package/cjs/common/segment/curve/base.js.map +1 -1
  32. package/cjs/common/segment/curve/cubic-bezier.d.ts +5 -1
  33. package/cjs/common/segment/curve/cubic-bezier.js +24 -3
  34. package/cjs/common/segment/curve/cubic-bezier.js.map +1 -1
  35. package/cjs/common/segment/curve/curve-context.js +5 -4
  36. package/cjs/common/segment/curve/curve-context.js.map +1 -1
  37. package/cjs/common/segment/curve/ellipse.d.ts +4 -1
  38. package/cjs/common/segment/curve/ellipse.js +9 -0
  39. package/cjs/common/segment/curve/ellipse.js.map +1 -1
  40. package/cjs/common/segment/curve/line.d.ts +4 -1
  41. package/cjs/common/segment/curve/line.js +18 -0
  42. package/cjs/common/segment/curve/line.js.map +1 -1
  43. package/cjs/common/segment/curve/move.d.ts +4 -1
  44. package/cjs/common/segment/curve/move.js +9 -0
  45. package/cjs/common/segment/curve/move.js.map +1 -1
  46. package/cjs/common/segment/curve/path.d.ts +2 -1
  47. package/cjs/common/segment/curve/path.js +5 -2
  48. package/cjs/common/segment/curve/path.js.map +1 -1
  49. package/cjs/common/segment/curve/quadratic-bezier.d.ts +6 -2
  50. package/cjs/common/segment/curve/quadratic-bezier.js +23 -5
  51. package/cjs/common/segment/curve/quadratic-bezier.js.map +1 -1
  52. package/cjs/common/shape/rect.d.ts +1 -1
  53. package/cjs/common/shape/rect.js +30 -25
  54. package/cjs/common/shape/rect.js.map +1 -1
  55. package/cjs/common/store.js +1 -1
  56. package/cjs/core/contributions/env/base-contribution.d.ts +2 -0
  57. package/cjs/core/contributions/env/base-contribution.js +6 -0
  58. package/cjs/core/contributions/env/base-contribution.js.map +1 -1
  59. package/cjs/core/global.d.ts +5 -0
  60. package/cjs/core/global.js +13 -1
  61. package/cjs/core/global.js.map +1 -1
  62. package/cjs/graphic/builtin-symbol/rect.d.ts +2 -1
  63. package/cjs/graphic/builtin-symbol/rect.js +28 -0
  64. package/cjs/graphic/builtin-symbol/rect.js.map +1 -1
  65. package/cjs/graphic/builtin-symbol/utils.d.ts +2 -1
  66. package/cjs/graphic/builtin-symbol/utils.js +5 -0
  67. package/cjs/graphic/builtin-symbol/utils.js.map +1 -1
  68. package/cjs/graphic/config.js +19 -5
  69. package/cjs/graphic/config.js.map +1 -1
  70. package/cjs/graphic/graphic.js +15 -1
  71. package/cjs/graphic/graphic.js.map +1 -1
  72. package/cjs/graphic/richtext/line.js +1 -1
  73. package/cjs/graphic/richtext/line.js.map +1 -1
  74. package/cjs/graphic/richtext/paragraph.d.ts +1 -1
  75. package/cjs/graphic/richtext/paragraph.js +9 -4
  76. package/cjs/graphic/richtext/paragraph.js.map +1 -1
  77. package/cjs/graphic/richtext/utils.d.ts +4 -0
  78. package/cjs/graphic/richtext/utils.js +19 -6
  79. package/cjs/graphic/richtext/utils.js.map +1 -1
  80. package/cjs/graphic/richtext/wrapper.d.ts +1 -0
  81. package/cjs/graphic/richtext/wrapper.js +1 -1
  82. package/cjs/graphic/richtext/wrapper.js.map +1 -1
  83. package/cjs/graphic/richtext.d.ts +7 -2
  84. package/cjs/graphic/richtext.js +33 -3
  85. package/cjs/graphic/richtext.js.map +1 -1
  86. package/cjs/index.d.ts +2 -0
  87. package/cjs/index.js +2 -1
  88. package/cjs/index.js.map +1 -1
  89. package/cjs/interface/animate.d.ts +5 -39
  90. package/cjs/interface/animate.js.map +1 -1
  91. package/cjs/interface/context.d.ts +1 -0
  92. package/cjs/interface/context.js.map +1 -1
  93. package/cjs/interface/global.d.ts +5 -0
  94. package/cjs/interface/global.js.map +1 -1
  95. package/cjs/interface/graphic/group.d.ts +1 -0
  96. package/cjs/interface/graphic/group.js.map +1 -1
  97. package/cjs/interface/graphic/image.d.ts +1 -0
  98. package/cjs/interface/graphic/image.js.map +1 -1
  99. package/cjs/interface/graphic/path.d.ts +1 -0
  100. package/cjs/interface/graphic/path.js.map +1 -1
  101. package/cjs/interface/graphic/rect.d.ts +1 -0
  102. package/cjs/interface/graphic/rect.js.map +1 -1
  103. package/cjs/interface/graphic/richText.d.ts +2 -0
  104. package/cjs/interface/graphic/richText.js.map +1 -1
  105. package/cjs/interface/graphic/symbol.d.ts +2 -0
  106. package/cjs/interface/graphic/symbol.js.map +1 -1
  107. package/cjs/interface/graphic.d.ts +11 -2
  108. package/cjs/interface/graphic.js.map +1 -1
  109. package/cjs/interface/path.d.ts +5 -0
  110. package/cjs/interface/path.js.map +1 -1
  111. package/cjs/interface/picker.d.ts +13 -0
  112. package/cjs/interface/picker.js.map +1 -1
  113. package/cjs/picker/constants.d.ts +2 -0
  114. package/cjs/picker/constants.js +3 -2
  115. package/cjs/picker/constants.js.map +1 -1
  116. package/cjs/picker/pick-interceptor.d.ts +7 -2
  117. package/cjs/picker/pick-interceptor.js +19 -2
  118. package/cjs/picker/pick-interceptor.js.map +1 -1
  119. package/cjs/picker/pick-modules.js +7 -4
  120. package/cjs/picker/pick-modules.js.map +1 -1
  121. package/cjs/picker/picker-service.d.ts +4 -2
  122. package/cjs/picker/picker-service.js +13 -12
  123. package/cjs/picker/picker-service.js.map +1 -1
  124. package/cjs/plugins/builtin-plugin/edit-module.d.ts +15 -5
  125. package/cjs/plugins/builtin-plugin/edit-module.js +123 -42
  126. package/cjs/plugins/builtin-plugin/edit-module.js.map +1 -1
  127. package/cjs/plugins/builtin-plugin/richtext-edit-plugin-old.d.ts +1 -0
  128. package/cjs/plugins/builtin-plugin/richtext-edit-plugin-old.js +3 -0
  129. package/cjs/plugins/builtin-plugin/richtext-edit-plugin-old.js.map +1 -0
  130. package/cjs/plugins/builtin-plugin/richtext-edit-plugin.d.ts +62 -29
  131. package/cjs/plugins/builtin-plugin/richtext-edit-plugin.js +346 -212
  132. package/cjs/plugins/builtin-plugin/richtext-edit-plugin.js.map +1 -1
  133. package/cjs/render/contributions/render/arc3d-render.js.map +1 -1
  134. package/cjs/render/contributions/render/base-render.d.ts +1 -0
  135. package/cjs/render/contributions/render/base-render.js +20 -2
  136. package/cjs/render/contributions/render/base-render.js.map +1 -1
  137. package/cjs/render/contributions/render/contributions/base-contribution-render.d.ts +7 -1
  138. package/cjs/render/contributions/render/contributions/base-contribution-render.js +16 -8
  139. package/cjs/render/contributions/render/contributions/base-contribution-render.js.map +1 -1
  140. package/cjs/render/contributions/render/contributions/base-texture-contribution-render.js +29 -2
  141. package/cjs/render/contributions/render/contributions/base-texture-contribution-render.js.map +1 -1
  142. package/cjs/render/contributions/render/contributions/group-contribution-render.js +8 -3
  143. package/cjs/render/contributions/render/contributions/group-contribution-render.js.map +1 -1
  144. package/cjs/render/contributions/render/contributions/image-contribution-render.d.ts +1 -1
  145. package/cjs/render/contributions/render/contributions/image-contribution-render.js +2 -2
  146. package/cjs/render/contributions/render/contributions/image-contribution-render.js.map +1 -1
  147. package/cjs/render/contributions/render/contributions/rect-contribution-render.js +4 -4
  148. package/cjs/render/contributions/render/contributions/rect-contribution-render.js.map +1 -1
  149. package/cjs/render/contributions/render/contributions/symbol-contribution-render.d.ts +8 -1
  150. package/cjs/render/contributions/render/contributions/symbol-contribution-render.js +30 -2
  151. package/cjs/render/contributions/render/contributions/symbol-contribution-render.js.map +1 -1
  152. package/cjs/render/contributions/render/contributions/text-contribution-render.js +5 -3
  153. package/cjs/render/contributions/render/contributions/text-contribution-render.js.map +1 -1
  154. package/cjs/render/contributions/render/group-render.js +2 -2
  155. package/cjs/render/contributions/render/group-render.js.map +1 -1
  156. package/cjs/render/contributions/render/image-render.js +3 -3
  157. package/cjs/render/contributions/render/image-render.js.map +1 -1
  158. package/cjs/render/contributions/render/path-render.js.map +1 -1
  159. package/cjs/render/contributions/render/polygon-render.js.map +1 -1
  160. package/cjs/render/contributions/render/rect-render.js +2 -2
  161. package/cjs/render/contributions/render/rect-render.js.map +1 -1
  162. package/cjs/render/contributions/render/richtext-render.js +1 -1
  163. package/cjs/render/contributions/render/richtext-render.js.map +1 -1
  164. package/cjs/render/contributions/render/symbol-render.js +15 -13
  165. package/cjs/render/contributions/render/symbol-render.js.map +1 -1
  166. package/cjs/render/contributions/render/utils.d.ts +1 -2
  167. package/cjs/render/contributions/render/utils.js +4 -20
  168. package/cjs/render/contributions/render/utils.js.map +1 -1
  169. package/cjs/resource-loader/loader.js +1 -1
  170. package/cjs/resource-loader/loader.js.map +1 -1
  171. package/dist/index.es.js +8652 -7685
  172. package/es/animate/Ticker/default-ticker.d.ts +2 -0
  173. package/es/animate/Ticker/default-ticker.js +7 -1
  174. package/es/animate/Ticker/default-ticker.js.map +1 -1
  175. package/es/animate/animate.js +1 -1
  176. package/es/animate/animate.js.map +1 -1
  177. package/es/animate/custom-animate.js +14 -25
  178. package/es/animate/custom-animate.js.map +1 -1
  179. package/es/animate/easing-func.d.ts +1 -0
  180. package/es/animate/easing-func.js +10 -0
  181. package/es/animate/easing-func.js.map +1 -0
  182. package/es/animate/easing.d.ts +4 -0
  183. package/es/animate/easing.js +24 -1
  184. package/es/animate/easing.js.map +1 -1
  185. package/es/animate/index.d.ts +1 -0
  186. package/es/animate/index.js +2 -0
  187. package/es/animate/index.js.map +1 -1
  188. package/es/color-string/store.js +1 -2
  189. package/es/common/3d-interceptor.js +2 -1
  190. package/es/common/bezier-utils.d.ts +3 -0
  191. package/es/common/bezier-utils.js +14 -0
  192. package/es/common/bezier-utils.js.map +1 -1
  193. package/es/common/custom-path2d.d.ts +4 -0
  194. package/es/common/custom-path2d.js +44 -12
  195. package/es/common/custom-path2d.js.map +1 -1
  196. package/es/common/render-area.js +1 -2
  197. package/es/common/render-command-list.js +2 -1
  198. package/es/common/segment/curve/arc.d.ts +4 -1
  199. package/es/common/segment/curve/arc.js +10 -1
  200. package/es/common/segment/curve/arc.js.map +1 -1
  201. package/es/common/segment/curve/base.d.ts +4 -1
  202. package/es/common/segment/curve/base.js.map +1 -1
  203. package/es/common/segment/curve/cubic-bezier.d.ts +5 -1
  204. package/es/common/segment/curve/cubic-bezier.js +22 -1
  205. package/es/common/segment/curve/cubic-bezier.js.map +1 -1
  206. package/es/common/segment/curve/curve-context.js +6 -3
  207. package/es/common/segment/curve/curve-context.js.map +1 -1
  208. package/es/common/segment/curve/ellipse.d.ts +4 -1
  209. package/es/common/segment/curve/ellipse.js +9 -0
  210. package/es/common/segment/curve/ellipse.js.map +1 -1
  211. package/es/common/segment/curve/line.d.ts +4 -1
  212. package/es/common/segment/curve/line.js +18 -0
  213. package/es/common/segment/curve/line.js.map +1 -1
  214. package/es/common/segment/curve/move.d.ts +4 -1
  215. package/es/common/segment/curve/move.js +9 -0
  216. package/es/common/segment/curve/move.js.map +1 -1
  217. package/es/common/segment/curve/path.d.ts +2 -1
  218. package/es/common/segment/curve/path.js +5 -2
  219. package/es/common/segment/curve/path.js.map +1 -1
  220. package/es/common/segment/curve/quadratic-bezier.d.ts +6 -2
  221. package/es/common/segment/curve/quadratic-bezier.js +28 -5
  222. package/es/common/segment/curve/quadratic-bezier.js.map +1 -1
  223. package/es/common/shape/rect.d.ts +1 -1
  224. package/es/common/shape/rect.js +30 -25
  225. package/es/common/shape/rect.js.map +1 -1
  226. package/es/common/store.js +1 -1
  227. package/es/core/contributions/env/base-contribution.d.ts +2 -0
  228. package/es/core/contributions/env/base-contribution.js +6 -0
  229. package/es/core/contributions/env/base-contribution.js.map +1 -1
  230. package/es/core/global.d.ts +5 -0
  231. package/es/core/global.js +14 -1
  232. package/es/core/global.js.map +1 -1
  233. package/es/graphic/builtin-symbol/rect.d.ts +2 -1
  234. package/es/graphic/builtin-symbol/rect.js +28 -0
  235. package/es/graphic/builtin-symbol/rect.js.map +1 -1
  236. package/es/graphic/builtin-symbol/utils.d.ts +2 -1
  237. package/es/graphic/builtin-symbol/utils.js +5 -0
  238. package/es/graphic/builtin-symbol/utils.js.map +1 -1
  239. package/es/graphic/config.js +19 -5
  240. package/es/graphic/config.js.map +1 -1
  241. package/es/graphic/graphic.js +15 -1
  242. package/es/graphic/graphic.js.map +1 -1
  243. package/es/graphic/richtext/line.js +1 -1
  244. package/es/graphic/richtext/line.js.map +1 -1
  245. package/es/graphic/richtext/paragraph.d.ts +1 -1
  246. package/es/graphic/richtext/paragraph.js +9 -4
  247. package/es/graphic/richtext/paragraph.js.map +1 -1
  248. package/es/graphic/richtext/utils.d.ts +4 -0
  249. package/es/graphic/richtext/utils.js +15 -2
  250. package/es/graphic/richtext/utils.js.map +1 -1
  251. package/es/graphic/richtext/wrapper.d.ts +1 -0
  252. package/es/graphic/richtext/wrapper.js +1 -1
  253. package/es/graphic/richtext/wrapper.js.map +1 -1
  254. package/es/graphic/richtext.d.ts +7 -2
  255. package/es/graphic/richtext.js +33 -4
  256. package/es/graphic/richtext.js.map +1 -1
  257. package/es/index.d.ts +2 -0
  258. package/es/index.js +4 -0
  259. package/es/index.js.map +1 -1
  260. package/es/interface/animate.d.ts +5 -39
  261. package/es/interface/animate.js.map +1 -1
  262. package/es/interface/context.d.ts +1 -0
  263. package/es/interface/context.js.map +1 -1
  264. package/es/interface/global.d.ts +5 -0
  265. package/es/interface/global.js.map +1 -1
  266. package/es/interface/graphic/group.d.ts +1 -0
  267. package/es/interface/graphic/group.js.map +1 -1
  268. package/es/interface/graphic/image.d.ts +1 -0
  269. package/es/interface/graphic/image.js.map +1 -1
  270. package/es/interface/graphic/path.d.ts +1 -0
  271. package/es/interface/graphic/path.js.map +1 -1
  272. package/es/interface/graphic/rect.d.ts +1 -0
  273. package/es/interface/graphic/rect.js.map +1 -1
  274. package/es/interface/graphic/richText.d.ts +2 -0
  275. package/es/interface/graphic/richText.js.map +1 -1
  276. package/es/interface/graphic/symbol.d.ts +2 -0
  277. package/es/interface/graphic/symbol.js.map +1 -1
  278. package/es/interface/graphic.d.ts +11 -2
  279. package/es/interface/graphic.js.map +1 -1
  280. package/es/interface/path.d.ts +5 -0
  281. package/es/interface/path.js.map +1 -1
  282. package/es/interface/picker.d.ts +13 -0
  283. package/es/interface/picker.js.map +1 -1
  284. package/es/picker/constants.d.ts +2 -0
  285. package/es/picker/constants.js +4 -0
  286. package/es/picker/constants.js.map +1 -1
  287. package/es/picker/pick-interceptor.d.ts +7 -2
  288. package/es/picker/pick-interceptor.js +19 -1
  289. package/es/picker/pick-interceptor.js.map +1 -1
  290. package/es/picker/pick-modules.js +5 -3
  291. package/es/picker/pick-modules.js.map +1 -1
  292. package/es/picker/picker-service.d.ts +4 -2
  293. package/es/picker/picker-service.js +13 -13
  294. package/es/picker/picker-service.js.map +1 -1
  295. package/es/plugins/builtin-plugin/edit-module.d.ts +15 -5
  296. package/es/plugins/builtin-plugin/edit-module.js +119 -40
  297. package/es/plugins/builtin-plugin/edit-module.js.map +1 -1
  298. package/es/plugins/builtin-plugin/richtext-edit-plugin-old.d.ts +1 -0
  299. package/es/plugins/builtin-plugin/richtext-edit-plugin-old.js +3 -0
  300. package/es/plugins/builtin-plugin/richtext-edit-plugin-old.js.map +1 -0
  301. package/es/plugins/builtin-plugin/richtext-edit-plugin.d.ts +62 -29
  302. package/es/plugins/builtin-plugin/richtext-edit-plugin.js +349 -211
  303. package/es/plugins/builtin-plugin/richtext-edit-plugin.js.map +1 -1
  304. package/es/render/contributions/render/arc3d-render.js.map +1 -1
  305. package/es/render/contributions/render/base-render.d.ts +1 -0
  306. package/es/render/contributions/render/base-render.js +21 -2
  307. package/es/render/contributions/render/base-render.js.map +1 -1
  308. package/es/render/contributions/render/contributions/base-contribution-render.d.ts +7 -1
  309. package/es/render/contributions/render/contributions/base-contribution-render.js +16 -8
  310. package/es/render/contributions/render/contributions/base-contribution-render.js.map +1 -1
  311. package/es/render/contributions/render/contributions/base-texture-contribution-render.js +29 -2
  312. package/es/render/contributions/render/contributions/base-texture-contribution-render.js.map +1 -1
  313. package/es/render/contributions/render/contributions/group-contribution-render.js +8 -3
  314. package/es/render/contributions/render/contributions/group-contribution-render.js.map +1 -1
  315. package/es/render/contributions/render/contributions/image-contribution-render.d.ts +1 -1
  316. package/es/render/contributions/render/contributions/image-contribution-render.js +2 -2
  317. package/es/render/contributions/render/contributions/image-contribution-render.js.map +1 -1
  318. package/es/render/contributions/render/contributions/rect-contribution-render.js +4 -4
  319. package/es/render/contributions/render/contributions/rect-contribution-render.js.map +1 -1
  320. package/es/render/contributions/render/contributions/symbol-contribution-render.d.ts +8 -1
  321. package/es/render/contributions/render/contributions/symbol-contribution-render.js +26 -0
  322. package/es/render/contributions/render/contributions/symbol-contribution-render.js.map +1 -1
  323. package/es/render/contributions/render/contributions/text-contribution-render.js +5 -3
  324. package/es/render/contributions/render/contributions/text-contribution-render.js.map +1 -1
  325. package/es/render/contributions/render/group-render.js +2 -2
  326. package/es/render/contributions/render/group-render.js.map +1 -1
  327. package/es/render/contributions/render/image-render.js +3 -2
  328. package/es/render/contributions/render/image-render.js.map +1 -1
  329. package/es/render/contributions/render/path-render.js.map +1 -1
  330. package/es/render/contributions/render/polygon-render.js.map +1 -1
  331. package/es/render/contributions/render/rect-render.js +2 -2
  332. package/es/render/contributions/render/rect-render.js.map +1 -1
  333. package/es/render/contributions/render/richtext-render.js +1 -1
  334. package/es/render/contributions/render/richtext-render.js.map +1 -1
  335. package/es/render/contributions/render/symbol-render.js +16 -14
  336. package/es/render/contributions/render/symbol-render.js.map +1 -1
  337. package/es/render/contributions/render/utils.d.ts +1 -2
  338. package/es/render/contributions/render/utils.js +0 -18
  339. package/es/render/contributions/render/utils.js.map +1 -1
  340. package/es/resource-loader/loader.js +1 -1
  341. package/es/resource-loader/loader.js.map +1 -1
  342. package/package.json +3 -3
@@ -28,7 +28,7 @@ export class DefaultBaseBackgroundRenderContribution {
28
28
  }
29
29
  drawShape(graphic, context, x, y, doFill, doStroke, fVisible, sVisible, graphicAttribute, drawContext, fillCb, strokeCb, options) {
30
30
  var _a;
31
- const {background: background, backgroundOpacity: backgroundOpacity = (null !== (_a = graphic.attribute.fillOpacity) && void 0 !== _a ? _a : graphicAttribute.backgroundOpacity), opacity: opacity = graphicAttribute.opacity, backgroundMode: backgroundMode = graphicAttribute.backgroundMode, backgroundFit: backgroundFit = graphicAttribute.backgroundFit} = graphic.attribute;
31
+ const {background: background, backgroundOpacity: backgroundOpacity = (null !== (_a = graphic.attribute.fillOpacity) && void 0 !== _a ? _a : graphicAttribute.backgroundOpacity), opacity: opacity = graphicAttribute.opacity, backgroundMode: backgroundMode = graphicAttribute.backgroundMode, backgroundFit: backgroundFit = graphicAttribute.backgroundFit, backgroundScale: backgroundScale = graphicAttribute.backgroundScale, backgroundOffsetX: backgroundOffsetX = graphicAttribute.backgroundOffsetX, backgroundOffsetY: backgroundOffsetY = graphicAttribute.backgroundOffsetY, backgroundClip: backgroundClip = graphicAttribute.backgroundClip} = graphic.attribute;
32
32
  if (background) if (graphic.backgroundImg && graphic.resources) {
33
33
  const res = graphic.resources.get(background);
34
34
  if ("success" !== res.state || !res.data) return;
@@ -36,19 +36,27 @@ export class DefaultBaseBackgroundRenderContribution {
36
36
  const groupAttribute = getTheme(graphic.parent).group, {scrollX: scrollX = groupAttribute.scrollX, scrollY: scrollY = groupAttribute.scrollY} = graphic.parent.attribute;
37
37
  context.setTransformFromMatrix(graphic.parent.globalTransMatrix, !0), context.translate(scrollX, scrollY);
38
38
  }
39
- context.clip();
39
+ backgroundClip && context.clip();
40
40
  const b = graphic.AABBBounds;
41
41
  context.setCommonStyle(graphic, graphic.attribute, x, y, graphicAttribute), context.globalAlpha = backgroundOpacity * opacity,
42
- this.doDrawImage(context, res.data, b, backgroundMode, backgroundFit), context.restore(),
43
- graphic.transMatrix.onlyTranslate() || context.setTransformForCurrent();
42
+ this.doDrawImage(context, res.data, b, {
43
+ backgroundMode: backgroundMode,
44
+ backgroundFit: backgroundFit,
45
+ backgroundScale: backgroundScale,
46
+ backgroundOffsetX: backgroundOffsetX,
47
+ backgroundOffsetY: backgroundOffsetY
48
+ }), context.restore(), graphic.transMatrix.onlyTranslate() || context.setTransformForCurrent();
44
49
  } else context.highPerformanceSave(), context.setCommonStyle(graphic, graphic.attribute, x, y, graphicAttribute),
45
50
  context.globalAlpha = backgroundOpacity * opacity, context.fillStyle = background,
46
51
  context.fill(), context.highPerformanceRestore();
47
52
  }
48
- doDrawImage(context, data, b, backgroundMode, backgroundFit) {
49
- if ("no-repeat" === backgroundMode) context.drawImage(data, b.x1, b.y1, b.width(), b.height()); else {
50
- const targetW = b.width(), targetH = b.height();
51
- let w = targetW, h = targetH;
53
+ doDrawImage(context, data, b, params) {
54
+ const {backgroundMode: backgroundMode, backgroundFit: backgroundFit, backgroundScale: backgroundScale = 1, backgroundOffsetX: backgroundOffsetX = 0, backgroundOffsetY: backgroundOffsetY = 0} = params, targetW = b.width(), targetH = b.height();
55
+ let w = targetW, h = targetH;
56
+ if ("no-repeat" === backgroundMode) if (backgroundFit) context.drawImage(data, b.x1, b.y1, b.width(), b.height()); else {
57
+ const resW = data.width * backgroundScale, resH = data.height * backgroundScale;
58
+ context.drawImage(data, b.x1 + backgroundOffsetX, b.y1 + backgroundOffsetY, resW, resH);
59
+ } else {
52
60
  if (backgroundFit && "repeat" !== backgroundMode && (data.width || data.height)) {
53
61
  const resW = data.width, resH = data.height;
54
62
  if ("repeat-x" === backgroundMode) {
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/render/contributions/render/contributions/base-contribution-render.ts"],"names":[],"mappings":";;;;;;;;;;;;AAUA,OAAO,EAAE,MAAM,EAAE,UAAU,EAAE,KAAK,EAAE,MAAM,mCAAmC,CAAC;AAC9E,OAAO,EAAE,QAAQ,EAAE,MAAM,2BAA2B,CAAC;AACrD,OAAO,EAAE,cAAc,EAAE,MAAM,uCAAuC,CAAC;AACvE,OAAO,EAAE,0BAA0B,EAAE,MAAM,0BAA0B,CAAC;AACtE,OAAO,EAAE,oBAAoB,EAAE,MAAM,0CAA0C,CAAC;AAChF,OAAO,EAAE,gCAAgC,EAAE,MAAM,aAAa,CAAC;AAE/D,MAAM,OAAO,uCAAuC;IAApD;QACE,SAAI,GAA+B,0BAA0B,CAAC,gBAAgB,CAAC;QAC/E,aAAQ,GAAY,IAAI,CAAC;QACzB,UAAK,GAAW,CAAC,CAAC;IAkHpB,CAAC;IAjHC,SAAS,CACP,OAAiB,EACjB,OAAmB,EACnB,CAAS,EACT,CAAS,EACT,MAAe,EACf,QAAiB,EACjB,QAAiB,EACjB,QAAiB,EACjB,gBAA6C,EAC7C,WAAyB,EACzB,MAAiH,EACjH,QAAmH,EACnH,OAAa;;QAEb,MAAM,EACJ,UAAU,EACV,iBAAiB,GAAG,MAAA,OAAO,CAAC,SAAS,CAAC,WAAW,mCAAI,gBA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EACR,gBAAgB,EAChB,WAAW,EACX,MAAM,EACN,QAAQ,EACR,OAAO,CACR,CAAC;QACJ,CAAC,CAAC,CAAC;IACL,CAAC;CACF,CAAA;AAhDY,wCAAwC;IADpD,UAAU,EAAE;IAQR,WAAA,MAAM,CAAC,oBAAoB,CAAC,CAAA;IAC5B,WAAA,KAAK,CAAC,gCAAgC,CAAC,CAAA;;GAR/B,wCAAwC,CAgDpD;SAhDY,wCAAwC","file":"base-contribution-render.js","sourcesContent":["import type {\n IGraphicAttribute,\n IContext2d,\n IGraphic,\n IThemeAttribute,\n IBaseRenderContribution,\n IContributionProvider,\n IDrawContext\n} from '../../../../interface';\nimport type { IBounds } from '@visactor/vutils';\nimport { inject, injectable, named } from '../../../../common/inversify-lite';\nimport { getTheme } from '../../../../graphic/theme';\nimport { canvasAllocate } from '../../../../allocator/canvas-allocate';\nimport { BaseRenderContributionTime } from '../../../../common/enums';\nimport { ContributionProvider } from '../../../../common/contribution-provider';\nimport { InteractiveSubRenderContribution } from './constants';\n\nexport class DefaultBaseBackgroundRenderContribution implements IBaseRenderContribution<IGraphic, IGraphicAttribute> {\n time: BaseRenderContributionTime = BaseRenderContributionTime.beforeFillStroke;\n useStyle: boolean = true;\n order: number = 0;\n drawShape(\n graphic: IGraphic,\n context: IContext2d,\n x: number,\n y: number,\n doFill: boolean,\n doStroke: boolean,\n fVisible: boolean,\n sVisible: boolean,\n graphicAttribute: Required<IGraphicAttribute>,\n drawContext: IDrawContext,\n fillCb?: (ctx: IContext2d, markAttribute: Partial<IGraphicAttribute>, themeAttribute: IThemeAttribute) => boolean,\n strokeCb?: (ctx: IContext2d, markAttribute: Partial<IGraphicAttribute>, themeAttribute: IThemeAttribute) => boolean,\n options?: any\n ) {\n const {\n background,\n backgroundOpacity = graphic.attribute.fillOpacity ?? graphicAttribute.backgroundOpacity,\n opacity = graphicAttribute.opacity,\n backgroundMode = graphicAttribute.backgroundMode,\n backgroundFit = graphicAttribute.backgroundFit\n } = graphic.attribute;\n if (!background) {\n return;\n }\n\n if (graphic.backgroundImg && graphic.resources) {\n const res = graphic.resources.get(background as any);\n if (res.state !== 'success' || !res.data) {\n return;\n }\n\n context.save();\n\n if (graphic.parent && !graphic.transMatrix.onlyTranslate()) {\n const groupAttribute = getTheme(graphic.parent).group;\n const { scrollX = groupAttribute.scrollX, scrollY = groupAttribute.scrollY } = graphic.parent.attribute;\n context.setTransformFromMatrix(graphic.parent.globalTransMatrix, true);\n context.translate(scrollX, scrollY);\n }\n context.clip();\n const b = graphic.AABBBounds;\n context.setCommonStyle(graphic, graphic.attribute, x, y, graphicAttribute);\n context.globalAlpha = backgroundOpacity * opacity;\n this.doDrawImage(context, res.data, b, backgroundMode, backgroundFit);\n context.restore();\n if (!graphic.transMatrix.onlyTranslate()) {\n context.setTransformForCurrent();\n }\n } else {\n context.highPerformanceSave();\n context.setCommonStyle(graphic, graphic.attribute, x, y, graphicAttribute);\n context.globalAlpha = backgroundOpacity * opacity;\n context.fillStyle = background as string;\n context.fill();\n context.highPerformanceRestore();\n }\n }\n\n protected doDrawImage(\n context: IContext2d,\n data: any,\n b: IBounds,\n backgroundMode: 'repeat' | 'repeat-x' | 'repeat-y' | 'no-repeat',\n backgroundFit: boolean\n ): void {\n if (backgroundMode === 'no-repeat') {\n context.drawImage(data, b.x1, b.y1, b.width(), b.height());\n } else {\n const targetW = b.width();\n const targetH = b.height();\n let w = targetW;\n let h = targetH;\n // debugger;\n // TODO 考虑缓存\n if (backgroundFit && backgroundMode !== 'repeat' && (data.width || data.height)) {\n const resW = data.width;\n const resH = data.height;\n\n if (backgroundMode === 'repeat-x') {\n // 高度适应\n const ratio = targetH / resH;\n w = resW * ratio;\n h = targetH;\n } else if (backgroundMode === 'repeat-y') {\n // 宽度适应\n const ratio = targetW / resW;\n h = resH * ratio;\n w = targetW;\n }\n\n const dpr = context.dpr;\n const canvas = canvasAllocate.allocate({ width: w, height: h, dpr });\n const ctx = canvas.getContext('2d');\n if (ctx) {\n ctx.inuse = true;\n ctx.clearMatrix();\n ctx.setTransformForCurrent(true);\n ctx.clearRect(0, 0, w, h);\n ctx.drawImage(data, 0, 0, w, h);\n data = canvas.nativeCanvas;\n }\n canvasAllocate.free(canvas);\n }\n const dpr = context.dpr;\n const pattern = context.createPattern(data, backgroundMode);\n pattern.setTransform && pattern.setTransform(new DOMMatrix([1 / dpr, 0, 0, 1 / dpr, 0, 0]));\n context.fillStyle = pattern;\n context.translate(b.x1, b.y1);\n context.fillRect(0, 0, targetW, targetH);\n context.translate(-b.x1, -b.y1);\n }\n }\n}\n\nexport const defaultBaseBackgroundRenderContribution = new DefaultBaseBackgroundRenderContribution();\n\nexport interface IInteractiveSubRenderContribution {\n render: (\n graphic: IGraphic,\n context: IContext2d,\n x: number,\n y: number,\n doFill: boolean,\n doStroke: boolean,\n fVisible: boolean,\n sVisible: boolean,\n graphicAttribute: Required<IGraphicAttribute>,\n drawContext: IDrawContext,\n fillCb?: (ctx: IContext2d, markAttribute: Partial<IGraphicAttribute>, themeAttribute: IThemeAttribute) => boolean,\n strokeCb?: (ctx: IContext2d, markAttribute: Partial<IGraphicAttribute>, themeAttribute: IThemeAttribute) => boolean,\n options?: any\n ) => void;\n}\n\n@injectable()\nexport class DefaultBaseInteractiveRenderContribution implements IBaseRenderContribution<IGraphic, IGraphicAttribute> {\n time: BaseRenderContributionTime = BaseRenderContributionTime.afterFillStroke;\n useStyle: boolean = true;\n order: number = 0;\n\n _subRenderContribitions?: IInteractiveSubRenderContribution[];\n constructor(\n @inject(ContributionProvider)\n @named(InteractiveSubRenderContribution)\n protected readonly subRenderContribitions: IContributionProvider<IInteractiveSubRenderContribution>\n ) {}\n\n drawShape(\n graphic: IGraphic,\n context: IContext2d,\n x: number,\n y: number,\n doFill: boolean,\n doStroke: boolean,\n fVisible: boolean,\n sVisible: boolean,\n graphicAttribute: Required<IGraphicAttribute>,\n drawContext: IDrawContext,\n fillCb?: (ctx: IContext2d, markAttribute: Partial<IGraphicAttribute>, themeAttribute: IThemeAttribute) => boolean,\n strokeCb?: (ctx: IContext2d, markAttribute: Partial<IGraphicAttribute>, themeAttribute: IThemeAttribute) => boolean,\n options?: any\n ) {\n if (!this._subRenderContribitions) {\n this._subRenderContribitions = this.subRenderContribitions.getContributions();\n }\n this._subRenderContribitions.forEach(c => {\n c.render(\n graphic,\n context,\n x,\n y,\n doFill,\n doStroke,\n fVisible,\n sVisible,\n graphicAttribute,\n drawContext,\n fillCb,\n strokeCb,\n options\n );\n });\n }\n}\n\n// const rect1 =\n// // @ts-ignore\n// 'data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAFEAAABRCAYAAACqj0o2AAAAAXNSR0IArs4c6QAAByRJREFUeF7tnU1oXUUUx/+XLirxA8QGSdA0tGBNRFNBxYJCoRsXKkZQVFSwKKKFLhp14cbiwoWYgoEiorSgolIRQV24KRQUFAzYKMZaaIm1JEgiQtVgF+XKvPvmvbn3zsf/zLs3Hy/vbTMz557fnDkzc2bmJEnTNEXEb2Lfs5g8/HZETWGVS/9lFTZdJqwoLx6rUxIF8fwpJNePID1yAHhqUv61bA0FcPZwVnp0X70gj04g2XsI6e+/ANfdyH5ho5wc4vlTwGt7kLw1j/RJALtrBHn2Y2Dx20yhvqH6QB6dAE4cQvIekD43CLx8XARSBrEJEP/OZwIVRPWrA6QJUNvFVTuAkedFVhIs3ATYsCit0+UykDxEA2BOoP7KKkHaAGo5/buAbY8E2VAFDIAlnQQgOYgFgFaIVVmkD2CVIAsArTqRIMMQLQCdEDsFyQCsAqQFoFMnAqQfogOgF2IsSAnATkA6AHp1CoB0Q/QADEKUgvzjG2DuE8qNlQpJfKQHYFAnD0g7xADAoEDJZLM0DZx5Pw6grjWwBxi6399GACClkwNkGSIBkBLIgKwCoJaz/Qlgy212kARAVbH/GLD4cKA/LSDzEEmAIoiuoV0lQB9IEqBIpwLINkQBQJFAm0XWAdAGUgBQrJMBMoMoBCgWaIK879HOfWDIg6qh/cVHja2c5JfbhTEVmyAziMdexYMvvoLPzjE1uTLj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b1ze9j1ojiGC6oniuOZ5boxnmjVqZJ4ogNkN0a2S3vnSiPbFpDdeMaSm50Fq4qwTywuW3qnfaWFnByiaqJ37pwDGQexdwOiAog66UTvLk4WuBBnIzGTTqgcEFVfq/MFDwTOno6D2fJa1HorzLgxm7v4XjXIrr2f6Es6obq9KpBMsKAKi2TyWpAWyQ3nDXJne+xLYObegiMgQIYhbqDXAxPTwKTt3XlHrwd671jaZhn1jqWTpBMSH8n4QN9Uy17rI56mVfuiqve2z91t1Ns+AmBjgWnmCvNZyjp6ZUrrVAAZ/d45+EDSBLth3juTFqjZ0L2mK3T9y/sackDQ2651XrCdA4KYuYq6ii1RNaB8SddmI1EKCkGKIZrOWHgzQWSs5pawThdVyoujv1IAUgTRtlCtA6RtTy0ASU+WzgxNQpA0RN+WqUqQFeQKo3QK5goTgKQEEpt362tS0fgFsOay1pEggxAZgFpWV+ZPJEDGJp1wGhl5Gy1XnzhYL8mLCapEZ/IMgIxNOuEdqRKQMQC1cEl4jwg2h+OJjuVPbNKJoLtjQHYC0AMyNq8FB9ECsrQckPjAEMmuzLNtGdqxSSdC/Fp/78qM7wWQvf890DYHfjibJtT7Lxi5ARUHEcDYTaOY+XmWHp3RBVfw/7HE6vQ/kFqNtpDetQkAAAAASUVORK5CYII=';\n"]}
1
+ {"version":3,"sources":["../src/render/contributions/render/contributions/base-contribution-render.ts"],"names":[],"mappings":";;;;;;;;;;;;AAaA,OAAO,EAAE,MAAM,EAAE,UAAU,EAAE,KAAK,EAAE,MAAM,mCAAmC,CAAC;AAC9E,OAAO,EAAE,QAAQ,EAAE,MAAM,2BAA2B,CAAC;AACrD,OAAO,EAAE,cAAc,EAAE,MAAM,uCAAuC,CAAC;AACvE,OAAO,EAAE,0BAA0B,EAAE,MAAM,0BAA0B,CAAC;AACtE,OAAO,EAAE,oBAAoB,EAAE,MAAM,0CAA0C,CAAC;AAChF,OAAO,EAAE,gCAAgC,EAAE,MAAM,aAAa,CAAC;AAE/D,MAAM,OAAO,uC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AA,MAAM,CAAC,oBAAoB,CAAC,CAAA;IAC5B,WAAA,KAAK,CAAC,gCAAgC,CAAC,CAAA;;GAR/B,wCAAwC,CAgDpD;SAhDY,wCAAwC","file":"base-contribution-render.js","sourcesContent":["import type {\n IGraphicAttribute,\n IContext2d,\n IGraphic,\n IThemeAttribute,\n IBaseRenderContribution,\n IContributionProvider,\n IDrawContext,\n ISymbol,\n IPath,\n ISymbolGraphicAttribute\n} from '../../../../interface';\nimport type { IBounds } from '@visactor/vutils';\nimport { inject, injectable, named } from '../../../../common/inversify-lite';\nimport { getTheme } from '../../../../graphic/theme';\nimport { canvasAllocate } from '../../../../allocator/canvas-allocate';\nimport { BaseRenderContributionTime } from '../../../../common/enums';\nimport { ContributionProvider } from '../../../../common/contribution-provider';\nimport { InteractiveSubRenderContribution } from './constants';\n\nexport class DefaultBaseBackgroundRenderContribution implements IBaseRenderContribution<IGraphic, IGraphicAttribute> {\n time: BaseRenderContributionTime = BaseRenderContributionTime.beforeFillStroke;\n useStyle: boolean = true;\n order: number = 0;\n drawShape(\n graphic: IGraphic,\n context: IContext2d,\n x: number,\n y: number,\n doFill: boolean,\n doStroke: boolean,\n fVisible: boolean,\n sVisible: boolean,\n graphicAttribute: Required<IGraphicAttribute>,\n drawContext: IDrawContext,\n fillCb?: (ctx: IContext2d, markAttribute: Partial<IGraphicAttribute>, themeAttribute: IThemeAttribute) => boolean,\n strokeCb?: (ctx: IContext2d, markAttribute: Partial<IGraphicAttribute>, themeAttribute: IThemeAttribute) => boolean,\n options?: any\n ) {\n const {\n background,\n backgroundOpacity = graphic.attribute.fillOpacity ?? graphicAttribute.backgroundOpacity,\n opacity = graphicAttribute.opacity,\n backgroundMode = graphicAttribute.backgroundMode,\n backgroundFit = graphicAttribute.backgroundFit,\n backgroundScale = graphicAttribute.backgroundScale,\n backgroundOffsetX = graphicAttribute.backgroundOffsetX,\n backgroundOffsetY = graphicAttribute.backgroundOffsetY,\n backgroundClip = graphicAttribute.backgroundClip\n } = graphic.attribute;\n if (!background) {\n return;\n }\n\n if (graphic.backgroundImg && graphic.resources) {\n const res = graphic.resources.get(background as any);\n if (res.state !== 'success' || !res.data) {\n return;\n }\n\n context.save();\n\n if (graphic.parent && !graphic.transMatrix.onlyTranslate()) {\n const groupAttribute = getTheme(graphic.parent).group;\n const { scrollX = groupAttribute.scrollX, scrollY = groupAttribute.scrollY } = graphic.parent.attribute;\n context.setTransformFromMatrix(graphic.parent.globalTransMatrix, true);\n context.translate(scrollX, scrollY);\n }\n backgroundClip && context.clip();\n const b = graphic.AABBBounds;\n context.setCommonStyle(graphic, graphic.attribute, x, y, graphicAttribute);\n context.globalAlpha = backgroundOpacity * opacity;\n this.doDrawImage(context, res.data, b, {\n backgroundMode,\n backgroundFit,\n backgroundScale,\n backgroundOffsetX,\n backgroundOffsetY\n });\n context.restore();\n if (!graphic.transMatrix.onlyTranslate()) {\n context.setTransformForCurrent();\n }\n } else {\n context.highPerformanceSave();\n context.setCommonStyle(graphic, graphic.attribute, x, y, graphicAttribute);\n context.globalAlpha = backgroundOpacity * opacity;\n context.fillStyle = background as string;\n context.fill();\n context.highPerformanceRestore();\n }\n }\n\n protected doDrawImage(\n context: IContext2d,\n data: any,\n b: IBounds,\n params: {\n backgroundMode: 'repeat' | 'repeat-x' | 'repeat-y' | 'no-repeat';\n backgroundFit: boolean;\n backgroundScale?: number;\n backgroundOffsetX?: number;\n backgroundOffsetY?: number;\n }\n ): void {\n const { backgroundMode, backgroundFit, backgroundScale = 1, backgroundOffsetX = 0, backgroundOffsetY = 0 } = params;\n const targetW = b.width();\n const targetH = b.height();\n let w = targetW;\n let h = targetH;\n if (backgroundMode === 'no-repeat') {\n if (backgroundFit) {\n context.drawImage(data, b.x1, b.y1, b.width(), b.height());\n } else {\n const resW = data.width * backgroundScale;\n const resH = data.height * backgroundScale;\n context.drawImage(data, b.x1 + backgroundOffsetX, b.y1 + backgroundOffsetY, resW, resH);\n }\n } else {\n // debugger;\n // TODO 考虑缓存\n if (backgroundFit && backgroundMode !== 'repeat' && (data.width || data.height)) {\n const resW = data.width;\n const resH = data.height;\n\n if (backgroundMode === 'repeat-x') {\n // 高度适应\n const ratio = targetH / resH;\n w = resW * ratio;\n h = targetH;\n } else if (backgroundMode === 'repeat-y') {\n // 宽度适应\n const ratio = targetW / resW;\n h = resH * ratio;\n w = targetW;\n }\n\n const dpr = context.dpr;\n const canvas = canvasAllocate.allocate({ width: w, height: h, dpr });\n const ctx = canvas.getContext('2d');\n if (ctx) {\n ctx.inuse = true;\n ctx.clearMatrix();\n ctx.setTransformForCurrent(true);\n ctx.clearRect(0, 0, w, h);\n ctx.drawImage(data, 0, 0, w, h);\n data = canvas.nativeCanvas;\n }\n canvasAllocate.free(canvas);\n }\n const dpr = context.dpr;\n const pattern = context.createPattern(data, backgroundMode);\n pattern.setTransform && pattern.setTransform(new DOMMatrix([1 / dpr, 0, 0, 1 / dpr, 0, 0]));\n context.fillStyle = pattern;\n context.translate(b.x1, b.y1);\n context.fillRect(0, 0, targetW, targetH);\n context.translate(-b.x1, -b.y1);\n }\n }\n}\n\nexport const defaultBaseBackgroundRenderContribution = new DefaultBaseBackgroundRenderContribution();\n\nexport interface IInteractiveSubRenderContribution {\n render: (\n graphic: IGraphic,\n context: IContext2d,\n x: number,\n y: number,\n doFill: boolean,\n doStroke: boolean,\n fVisible: boolean,\n sVisible: boolean,\n graphicAttribute: Required<IGraphicAttribute>,\n drawContext: IDrawContext,\n fillCb?: (ctx: IContext2d, markAttribute: Partial<IGraphicAttribute>, themeAttribute: IThemeAttribute) => boolean,\n strokeCb?: (ctx: IContext2d, markAttribute: Partial<IGraphicAttribute>, themeAttribute: IThemeAttribute) => boolean,\n options?: any\n ) => void;\n}\n\n@injectable()\nexport class DefaultBaseInteractiveRenderContribution implements IBaseRenderContribution<IGraphic, IGraphicAttribute> {\n time: BaseRenderContributionTime = BaseRenderContributionTime.afterFillStroke;\n useStyle: boolean = true;\n order: number = 0;\n\n _subRenderContribitions?: IInteractiveSubRenderContribution[];\n constructor(\n @inject(ContributionProvider)\n @named(InteractiveSubRenderContribution)\n protected readonly subRenderContribitions: IContributionProvider<IInteractiveSubRenderContribution>\n ) {}\n\n drawShape(\n graphic: IGraphic,\n context: IContext2d,\n x: number,\n y: number,\n doFill: boolean,\n doStroke: boolean,\n fVisible: boolean,\n sVisible: boolean,\n graphicAttribute: Required<IGraphicAttribute>,\n drawContext: IDrawContext,\n fillCb?: (ctx: IContext2d, markAttribute: Partial<IGraphicAttribute>, themeAttribute: IThemeAttribute) => boolean,\n strokeCb?: (ctx: IContext2d, markAttribute: Partial<IGraphicAttribute>, themeAttribute: IThemeAttribute) => boolean,\n options?: any\n ) {\n if (!this._subRenderContribitions) {\n this._subRenderContribitions = this.subRenderContribitions.getContributions();\n }\n this._subRenderContribitions.forEach(c => {\n c.render(\n graphic,\n context,\n x,\n y,\n doFill,\n doStroke,\n fVisible,\n sVisible,\n graphicAttribute,\n drawContext,\n fillCb,\n strokeCb,\n options\n );\n });\n }\n}\n"]}
@@ -4,6 +4,25 @@ import { BaseRenderContributionTime } from "../../../../common/enums";
4
4
 
5
5
  import { pi2 } from "@visactor/vutils";
6
6
 
7
+ function formatRatio(ratio) {
8
+ return ratio <= .5 ? 4 * ratio - 1 : -4 * ratio + 3;
9
+ }
10
+
11
+ function drawWave(ctx, ratio, boundsWidth, boundsHeight, textureOptions, offsetX, offsetY) {
12
+ const {fill: fill = "orange", percent: percent = .6, frequency: frequency = 4, opacity: opacity, phi: phi = 0} = textureOptions;
13
+ let {amplitude: amplitude = 10} = textureOptions;
14
+ amplitude *= formatRatio(ratio);
15
+ const height = boundsHeight * (1 - percent), width = boundsWidth, step = Math.max(Math.round(width / 70), 2);
16
+ ctx.beginPath(), ctx.moveTo(0 + offsetX, boundsHeight + offsetY), ctx.lineTo(0 + offsetX, height + offsetY);
17
+ const delta = width / frequency * ratio, c = width / Math.PI / (2 * frequency);
18
+ for (let i = 0; i < width; i += step) {
19
+ const y = amplitude * Math.sin((i + delta + phi) / c + phi);
20
+ ctx.lineTo(i + offsetX, height + y + offsetY);
21
+ }
22
+ ctx.lineTo(width + offsetX, boundsHeight + offsetY), ctx.closePath(), ctx.fillStyle = fill,
23
+ isFinite(opacity) && (ctx.globalAlpha = opacity), ctx.fill();
24
+ }
25
+
7
26
  export class DefaultBaseTextureRenderContribution {
8
27
  constructor() {
9
28
  this.time = BaseRenderContributionTime.afterFillStroke, this.useStyle = !0, this.order = 10;
@@ -82,6 +101,7 @@ export class DefaultBaseTextureRenderContribution {
82
101
  texture && this.drawTexture(texture, graphic, context, x, y, graphicAttribute, textureColor, textureSize, texturePadding);
83
102
  }
84
103
  drawTexture(texture, graphic, context, x, y, graphicAttribute, textureColor, textureSize, texturePadding) {
104
+ const {textureRatio: textureRatio = graphicAttribute.textureRatio, textureOptions: textureOptions = null} = graphic.attribute;
85
105
  let pattern = this.textureMap.get(texture);
86
106
  if (!pattern) switch (texture) {
87
107
  case "circle":
@@ -115,8 +135,15 @@ export class DefaultBaseTextureRenderContribution {
115
135
  case "grid":
116
136
  pattern = this.createGridPattern(textureSize, texturePadding, textureColor, context);
117
137
  }
118
- pattern && (context.highPerformanceSave(), context.setCommonStyle(graphic, graphic.attribute, x, y, graphicAttribute),
119
- context.fillStyle = pattern, context.fill(), context.highPerformanceRestore());
138
+ if (pattern) context.highPerformanceSave(), context.setCommonStyle(graphic, graphic.attribute, x, y, graphicAttribute),
139
+ context.fillStyle = pattern, context.fill(), context.highPerformanceRestore(); else if ("wave" === texture) {
140
+ context.save(), context.setCommonStyle(graphic, graphic.attribute, x, y, graphicAttribute),
141
+ context.clip();
142
+ const b = graphic.AABBBounds;
143
+ drawWave(context, textureRatio, b.width(), b.height(), Object.assign(Object.assign({}, textureOptions || {}), {
144
+ fill: textureColor
145
+ }), x + b.x1 - x, y + b.y1 - y), context.restore();
146
+ }
120
147
  }
121
148
  }
122
149
 
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/render/contributions/render/contributions/base-texture-contribution-render.ts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":["import { canvasAllocate } from '../../../../allocator/canvas-allocate';\nimport { BaseRenderContributionTime } from '../../../../common/enums';\nimport type {\n IBaseRenderContribution,\n IContext2d,\n IDrawContext,\n IGraphic,\n IGraphicAttribute,\n IStage,\n IThemeAttribute\n} from '../../../../interface';\nimport { pi2 } from '@visactor/vutils';\n\nexport class DefaultBaseTextureRenderContribution implements IBaseRenderContribution<IGraphic, IGraphicAttribute> {\n time: BaseRenderContributionTime = BaseRenderContributionTime.afterFillStroke;\n useStyle: boolean = true;\n textureMap?: Map<string, CanvasPattern>;\n order: number = 10;\n\n createCommonPattern(\n size: number,\n padding: number,\n color: string,\n targetContext: IContext2d,\n cb: (r: number, targetContext: IContext2d) => void\n ) {\n const r = (size - padding * 2) / 2;\n const dpr = targetContext.dpr;\n const canvas = canvasAllocate.allocate({ width: size, height: size, dpr });\n const ctx = canvas.getContext('2d');\n if (!ctx) {\n return null;\n }\n ctx.inuse = true;\n ctx.clearMatrix();\n ctx.setTransformForCurrent(true);\n ctx.clearRect(0, 0, size, size);\n //setup up design for pattern\n cb(r, ctx);\n const pattern = targetContext.createPattern(canvas.nativeCanvas, 'repeat');\n pattern.setTransform && pattern.setTransform(new DOMMatrix([1 / dpr, 0, 0, 1 / dpr, 0, 0]));\n\n canvasAllocate.free(canvas);\n return pattern;\n }\n\n createCirclePattern(size: number, padding: number, color: string, targetContext: IContext2d) {\n return this.createCommonPattern(size, padding, color, targetContext, (r, ctx) => {\n ctx.fillStyle = color;\n ctx.arc(r, r, r, 0, pi2);\n ctx.fill();\n });\n }\n\n createDiamondPattern(size: number, padding: number, color: string, targetContext: IContext2d) {\n return this.createCommonPattern(size, padding, color, targetContext, (r, ctx) => {\n const x = size / 2;\n const y = x;\n ctx.fillStyle = color;\n ctx.moveTo(x, y - r);\n ctx.lineTo(r + x, y);\n ctx.lineTo(x, y + r);\n ctx.lineTo(x - r, y);\n ctx.closePath();\n ctx.fill();\n });\n }\n\n createRectPattern(size: number, padding: number, color: string, targetContext: IContext2d) {\n return this.createCommonPattern(size, padding, color, targetContext, (r, ctx) => {\n const x = padding;\n const y = x;\n ctx.fillStyle = color;\n ctx.fillRect(x, y, r * 2, r * 2);\n });\n }\n\n createVerticalLinePattern(size: number, padding: number, color: string, targetContext: IContext2d) {\n return this.createCommonPattern(size, padding, color, targetContext, (r, ctx) => {\n const x = padding;\n const y = 0;\n ctx.fillStyle = color;\n ctx.fillRect(x, y, r * 2, size);\n });\n }\n\n createHorizontalLinePattern(size: number, padding: number, color: string, targetContext: IContext2d) {\n return this.createCommonPattern(size, padding, color, targetContext, (r, ctx) => {\n const x = 0;\n const y = padding;\n ctx.fillStyle = color;\n ctx.fillRect(x, y, size, r * 2);\n });\n }\n\n createBiasLRLinePattern(size: number, padding: number, color: string, targetContext: IContext2d) {\n return this.createCommonPattern(size, padding, color, targetContext, (r, ctx) => {\n ctx.strokeStyle = color;\n ctx.lineWidth = r;\n ctx.moveTo(0, 0);\n ctx.lineTo(size, size);\n const dx = size / 2;\n const dy = -dx;\n ctx.moveTo(dx, dy);\n ctx.lineTo(dx + size, dy + size);\n ctx.moveTo(-dx, -dy);\n ctx.lineTo(-dx + size, -dy + size);\n ctx.stroke();\n });\n }\n\n createBiasRLLinePattern(size: number, padding: number, color: string, targetContext: IContext2d) {\n return this.createCommonPattern(size, padding, color, targetContext, (r, ctx) => {\n ctx.strokeStyle = color;\n ctx.lineWidth = r;\n ctx.moveTo(size, 0);\n ctx.lineTo(0, size);\n const dx = size / 2;\n const dy = dx;\n ctx.moveTo(size + dx, dy);\n ctx.lineTo(dx, dy + size);\n ctx.moveTo(size - dx, -dy);\n ctx.lineTo(-dx, -dy + size);\n ctx.stroke();\n });\n }\n\n createGridPattern(size: number, padding: number, color: string, targetContext: IContext2d) {\n return this.createCommonPattern(size, padding, color, targetContext, (r, ctx) => {\n const x = padding;\n const y = x;\n ctx.fillStyle = color;\n ctx.fillRect(x, y, r, r);\n ctx.fillRect(x + r, y + r, r, r);\n });\n }\n\n initTextureMap(ctx: IContext2d, stage: IStage) {\n this.textureMap = new Map();\n // ResourceLoader.GetImage(rect1, {\n // imageLoadFail: () => {\n // return;\n // },\n // imageLoadSuccess: (url, img) => {\n // const pattern = ctx.createPattern(img, 'repeat');\n // this.textureMap.set('rect1', pattern);\n // stage && stage.renderNextFrame();\n // }\n // });\n }\n\n drawShape(\n graphic: IGraphic,\n context: IContext2d,\n x: number,\n y: number,\n doFill: boolean,\n doStroke: boolean,\n fVisible: boolean,\n sVisible: boolean,\n graphicAttribute: Required<IGraphicAttribute>,\n drawContext: IDrawContext,\n fillCb?: (ctx: IContext2d, markAttribute: Partial<IGraphicAttribute>, themeAttribute: IThemeAttribute) => boolean,\n strokeCb?: (ctx: IContext2d, markAttribute: Partial<IGraphicAttribute>, themeAttribute: IThemeAttribute) => boolean,\n options?: any\n ) {\n if (!this.textureMap) {\n this.initTextureMap(context, graphic.stage);\n }\n const {\n texture = graphicAttribute.texture,\n textureColor = graphicAttribute.textureColor,\n textureSize = graphicAttribute.textureSize,\n texturePadding = graphicAttribute.texturePadding\n } = graphic.attribute;\n if (!texture) {\n return;\n }\n this.drawTexture(texture, graphic, context, x, y, graphicAttribute, textureColor, textureSize, texturePadding);\n }\n\n protected drawTexture(\n texture: string,\n graphic: IGraphic,\n context: IContext2d,\n x: number,\n y: number,\n graphicAttribute: Required<IGraphicAttribute>,\n textureColor: string,\n textureSize: number,\n texturePadding: number\n ) {\n let pattern: CanvasPattern = this.textureMap.get(texture);\n\n if (!pattern) {\n switch (texture) {\n case 'circle':\n pattern = this.createCirclePattern(textureSize, texturePadding, textureColor, context);\n break;\n case 'diamond':\n pattern = this.createDiamondPattern(textureSize, texturePadding, textureColor, context);\n break;\n case 'rect':\n pattern = this.createRectPattern(textureSize, texturePadding, textureColor, context);\n break;\n case 'vertical-line':\n pattern = this.createVerticalLinePattern(textureSize, texturePadding, textureColor, context);\n break;\n case 'horizontal-line':\n pattern = this.createHorizontalLinePattern(textureSize, texturePadding, textureColor, context);\n break;\n case 'bias-lr':\n pattern = this.createBiasLRLinePattern(textureSize, texturePadding, textureColor, context);\n break;\n case 'bias-rl':\n pattern = this.createBiasRLLinePattern(textureSize, texturePadding, textureColor, context);\n break;\n case 'grid':\n pattern = this.createGridPattern(textureSize, texturePadding, textureColor, context);\n break;\n }\n }\n\n if (pattern) {\n context.highPerformanceSave();\n context.setCommonStyle(graphic, graphic.attribute, x, y, graphicAttribute);\n context.fillStyle = pattern;\n context.fill();\n context.highPerformanceRestore();\n }\n }\n}\n\nexport const defaultBaseTextureRenderContribution = new DefaultBaseTextureRenderContribution();\n"]}
1
+ {"version":3,"sources":["../src/render/contributions/render/contributions/base-texture-contribution-render.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAE,MAAM,uCAAuC,CAAC;AACvE,OAAO,EAAE,0BAA0B,EAAE,MAAM,0BAA0B,CAAC;AAUtE,OAAO,EAAE,GAAG,EAAE,MAAM,kBAAkB,CAAC;AAEvC,SAAS,WAAW,CAAC,KAAa;IAChC,IAAI,KAAK,IAAI,GAAG,EAAE;QAChB,OAAO,KAAK,GAAG,CAAC,GAAG,CAAC,CAAC;KACtB;IACD,OAAO,CAAC,CAAC,GAAG,KAAK,GAAG,CAAC,CAAC;AACxB,CAAC;AAED,SAAS,QAAQ,CACf,GAAe,EACf,KAAa,EACb,WAAmB,EACnB,YAAoB,EACpB,cAOC,EACD,OAAe,EACf,OAAe;IAEf,MAAM,EAAE,IAAI,GAAG,QAAQ,EAAE,OAAO,GAAG,GAAG,EAAE,SAAS,GAAG,CAAC,EAAE,OAAO,EAAE,GAAG,GAAG,CAAC,EAAE,GAAG,cAAc,CAAC;IAC3F,IAAI,EAAE,SAAS,GAAG,EAAE,EAAE,GAAG,cAAc,CAAC;IACxC,SAAS,GAAG,SAAS,GAAG,WAAW,CAAC,KAAK,CAAC,CAAC;IAE3C,MAAM,MAAM,GAAG,YAAY,GAAG,CAAC,CAAC,GAAG,OAAO,CAAC,CAAC;IAC5C,MAAM,K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AO,CAAC,UAAU,CAAC;YAC7B,QAAQ,CACN,OAAO,EACP,YAAY,EACZ,CAAC,CAAC,KAAK,EAAE,EACT,CAAC,CAAC,MAAM,EAAE,kCACL,CAAC,cAAc,IAAI,EAAE,CAAC,KAAE,IAAI,EAAE,YAAY,KAC/C,CAAC,GAAG,CAAC,CAAC,EAAE,GAAG,CAAC,EACZ,CAAC,GAAG,CAAC,CAAC,EAAE,GAAG,CAAC,CACb,CAAC;YACF,OAAO,CAAC,OAAO,EAAE,CAAC;SACnB;IACH,CAAC;CACF;AAED,MAAM,CAAC,MAAM,oCAAoC,GAAG,IAAI,oCAAoC,EAAE,CAAC","file":"base-texture-contribution-render.js","sourcesContent":["import { canvasAllocate } from '../../../../allocator/canvas-allocate';\nimport { BaseRenderContributionTime } from '../../../../common/enums';\nimport type {\n IBaseRenderContribution,\n IContext2d,\n IDrawContext,\n IGraphic,\n IGraphicAttribute,\n IStage,\n IThemeAttribute\n} from '../../../../interface';\nimport { pi2 } from '@visactor/vutils';\n\nfunction formatRatio(ratio: number) {\n if (ratio <= 0.5) {\n return ratio * 4 - 1;\n }\n return -4 * ratio + 3;\n}\n\nfunction drawWave(\n ctx: IContext2d,\n ratio: number,\n boundsWidth: number,\n boundsHeight: number,\n textureOptions: {\n fill: string;\n percent: number;\n frequency: number;\n amplitude: number;\n opacity?: number;\n phi?: number;\n },\n offsetX: number,\n offsetY: number\n) {\n const { fill = 'orange', percent = 0.6, frequency = 4, opacity, phi = 0 } = textureOptions;\n let { amplitude = 10 } = textureOptions;\n amplitude = amplitude * formatRatio(ratio);\n\n const height = boundsHeight * (1 - percent);\n const width = boundsWidth;\n\n const step = Math.max(Math.round(width / 70), 2);\n ctx.beginPath();\n ctx.moveTo(0 + offsetX, boundsHeight + offsetY);\n ctx.lineTo(0 + offsetX, height + offsetY);\n const delta = (width / frequency) * ratio;\n const c = width / Math.PI / (frequency * 2);\n\n for (let i = 0; i < width; i += step) {\n const y = amplitude * Math.sin((i + delta + phi) / c + phi);\n ctx.lineTo(i + offsetX, height + y + offsetY);\n }\n\n ctx.lineTo(width + offsetX, boundsHeight + offsetY);\n ctx.closePath();\n\n ctx.fillStyle = fill;\n if (isFinite(opacity)) {\n ctx.globalAlpha = opacity;\n }\n ctx.fill();\n}\n\nexport class DefaultBaseTextureRenderContribution implements IBaseRenderContribution<IGraphic, IGraphicAttribute> {\n time: BaseRenderContributionTime = BaseRenderContributionTime.afterFillStroke;\n useStyle: boolean = true;\n textureMap?: Map<string, CanvasPattern>;\n order: number = 10;\n\n createCommonPattern(\n size: number,\n padding: number,\n color: string,\n targetContext: IContext2d,\n cb: (r: number, targetContext: IContext2d) => void\n ) {\n const r = (size - padding * 2) / 2;\n const dpr = targetContext.dpr;\n const canvas = canvasAllocate.allocate({ width: size, height: size, dpr });\n const ctx = canvas.getContext('2d');\n if (!ctx) {\n return null;\n }\n ctx.inuse = true;\n ctx.clearMatrix();\n ctx.setTransformForCurrent(true);\n ctx.clearRect(0, 0, size, size);\n //setup up design for pattern\n cb(r, ctx);\n const pattern = targetContext.createPattern(canvas.nativeCanvas, 'repeat');\n pattern.setTransform && pattern.setTransform(new DOMMatrix([1 / dpr, 0, 0, 1 / dpr, 0, 0]));\n\n canvasAllocate.free(canvas);\n return pattern;\n }\n\n createCirclePattern(size: number, padding: number, color: string, targetContext: IContext2d) {\n return this.createCommonPattern(size, padding, color, targetContext, (r, ctx) => {\n ctx.fillStyle = color;\n ctx.arc(r, r, r, 0, pi2);\n ctx.fill();\n });\n }\n\n createDiamondPattern(size: number, padding: number, color: string, targetContext: IContext2d) {\n return this.createCommonPattern(size, padding, color, targetContext, (r, ctx) => {\n const x = size / 2;\n const y = x;\n ctx.fillStyle = color;\n ctx.moveTo(x, y - r);\n ctx.lineTo(r + x, y);\n ctx.lineTo(x, y + r);\n ctx.lineTo(x - r, y);\n ctx.closePath();\n ctx.fill();\n });\n }\n\n createRectPattern(size: number, padding: number, color: string, targetContext: IContext2d) {\n return this.createCommonPattern(size, padding, color, targetContext, (r, ctx) => {\n const x = padding;\n const y = x;\n ctx.fillStyle = color;\n ctx.fillRect(x, y, r * 2, r * 2);\n });\n }\n\n createVerticalLinePattern(size: number, padding: number, color: string, targetContext: IContext2d) {\n return this.createCommonPattern(size, padding, color, targetContext, (r, ctx) => {\n const x = padding;\n const y = 0;\n ctx.fillStyle = color;\n ctx.fillRect(x, y, r * 2, size);\n });\n }\n\n createHorizontalLinePattern(size: number, padding: number, color: string, targetContext: IContext2d) {\n return this.createCommonPattern(size, padding, color, targetContext, (r, ctx) => {\n const x = 0;\n const y = padding;\n ctx.fillStyle = color;\n ctx.fillRect(x, y, size, r * 2);\n });\n }\n\n createBiasLRLinePattern(size: number, padding: number, color: string, targetContext: IContext2d) {\n return this.createCommonPattern(size, padding, color, targetContext, (r, ctx) => {\n ctx.strokeStyle = color;\n ctx.lineWidth = r;\n ctx.moveTo(0, 0);\n ctx.lineTo(size, size);\n const dx = size / 2;\n const dy = -dx;\n ctx.moveTo(dx, dy);\n ctx.lineTo(dx + size, dy + size);\n ctx.moveTo(-dx, -dy);\n ctx.lineTo(-dx + size, -dy + size);\n ctx.stroke();\n });\n }\n\n createBiasRLLinePattern(size: number, padding: number, color: string, targetContext: IContext2d) {\n return this.createCommonPattern(size, padding, color, targetContext, (r, ctx) => {\n ctx.strokeStyle = color;\n ctx.lineWidth = r;\n ctx.moveTo(size, 0);\n ctx.lineTo(0, size);\n const dx = size / 2;\n const dy = dx;\n ctx.moveTo(size + dx, dy);\n ctx.lineTo(dx, dy + size);\n ctx.moveTo(size - dx, -dy);\n ctx.lineTo(-dx, -dy + size);\n ctx.stroke();\n });\n }\n\n createGridPattern(size: number, padding: number, color: string, targetContext: IContext2d) {\n return this.createCommonPattern(size, padding, color, targetContext, (r, ctx) => {\n const x = padding;\n const y = x;\n ctx.fillStyle = color;\n ctx.fillRect(x, y, r, r);\n ctx.fillRect(x + r, y + r, r, r);\n });\n }\n\n initTextureMap(ctx: IContext2d, stage: IStage) {\n this.textureMap = new Map();\n // ResourceLoader.GetImage(rect1, {\n // imageLoadFail: () => {\n // return;\n // },\n // imageLoadSuccess: (url, img) => {\n // const pattern = ctx.createPattern(img, 'repeat');\n // this.textureMap.set('rect1', pattern);\n // stage && stage.renderNextFrame();\n // }\n // });\n }\n\n drawShape(\n graphic: IGraphic,\n context: IContext2d,\n x: number,\n y: number,\n doFill: boolean,\n doStroke: boolean,\n fVisible: boolean,\n sVisible: boolean,\n graphicAttribute: Required<IGraphicAttribute>,\n drawContext: IDrawContext,\n fillCb?: (ctx: IContext2d, markAttribute: Partial<IGraphicAttribute>, themeAttribute: IThemeAttribute) => boolean,\n strokeCb?: (ctx: IContext2d, markAttribute: Partial<IGraphicAttribute>, themeAttribute: IThemeAttribute) => boolean,\n options?: any\n ) {\n if (!this.textureMap) {\n this.initTextureMap(context, graphic.stage);\n }\n const {\n texture = graphicAttribute.texture,\n textureColor = graphicAttribute.textureColor,\n textureSize = graphicAttribute.textureSize,\n texturePadding = graphicAttribute.texturePadding\n } = graphic.attribute;\n if (!texture) {\n return;\n }\n this.drawTexture(texture, graphic, context, x, y, graphicAttribute, textureColor, textureSize, texturePadding);\n }\n\n protected drawTexture(\n texture: string,\n graphic: IGraphic,\n context: IContext2d,\n x: number,\n y: number,\n graphicAttribute: Required<IGraphicAttribute>,\n textureColor: string,\n textureSize: number,\n texturePadding: number\n ) {\n const { textureRatio = graphicAttribute.textureRatio, textureOptions = null } = graphic.attribute;\n let pattern: CanvasPattern = this.textureMap.get(texture);\n\n if (!pattern) {\n switch (texture) {\n case 'circle':\n pattern = this.createCirclePattern(textureSize, texturePadding, textureColor, context);\n break;\n case 'diamond':\n pattern = this.createDiamondPattern(textureSize, texturePadding, textureColor, context);\n break;\n case 'rect':\n pattern = this.createRectPattern(textureSize, texturePadding, textureColor, context);\n break;\n case 'vertical-line':\n pattern = this.createVerticalLinePattern(textureSize, texturePadding, textureColor, context);\n break;\n case 'horizontal-line':\n pattern = this.createHorizontalLinePattern(textureSize, texturePadding, textureColor, context);\n break;\n case 'bias-lr':\n pattern = this.createBiasLRLinePattern(textureSize, texturePadding, textureColor, context);\n break;\n case 'bias-rl':\n pattern = this.createBiasRLLinePattern(textureSize, texturePadding, textureColor, context);\n break;\n case 'grid':\n pattern = this.createGridPattern(textureSize, texturePadding, textureColor, context);\n break;\n }\n }\n\n if (pattern) {\n context.highPerformanceSave();\n context.setCommonStyle(graphic, graphic.attribute, x, y, graphicAttribute);\n context.fillStyle = pattern;\n context.fill();\n context.highPerformanceRestore();\n } else if (texture === 'wave') {\n context.save();\n context.setCommonStyle(graphic, graphic.attribute, x, y, graphicAttribute);\n context.clip();\n const b = graphic.AABBBounds;\n drawWave(\n context,\n textureRatio,\n b.width(),\n b.height(),\n { ...(textureOptions || {}), fill: textureColor },\n x + b.x1 - x,\n y + b.y1 - y\n );\n context.restore();\n }\n }\n}\n\nexport const defaultBaseTextureRenderContribution = new DefaultBaseTextureRenderContribution();\n"]}
@@ -7,14 +7,19 @@ export class DefaultGroupBackgroundRenderContribution extends DefaultBaseBackgro
7
7
  super(...arguments), this.time = BaseRenderContributionTime.beforeFillStroke;
8
8
  }
9
9
  drawShape(graphic, context, x, y, doFill, doStroke, fVisible, sVisible, graphicAttribute, drawContext, fillCb, strokeCb) {
10
- const {background: background, backgroundMode: backgroundMode = graphicAttribute.backgroundMode, backgroundFit: backgroundFit = graphicAttribute.backgroundFit} = graphic.attribute;
10
+ const {background: background, backgroundMode: backgroundMode = graphicAttribute.backgroundMode, backgroundFit: backgroundFit = graphicAttribute.backgroundFit, backgroundScale: backgroundScale = graphicAttribute.backgroundScale, backgroundOffsetX: backgroundOffsetX = graphicAttribute.backgroundOffsetX, backgroundOffsetY: backgroundOffsetY = graphicAttribute.backgroundOffsetY} = graphic.attribute;
11
11
  if (background) if (graphic.backgroundImg && graphic.resources) {
12
12
  const res = graphic.resources.get(background);
13
13
  if ("success" !== res.state || !res.data) return;
14
14
  context.highPerformanceSave(), context.setTransformFromMatrix(graphic.parent.globalTransMatrix, !0);
15
15
  const b = graphic.AABBBounds;
16
- this.doDrawImage(context, res.data, b, backgroundMode, backgroundFit), context.highPerformanceRestore(),
17
- context.setTransformForCurrent();
16
+ this.doDrawImage(context, res.data, b, {
17
+ backgroundMode: backgroundMode,
18
+ backgroundFit: backgroundFit,
19
+ backgroundScale: backgroundScale,
20
+ backgroundOffsetX: backgroundOffsetX,
21
+ backgroundOffsetY: backgroundOffsetY
22
+ }), context.highPerformanceRestore(), context.setTransformForCurrent();
18
23
  } else context.highPerformanceSave(), context.fillStyle = background, context.fill(),
19
24
  context.highPerformanceRestore();
20
25
  }
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/render/contributions/render/contributions/group-contribution-render.ts"],"names":[],"mappings":"AAQA,OAAO,EAAE,uCAAuC,EAAE,MAAM,4BAA4B,CAAC;AACrF,OAAO,EAAE,0BAA0B,EAAE,MAAM,0BAA0B,CAAC;AAEtE,MAAM,OAAO,wCACX,SAAQ,uCAAuC;IADjD;;QAIE,SAAI,GAA+B,0BAA0B,CAAC,gBAAgB,CAAC;IA6CjF,CAAC;IA3CC,SAAS,CACP,OAAe,EACf,OAAmB,EACnB,CAAS,EACT,CAAS,EACT,MAAe,EACf,QAAiB,EACjB,QAAiB,EACjB,QAAiB,EACjB,gBAA6C,EAC7C,WAAyB,EACzB,MAAiH,EACjH,QAAmH;QAEnH,MAAM,EACJ,UAAU,EACV,cAAc,GAAG,gBAAgB,CAAC,cAAc,EAChD,aAAa,GAAG,gBAAgB,CAAC,aAAa,EAC/C,GAAG,OAAO,CAAC,SAAS,CAAC;QACtB,IAAI,CAAC,UAAU,EAAE;YACf,OAAO;SACR;QAED,IAAI,OAAO,CAAC,aAAa,IAAI,OAAO,CAAC,SAAS,EAAE;YAC9C,MAAM,GAAG,GAAG,OAAO,CAAC,SAAS,CAAC,GAAG,CAAC,UAAiB,CAAC,CAAC;YACrD,IAAI,GAAG,CAAC,KAAK,KAAK,SAAS,IAAI,CAAC,GAAG,CAAC,IAAI,EAAE;gBACxC,OAAO;aACR;YAED,OAAO,CAAC,mBAAmB,EAAE,CAAC;YAE9B,OAAO,CAAC,sBAAsB,CAAC,OAAO,CAAC,MAAM,CAAC,iBAAiB,EAAE,IAAI,CAAC,CAAC;YACvE,MAAM,CAAC,GAAG,OAAO,CAAC,UAAU,CAAC;YAC7B,IAAI,CAAC,WAAW,CAAC,OAAO,EAAE,GAAG,CAAC,IAAI,EAAE,CAAC,EAAE,cAAc,EAAE,aAAa,CAAC,CAAC;YACtE,OAAO,CAAC,sBAAsB,EAAE,CAAC;YACjC,OAAO,CAAC,sBAAsB,EAAE,CAAC;SAClC;aAAM;YACL,OAAO,CAAC,mBAAmB,EAAE,CAAC;YAC9B,OAAO,CAAC,SAAS,GAAG,UAAoB,CAAC;YACzC,OAAO,CAAC,IAAI,EAAE,CAAC;YACf,OAAO,CAAC,sBAAsB,EAAE,CAAC;SAClC;IACH,CAAC;CACF;AAED,MAAM,CAAC,MAAM,wCAAwC,GAAG,IAAI,wCAAwC,EAAE,CAAC","file":"group-contribution-render.js","sourcesContent":["import type {\n IGraphicAttribute,\n IContext2d,\n IGroup,\n IThemeAttribute,\n IGroupRenderContribution,\n IDrawContext\n} from '../../../../interface';\nimport { DefaultBaseBackgroundRenderContribution } from './base-contribution-render';\nimport { BaseRenderContributionTime } from '../../../../common/enums';\n\nexport class DefaultGroupBackgroundRenderContribution\n extends DefaultBaseBackgroundRenderContribution\n implements IGroupRenderContribution\n{\n time: BaseRenderContributionTime = BaseRenderContributionTime.beforeFillStroke;\n\n drawShape(\n graphic: IGroup,\n context: IContext2d,\n x: number,\n y: number,\n doFill: boolean,\n doStroke: boolean,\n fVisible: boolean,\n sVisible: boolean,\n graphicAttribute: Required<IGraphicAttribute>,\n drawContext: IDrawContext,\n fillCb?: (ctx: IContext2d, markAttribute: Partial<IGraphicAttribute>, themeAttribute: IThemeAttribute) => boolean,\n strokeCb?: (ctx: IContext2d, markAttribute: Partial<IGraphicAttribute>, themeAttribute: IThemeAttribute) => boolean\n ) {\n const {\n background,\n backgroundMode = graphicAttribute.backgroundMode,\n backgroundFit = graphicAttribute.backgroundFit\n } = graphic.attribute;\n if (!background) {\n return;\n }\n\n if (graphic.backgroundImg && graphic.resources) {\n const res = graphic.resources.get(background as any);\n if (res.state !== 'success' || !res.data) {\n return;\n }\n\n context.highPerformanceSave();\n\n context.setTransformFromMatrix(graphic.parent.globalTransMatrix, true);\n const b = graphic.AABBBounds;\n this.doDrawImage(context, res.data, b, backgroundMode, backgroundFit);\n context.highPerformanceRestore();\n context.setTransformForCurrent();\n } else {\n context.highPerformanceSave();\n context.fillStyle = background as string;\n context.fill();\n context.highPerformanceRestore();\n }\n }\n}\n\nexport const defaultGroupBackgroundRenderContribution = new DefaultGroupBackgroundRenderContribution();\n"]}
1
+ {"version":3,"sources":["../src/render/contributions/render/contributions/group-contribution-render.ts"],"names":[],"mappings":"AAQA,OAAO,EAAE,uCAAuC,EAAE,MAAM,4BAA4B,CAAC;AACrF,OAAO,EAAE,0BAA0B,EAAE,MAAM,0BAA0B,CAAC;AAEtE,MAAM,OAAO,wCACX,SAAQ,uCAAuC;IADjD;;QAIE,SAAI,GAA+B,0BAA0B,CAAC,gBAAgB,CAAC;IAsDjF,CAAC;IApDC,SAAS,CACP,OAAe,EACf,OAAmB,EACnB,CAAS,EACT,CAAS,EACT,MAAe,EACf,QAAiB,EACjB,QAAiB,EACjB,QAAiB,EACjB,gBAA6C,EAC7C,WAAyB,EACzB,MAAiH,EACjH,QAAmH;QAEnH,MAAM,EACJ,UAAU,EACV,cAAc,GAAG,gBAAgB,CAAC,cAAc,EAChD,aAAa,GAAG,gBAAgB,CAAC,aAAa,EAC9C,eAAe,GAAG,gBAAgB,CAAC,eAAe,EAClD,iBAAiB,GAAG,gBAAgB,CAAC,iBAAiB,EACtD,iBAAiB,GAAG,gBAAgB,CAAC,iBAAiB,EACvD,GAAG,OAAO,CAAC,SAAS,CAAC;QACtB,IAAI,CAAC,UAAU,EAAE;YACf,OAAO;SACR;QAED,IAAI,OAAO,CAAC,aAAa,IAAI,OAAO,CAAC,SAAS,EAAE;YAC9C,MAAM,GAAG,GAAG,OAAO,CAAC,SAAS,CAAC,GAAG,CAAC,UAAiB,CAAC,CAAC;YACrD,IAAI,GAAG,CAAC,KAAK,KAAK,SAAS,IAAI,CAAC,GAAG,CAAC,IAAI,EAAE;gBACxC,OAAO;aACR;YAED,OAAO,CAAC,mBAAmB,EAAE,CAAC;YAE9B,OAAO,CAAC,sBAAsB,CAAC,OAAO,CAAC,MAAM,CAAC,iBAAiB,EAAE,IAAI,CAAC,CAAC;YACvE,MAAM,CAAC,GAAG,OAAO,CAAC,UAAU,CAAC;YAC7B,IAAI,CAAC,WAAW,CAAC,OAAO,EAAE,GAAG,CAAC,IAAI,EAAE,CAAC,EAAE;gBACrC,cAAc;gBACd,aAAa;gBACb,eAAe;gBACf,iBAAiB;gBACjB,iBAAiB;aAClB,CAAC,CAAC;YACH,OAAO,CAAC,sBAAsB,EAAE,CAAC;YACjC,OAAO,CAAC,sBAAsB,EAAE,CAAC;SAClC;aAAM;YACL,OAAO,CAAC,mBAAmB,EAAE,CAAC;YAC9B,OAAO,CAAC,SAAS,GAAG,UAAoB,CAAC;YACzC,OAAO,CAAC,IAAI,EAAE,CAAC;YACf,OAAO,CAAC,sBAAsB,EAAE,CAAC;SAClC;IACH,CAAC;CACF;AAED,MAAM,CAAC,MAAM,wCAAwC,GAAG,IAAI,wCAAwC,EAAE,CAAC","file":"group-contribution-render.js","sourcesContent":["import type {\n IGraphicAttribute,\n IContext2d,\n IGroup,\n IThemeAttribute,\n IGroupRenderContribution,\n IDrawContext\n} from '../../../../interface';\nimport { DefaultBaseBackgroundRenderContribution } from './base-contribution-render';\nimport { BaseRenderContributionTime } from '../../../../common/enums';\n\nexport class DefaultGroupBackgroundRenderContribution\n extends DefaultBaseBackgroundRenderContribution\n implements IGroupRenderContribution\n{\n time: BaseRenderContributionTime = BaseRenderContributionTime.beforeFillStroke;\n\n drawShape(\n graphic: IGroup,\n context: IContext2d,\n x: number,\n y: number,\n doFill: boolean,\n doStroke: boolean,\n fVisible: boolean,\n sVisible: boolean,\n graphicAttribute: Required<IGraphicAttribute>,\n drawContext: IDrawContext,\n fillCb?: (ctx: IContext2d, markAttribute: Partial<IGraphicAttribute>, themeAttribute: IThemeAttribute) => boolean,\n strokeCb?: (ctx: IContext2d, markAttribute: Partial<IGraphicAttribute>, themeAttribute: IThemeAttribute) => boolean\n ) {\n const {\n background,\n backgroundMode = graphicAttribute.backgroundMode,\n backgroundFit = graphicAttribute.backgroundFit,\n backgroundScale = graphicAttribute.backgroundScale,\n backgroundOffsetX = graphicAttribute.backgroundOffsetX,\n backgroundOffsetY = graphicAttribute.backgroundOffsetY\n } = graphic.attribute;\n if (!background) {\n return;\n }\n\n if (graphic.backgroundImg && graphic.resources) {\n const res = graphic.resources.get(background as any);\n if (res.state !== 'success' || !res.data) {\n return;\n }\n\n context.highPerformanceSave();\n\n context.setTransformFromMatrix(graphic.parent.globalTransMatrix, true);\n const b = graphic.AABBBounds;\n this.doDrawImage(context, res.data, b, {\n backgroundMode,\n backgroundFit,\n backgroundScale,\n backgroundOffsetX,\n backgroundOffsetY\n });\n context.highPerformanceRestore();\n context.setTransformForCurrent();\n } else {\n context.highPerformanceSave();\n context.fillStyle = background as string;\n context.fill();\n context.highPerformanceRestore();\n }\n }\n}\n\nexport const defaultGroupBackgroundRenderContribution = new DefaultGroupBackgroundRenderContribution();\n"]}
@@ -6,7 +6,7 @@ export declare class DefaultImageRenderContribution extends DefaultRectRenderCon
6
6
  time: BaseRenderContributionTime;
7
7
  useStyle: boolean;
8
8
  order: number;
9
- drawShape(rect: any, context: IContext2d, x: number, y: number, doFill: boolean, doStroke: boolean, fVisible: boolean, sVisible: boolean, rectAttribute: any, drawContext: IDrawContext, fillCb?: (ctx: IContext2d, markAttribute: Partial<IMarkAttribute & IGraphicAttribute>, themeAttribute: IThemeAttribute) => boolean, strokeCb?: (ctx: IContext2d, markAttribute: Partial<IMarkAttribute & IGraphicAttribute>, themeAttribute: IThemeAttribute) => boolean): void;
9
+ drawShape(image: any, context: IContext2d, x: number, y: number, doFill: boolean, doStroke: boolean, fVisible: boolean, sVisible: boolean, rectAttribute: any, drawContext: IDrawContext, fillCb?: (ctx: IContext2d, markAttribute: Partial<IMarkAttribute & IGraphicAttribute>, themeAttribute: IThemeAttribute) => boolean, strokeCb?: (ctx: IContext2d, markAttribute: Partial<IMarkAttribute & IGraphicAttribute>, themeAttribute: IThemeAttribute) => boolean): void;
10
10
  }
11
11
  export declare const defaultImageRenderContribution: DefaultImageRenderContribution;
12
12
  export declare const defaultImageBackgroundRenderContribution: DefaultBaseBackgroundRenderContribution;
@@ -9,8 +9,8 @@ export class DefaultImageRenderContribution extends DefaultRectRenderContributio
9
9
  super(...arguments), this.time = BaseRenderContributionTime.afterFillStroke, this.useStyle = !0,
10
10
  this.order = 0;
11
11
  }
12
- drawShape(rect, context, x, y, doFill, doStroke, fVisible, sVisible, rectAttribute, drawContext, fillCb, strokeCb) {
13
- return super.drawShape(rect, context, x, y, doFill, doStroke, fVisible, sVisible, rectAttribute, drawContext, fillCb, strokeCb);
12
+ drawShape(image, context, x, y, doFill, doStroke, fVisible, sVisible, rectAttribute, drawContext, fillCb, strokeCb) {
13
+ return super.drawShape(image, context, x, y, doFill, doStroke, fVisible, sVisible, rectAttribute, drawContext, fillCb, strokeCb);
14
14
  }
15
15
  }
16
16
 
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/render/contributions/render/contributions/image-contribution-render.ts"],"names":[],"mappings":"AAYA,OAAO,EACL,uCAAuC,EAExC,MAAM,4BAA4B,CAAC;AACpC,OAAO,EAAE,0BAA0B,EAAE,MAAM,0BAA0B,CAAC;AAItE,OAAO,EAAE,6BAA6B,EAAE,MAAM,4BAA4B,CAAC;AA+H3E,MAAM,OAAO,8BAA+B,SAAQ,6BAA6B;IAAjF;;QACE,SAAI,GAA+B,0BAA0B,CAAC,eAAe,CAAC;QAC9E,aAAQ,GAAY,IAAI,CAAC;QACzB,UAAK,GAAW,CAAC,CAAC;IAsCpB,CAAC;IArCC,SAAS,CACP,IAAS,EACT,OAAmB,EACnB,CAAS,EACT,CAAS,EACT,MAAe,EACf,QAAiB,EACjB,QAAiB,EACjB,QAAiB,EACjB,aAAkB,EAClB,WAAyB,EACzB,MAIY,EACZ,QAIY;QAEZ,OAAO,KAAK,CAAC,SAAS,CACpB,IAAI,EACJ,OAAO,EACP,CAAC,EACD,CAAC,EACD,MAAM,EACN,QAAQ,EACR,QAAQ,EACR,QAAQ,EACR,aAAa,EACb,WAAW,EACX,MAAM,EACN,QAAQ,CACT,CAAC;IACJ,CAAC;CACF;AAED,MAAM,CAAC,MAAM,8BAA8B,GAAG,IAAI,8BAA8B,EAAE,CAAC;AACnF,MAAM,CAAC,MAAM,wCAAwC,GAAG,uCAAuC,CAAC","file":"image-contribution-render.js","sourcesContent":["import type {\n IGraphicAttribute,\n IContext2d,\n IImage,\n IThemeAttribute,\n IImageRenderContribution,\n IDrawContext,\n IBackgroundConfig,\n IGraphic,\n IMarkAttribute\n} from '../../../../interface';\nimport { getTheme } from '../../../../graphic/theme';\nimport {\n defaultBaseBackgroundRenderContribution,\n DefaultBaseBackgroundRenderContribution\n} from './base-contribution-render';\nimport { BaseRenderContributionTime } from '../../../../common/enums';\nimport { isNumber, isObject } from '@visactor/vutils';\nimport { parsePadding } from '../../../../common/utils';\nimport { createRectPath } from '../../../../common/shape/rect';\nimport { DefaultRectRenderContribution } from './rect-contribution-render';\n\n// export class DefaultImageBackgroundRenderContribution\n// extends DefaultBaseBackgroundRenderContribution\n// implements IImageRenderContribution\n// {\n// time: BaseRenderContributionTime = BaseRenderContributionTime.beforeFillStroke;\n\n// drawShape(\n// graphic: IImage,\n// context: IContext2d,\n// x: number,\n// y: number,\n// doFill: boolean,\n// doStroke: boolean,\n// fVisible: boolean,\n// sVisible: boolean,\n// graphicAttribute: Required<IGraphicAttribute>,\n// drawContext: IDrawContext,\n// fillCb?: (ctx: IContext2d, markAttribute: Partial<IGraphicAttribute>, themeAttribute: IThemeAttribute) => boolean,\n// strokeCb?: (ctx: IContext2d, markAttribute: Partial<IGraphicAttribute>, themeAttribute: IThemeAttribute) => boolean\n// ) {\n// const {\n// background,\n// backgroundMode = graphicAttribute.backgroundMode,\n// backgroundFit = graphicAttribute.backgroundFit,\n// width,\n// height\n// } = graphic.attribute;\n// if (!background) {\n// return;\n// }\n\n// if (!graphic.backgroundImg) {\n// if (isObject(background)) {\n// const {\n// stroke,\n// fill,\n// lineWidth = 1,\n// cornerRadius = 0,\n// expandX = 0,\n// expandY = 0\n// } = background as IBackgroundConfig;\n\n// if (!stroke && !fill) {\n// return;\n// }\n\n// context.beginPath();\n// const { x, y, width, height } = getActualPosition(graphic);\n// if (cornerRadius) {\n// createRectPath(context, x - expandX, y - expandY, width + expandX * 2, height + expandY * 2, cornerRadius);\n// } else {\n// context.rect(x - expandX, y - expandY, width + expandX * 2, height + expandY * 2);\n// }\n\n// context.globalAlpha = 1;\n// if (fill) {\n// context.fillStyle = fill as string;\n// context.fill();\n// }\n\n// if (stroke && lineWidth > 0) {\n// context.lineWidth = lineWidth;\n// context.strokeStyle = stroke as string;\n// context.stroke();\n// }\n// } else {\n// context.beginPath();\n// // const b = graphic.AABBBounds;\n// // image的背景不包括Bounds了\n// context.rect(x, y, width || 0, height || 0);\n// context.fillStyle = background as string;\n// context.globalAlpha = 1;\n// context.fill();\n// }\n// } else {\n// const res = graphic.resources.get(background as any);\n// if (res.state !== 'success' || !res.data) {\n// return;\n// }\n// context.save();\n// if (graphic.parent && !graphic.transMatrix.onlyTranslate()) {\n// const groupAttribute = getTheme(graphic.parent).group;\n// const { scrollX = groupAttribute.scrollX, scrollY = groupAttribute.scrollY } = graphic.parent.attribute;\n// context.setTransformFromMatrix(graphic.parent.globalTransMatrix, true);\n// context.translate(scrollX, scrollY);\n// }\n// // context.clip();\n// const b = graphic.AABBBounds;\n// this.doDrawImage(context, res.data, b, backgroundMode, backgroundFit);\n// context.restore();\n// if (!graphic.transMatrix.onlyTranslate()) {\n// context.setTransformForCurrent();\n// }\n// }\n// }\n// }\n\n// function getActualPosition(graphic: IGraphic) {\n// const boundsPadding = parsePadding(graphic.attribute.boundsPadding);\n// const bounds = graphic.AABBBounds;\n// let x = bounds.x1;\n// let y = bounds.y1;\n// let width = bounds.width();\n// let height = bounds.height();\n\n// if (isNumber(boundsPadding)) {\n// x += boundsPadding;\n// y += boundsPadding;\n// width -= boundsPadding * 2;\n// height -= boundsPadding * 2;\n// } else {\n// x += boundsPadding[3];\n// y += boundsPadding[0];\n// width -= boundsPadding[1] + boundsPadding[3];\n// height -= boundsPadding[0] + boundsPadding[2];\n// }\n\n// return {\n// x,\n// y,\n// width,\n// height\n// };\n// }\n\nexport class DefaultImageRenderContribution extends DefaultRectRenderContribution implements IImageRenderContribution {\n time: BaseRenderContributionTime = BaseRenderContributionTime.afterFillStroke;\n useStyle: boolean = true;\n order: number = 0;\n drawShape(\n rect: any,\n context: IContext2d,\n x: number,\n y: number,\n doFill: boolean,\n doStroke: boolean,\n fVisible: boolean,\n sVisible: boolean,\n rectAttribute: any,\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 return super.drawShape(\n rect,\n context,\n x,\n y,\n doFill,\n doStroke,\n fVisible,\n sVisible,\n rectAttribute,\n drawContext,\n fillCb,\n strokeCb\n );\n }\n}\n\nexport const defaultImageRenderContribution = new DefaultImageRenderContribution();\nexport const defaultImageBackgroundRenderContribution = defaultBaseBackgroundRenderContribution;\n"]}
1
+ {"version":3,"sources":["../src/render/contributions/render/contributions/image-contribution-render.ts"],"names":[],"mappings":"AAYA,OAAO,EACL,uCAAuC,EAExC,MAAM,4BAA4B,CAAC;AACpC,OAAO,EAAE,0BAA0B,EAAE,MAAM,0BAA0B,CAAC;AAItE,OAAO,EAAE,6BAA6B,EAAE,MAAM,4BAA4B,CAAC;AA+H3E,MAAM,OAAO,8BAA+B,SAAQ,6BAA6B;IAAjF;;QACE,SAAI,GAA+B,0BAA0B,CAAC,eAAe,CAAC;QAC9E,aAAQ,GAAY,IAAI,CAAC;QACzB,UAAK,GAAW,CAAC,CAAC;IAsCpB,CAAC;IArCC,SAAS,CACP,KAAU,EACV,OAAmB,EACnB,CAAS,EACT,CAAS,EACT,MAAe,EACf,QAAiB,EACjB,QAAiB,EACjB,QAAiB,EACjB,aAAkB,EAClB,WAAyB,EACzB,MAIY,EACZ,QAIY;QAEZ,OAAO,KAAK,CAAC,SAAS,CACpB,KAAK,EACL,OAAO,EACP,CAAC,EACD,CAAC,EACD,MAAM,EACN,QAAQ,EACR,QAAQ,EACR,QAAQ,EACR,aAAa,EACb,WAAW,EACX,MAAM,EACN,QAAQ,CACT,CAAC;IACJ,CAAC;CACF;AAED,MAAM,CAAC,MAAM,8BAA8B,GAAG,IAAI,8BAA8B,EAAE,CAAC;AACnF,MAAM,CAAC,MAAM,wCAAwC,GAAG,uCAAuC,CAAC","file":"image-contribution-render.js","sourcesContent":["import type {\n IGraphicAttribute,\n IContext2d,\n IImage,\n IThemeAttribute,\n IImageRenderContribution,\n IDrawContext,\n IBackgroundConfig,\n IGraphic,\n IMarkAttribute\n} from '../../../../interface';\nimport { getTheme } from '../../../../graphic/theme';\nimport {\n defaultBaseBackgroundRenderContribution,\n DefaultBaseBackgroundRenderContribution\n} from './base-contribution-render';\nimport { BaseRenderContributionTime } from '../../../../common/enums';\nimport { isNumber, isObject } from '@visactor/vutils';\nimport { parsePadding } from '../../../../common/utils';\nimport { createRectPath } from '../../../../common/shape/rect';\nimport { DefaultRectRenderContribution } from './rect-contribution-render';\n\n// export class DefaultImageBackgroundRenderContribution\n// extends DefaultBaseBackgroundRenderContribution\n// implements IImageRenderContribution\n// {\n// time: BaseRenderContributionTime = BaseRenderContributionTime.beforeFillStroke;\n\n// drawShape(\n// graphic: IImage,\n// context: IContext2d,\n// x: number,\n// y: number,\n// doFill: boolean,\n// doStroke: boolean,\n// fVisible: boolean,\n// sVisible: boolean,\n// graphicAttribute: Required<IGraphicAttribute>,\n// drawContext: IDrawContext,\n// fillCb?: (ctx: IContext2d, markAttribute: Partial<IGraphicAttribute>, themeAttribute: IThemeAttribute) => boolean,\n// strokeCb?: (ctx: IContext2d, markAttribute: Partial<IGraphicAttribute>, themeAttribute: IThemeAttribute) => boolean\n// ) {\n// const {\n// background,\n// backgroundMode = graphicAttribute.backgroundMode,\n// backgroundFit = graphicAttribute.backgroundFit,\n// width,\n// height\n// } = graphic.attribute;\n// if (!background) {\n// return;\n// }\n\n// if (!graphic.backgroundImg) {\n// if (isObject(background)) {\n// const {\n// stroke,\n// fill,\n// lineWidth = 1,\n// cornerRadius = 0,\n// expandX = 0,\n// expandY = 0\n// } = background as IBackgroundConfig;\n\n// if (!stroke && !fill) {\n// return;\n// }\n\n// context.beginPath();\n// const { x, y, width, height } = getActualPosition(graphic);\n// if (cornerRadius) {\n// createRectPath(context, x - expandX, y - expandY, width + expandX * 2, height + expandY * 2, cornerRadius);\n// } else {\n// context.rect(x - expandX, y - expandY, width + expandX * 2, height + expandY * 2);\n// }\n\n// context.globalAlpha = 1;\n// if (fill) {\n// context.fillStyle = fill as string;\n// context.fill();\n// }\n\n// if (stroke && lineWidth > 0) {\n// context.lineWidth = lineWidth;\n// context.strokeStyle = stroke as string;\n// context.stroke();\n// }\n// } else {\n// context.beginPath();\n// // const b = graphic.AABBBounds;\n// // image的背景不包括Bounds了\n// context.rect(x, y, width || 0, height || 0);\n// context.fillStyle = background as string;\n// context.globalAlpha = 1;\n// context.fill();\n// }\n// } else {\n// const res = graphic.resources.get(background as any);\n// if (res.state !== 'success' || !res.data) {\n// return;\n// }\n// context.save();\n// if (graphic.parent && !graphic.transMatrix.onlyTranslate()) {\n// const groupAttribute = getTheme(graphic.parent).group;\n// const { scrollX = groupAttribute.scrollX, scrollY = groupAttribute.scrollY } = graphic.parent.attribute;\n// context.setTransformFromMatrix(graphic.parent.globalTransMatrix, true);\n// context.translate(scrollX, scrollY);\n// }\n// // context.clip();\n// const b = graphic.AABBBounds;\n// this.doDrawImage(context, res.data, b, backgroundMode, backgroundFit);\n// context.restore();\n// if (!graphic.transMatrix.onlyTranslate()) {\n// context.setTransformForCurrent();\n// }\n// }\n// }\n// }\n\n// function getActualPosition(graphic: IGraphic) {\n// const boundsPadding = parsePadding(graphic.attribute.boundsPadding);\n// const bounds = graphic.AABBBounds;\n// let x = bounds.x1;\n// let y = bounds.y1;\n// let width = bounds.width();\n// let height = bounds.height();\n\n// if (isNumber(boundsPadding)) {\n// x += boundsPadding;\n// y += boundsPadding;\n// width -= boundsPadding * 2;\n// height -= boundsPadding * 2;\n// } else {\n// x += boundsPadding[3];\n// y += boundsPadding[0];\n// width -= boundsPadding[1] + boundsPadding[3];\n// height -= boundsPadding[0] + boundsPadding[2];\n// }\n\n// return {\n// x,\n// y,\n// width,\n// height\n// };\n// }\n\nexport class DefaultImageRenderContribution extends DefaultRectRenderContribution implements IImageRenderContribution {\n time: BaseRenderContributionTime = BaseRenderContributionTime.afterFillStroke;\n useStyle: boolean = true;\n order: number = 0;\n drawShape(\n image: any,\n context: IContext2d,\n x: number,\n y: number,\n doFill: boolean,\n doStroke: boolean,\n fVisible: boolean,\n sVisible: boolean,\n rectAttribute: any,\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 return super.drawShape(\n image,\n context,\n x,\n y,\n doFill,\n doStroke,\n fVisible,\n sVisible,\n rectAttribute,\n drawContext,\n fillCb,\n strokeCb\n );\n }\n}\n\nexport const defaultImageRenderContribution = new DefaultImageRenderContribution();\nexport const defaultImageBackgroundRenderContribution = defaultBaseBackgroundRenderContribution;\n"]}
@@ -25,14 +25,14 @@ 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, keepStrokeScale: keepStrokeScale = rectAttribute.keepStrokeScale} = rect.attribute;
28
+ const {cornerRadius: cornerRadius = rectAttribute.cornerRadius, cornerType: cornerType = rectAttribute.cornerType, 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
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
- createRectPath(context, nextX, nextY, width - sign * dw, height - sign * dw, cornerRadius)),
35
+ createRectPath(context, nextX, nextY, width - sign * dw, height - sign * dw, cornerRadius, "bevel" !== cornerType)),
36
36
  context.setShadowBlendStyle && context.setShadowBlendStyle(rect, rect.attribute, rectAttribute),
37
37
  strokeCb) strokeCb(context, borderStyle, rectAttribute[key]); else if (doStroke) {
38
38
  const lastOpacity = rectAttribute[key].opacity;
@@ -63,13 +63,13 @@ let SplitRectAfterRenderContribution = class {
63
63
  this.time = BaseRenderContributionTime.afterFillStroke, this.useStyle = !0, this.order = 0;
64
64
  }
65
65
  drawShape(rect, context, x, y, doFill, doStroke, fVisible, sVisible, groupAttribute, drawContext, fillCb, strokeCb) {
66
- const {x1: x1, y1: y1, x: originX = groupAttribute.x, y: originY = groupAttribute.y, stroke: stroke = groupAttribute.stroke, cornerRadius: cornerRadius = groupAttribute.cornerRadius} = rect.attribute;
66
+ const {x1: x1, y1: y1, x: originX = groupAttribute.x, y: originY = groupAttribute.y, stroke: stroke = groupAttribute.stroke, cornerRadius: cornerRadius = groupAttribute.cornerRadius, cornerType: cornerType = groupAttribute.cornerType} = rect.attribute;
67
67
  let {width: width, height: height} = rect.attribute;
68
68
  if (width = (null != width ? width : x1 - originX) || 0, height = (null != height ? height : y1 - originY) || 0,
69
69
  Array.isArray(stroke) && stroke.some((s => !1 === s))) {
70
70
  if (context.setStrokeStyle(rect, rect.attribute, x, y, groupAttribute), !(0 === cornerRadius || isArray(cornerRadius) && cornerRadius.every((num => 0 === num)))) {
71
71
  let lastStroke, lastStrokeI = 0;
72
- return createRectPath(context, x, y, width, height, cornerRadius, new Array(4).fill(0).map(((_, i) => (x1, y1, x2, y2) => {
72
+ return createRectPath(context, x, y, width, height, cornerRadius, "bevel" !== cornerType, new Array(4).fill(0).map(((_, i) => (x1, y1, x2, y2) => {
73
73
  stroke[i] && (lastStrokeI === i - 1 && stroke[i] === lastStroke || (context.setStrokeStyle(rect, Object.assign(Object.assign({}, rect.attribute), {
74
74
  stroke: stroke[i]
75
75
  }), x, y, groupAttribute), context.beginPath(), context.moveTo(x1, y1), lastStroke = stroke[i]),
@@ -1 +1 @@
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,OAAO,KAAK,KAAK,CAAC;QACnE,IAAI,CAAC,CAAC,aAAa,IAAI,aAAa,CAAC,EAAE;YACrC,OAAO;SACR;QACD,MAAM,EACJ,YAAY,GAAG,aAAa,CAAC,YAAY,EACzC,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AAM,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"]}
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;IAmGpB,CAAC;IAlGC,SAAS,CACP,IAAW,EAC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F,CAAA;AAhHY,gCAAgC;IAD5C,UAAU,EAAE;GACA,gCAAgC,CAgH5C;SAhHY,gCAAgC;AAkH7C,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 cornerType = rectAttribute.cornerType,\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(\n context,\n nextX,\n nextY,\n width - sign * dw,\n height - sign * dw,\n cornerRadius,\n cornerType !== 'bevel'\n );\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 cornerType = groupAttribute.cornerType\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 cornerType !== 'bevel',\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,4 +1,4 @@
1
- import type { IGraphicAttribute, IContext2d, IMarkAttribute, ISymbol, ISymbolGraphicAttribute, IThemeAttribute, ISymbolRenderContribution, IDrawContext } from '../../../../interface';
1
+ import type { IGraphicAttribute, IContext2d, IMarkAttribute, ISymbol, ISymbolGraphicAttribute, IThemeAttribute, ISymbolRenderContribution, IDrawContext, IBaseRenderContribution } from '../../../../interface';
2
2
  import { BaseRenderContributionTime } from '../../../../common/enums';
3
3
  export declare class DefaultSymbolRenderContribution implements ISymbolRenderContribution {
4
4
  time: BaseRenderContributionTime;
@@ -6,6 +6,13 @@ export declare class DefaultSymbolRenderContribution implements ISymbolRenderCon
6
6
  order: number;
7
7
  drawShape(symbol: ISymbol, context: IContext2d, x: number, y: number, doFill: boolean, doStroke: boolean, fVisible: boolean, sVisible: boolean, symbolAttribute: Required<ISymbolGraphicAttribute>, drawContext: IDrawContext, fillCb?: (ctx: IContext2d, markAttribute: Partial<IMarkAttribute & IGraphicAttribute>, themeAttribute: IThemeAttribute) => boolean, strokeCb?: (ctx: IContext2d, markAttribute: Partial<IMarkAttribute & IGraphicAttribute>, themeAttribute: IThemeAttribute) => boolean): void;
8
8
  }
9
+ export declare class DefaultSymbolClipRangeStrokeRenderContribution implements IBaseRenderContribution<ISymbol, ISymbolGraphicAttribute> {
10
+ time: BaseRenderContributionTime;
11
+ useStyle: boolean;
12
+ order: number;
13
+ drawShape(graphic: ISymbol, context: IContext2d, x: number, y: number, doFill: boolean, doStroke: boolean, fVisible: boolean, sVisible: boolean, graphicAttribute: Required<ISymbolGraphicAttribute>, drawContext: IDrawContext, fillCb?: (ctx: IContext2d, markAttribute: Partial<IGraphicAttribute>, themeAttribute: IThemeAttribute) => boolean, strokeCb?: (ctx: IContext2d, markAttribute: Partial<IGraphicAttribute>, themeAttribute: IThemeAttribute) => boolean, options?: any): void;
14
+ }
9
15
  export declare const defaultSymbolRenderContribution: DefaultSymbolRenderContribution;
16
+ export declare const defaultSymbolClipRangeStrokeRenderContribution: DefaultSymbolClipRangeStrokeRenderContribution;
10
17
  export declare const defaultSymbolTextureRenderContribution: import("./base-texture-contribution-render").DefaultBaseTextureRenderContribution;
11
18
  export declare const defaultSymbolBackgroundRenderContribution: import("./base-contribution-render").DefaultBaseBackgroundRenderContribution;
@@ -29,8 +29,34 @@ export class DefaultSymbolRenderContribution {
29
29
  }
30
30
  }
31
31
 
32
+ export class DefaultSymbolClipRangeStrokeRenderContribution {
33
+ constructor() {
34
+ this.time = BaseRenderContributionTime.afterFillStroke, this.useStyle = !0, this.order = 0;
35
+ }
36
+ drawShape(graphic, context, x, y, doFill, doStroke, fVisible, sVisible, graphicAttribute, drawContext, fillCb, strokeCb, options) {
37
+ const {clipRange: clipRange = graphicAttribute.clipRange, x: originX = graphicAttribute.x, y: originY = graphicAttribute.y, z: z = graphicAttribute.z, size: size = graphicAttribute.size, scaleX: scaleX = graphicAttribute.scaleX, scaleY: scaleY = graphicAttribute.scaleY} = graphic.attribute, parsedPath = graphic.getParsedPath();
38
+ if (!(parsedPath && clipRange < 1 && clipRange > 0)) return;
39
+ context.beginPath(), parsedPath.drawWithClipRange && parsedPath.drawWithClipRange(context, size, x, y, clipRange, z, ((p, a) => {
40
+ var _a, _b, _c, _d;
41
+ if (graphic._parsedPath.svgCache) {
42
+ const obj = Object.assign({}, a);
43
+ obj.fill = null !== (_a = a.fill) && void 0 !== _a ? _a : graphic.attribute.fill,
44
+ obj.opacity = null !== (_b = a.opacity) && void 0 !== _b ? _b : graphic.attribute.opacity,
45
+ obj.fillOpacity = graphic.attribute.fillOpacity, obj.stroke = null !== (_c = a.stroke) && void 0 !== _c ? _c : graphic.attribute.stroke,
46
+ obj.lineWidth = null !== (_d = a.lineWidth) && void 0 !== _d ? _d : graphic.attribute.lineWidth,
47
+ a = obj;
48
+ }
49
+ a.stroke && (strokeCb ? strokeCb(context, graphic.attribute, graphicAttribute) : sVisible && (context.setStrokeStyle(graphic, a, (originX - x) / scaleX, (originY - y) / scaleY, graphicAttribute),
50
+ context.stroke()));
51
+ })), doStroke && !parsedPath.isSvg && (strokeCb ? strokeCb(context, graphic.attribute, graphicAttribute) : sVisible && (context.setStrokeStyle(graphic, graphic.attribute, (originX - x) / scaleX, (originY - y) / scaleY, graphicAttribute),
52
+ context.stroke()));
53
+ }
54
+ }
55
+
32
56
  export const defaultSymbolRenderContribution = new DefaultSymbolRenderContribution;
33
57
 
58
+ export const defaultSymbolClipRangeStrokeRenderContribution = new DefaultSymbolClipRangeStrokeRenderContribution;
59
+
34
60
  export const defaultSymbolTextureRenderContribution = defaultBaseTextureRenderContribution;
35
61
 
36
62
  export const defaultSymbolBackgroundRenderContribution = defaultBaseBackgroundRenderContribution;
@@ -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;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,W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AAE;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"]}
1
+ {"version":3,"sources":["../src/render/contributions/render/contributions/symbol-contribution-render.ts"],"names":[],"mappings":"AAaA,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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C,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 IBaseRenderContribution,\n ICustomPath2D\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 class DefaultSymbolClipRangeStrokeRenderContribution\n implements IBaseRenderContribution<ISymbol, ISymbolGraphicAttribute>\n{\n time: BaseRenderContributionTime = BaseRenderContributionTime.afterFillStroke;\n useStyle: boolean = true;\n order: number = 0;\n\n drawShape(\n graphic: ISymbol,\n context: IContext2d,\n x: number,\n y: number,\n doFill: boolean,\n doStroke: boolean,\n fVisible: boolean,\n sVisible: boolean,\n graphicAttribute: Required<ISymbolGraphicAttribute>,\n drawContext: IDrawContext,\n fillCb?: (ctx: IContext2d, markAttribute: Partial<IGraphicAttribute>, themeAttribute: IThemeAttribute) => boolean,\n strokeCb?: (ctx: IContext2d, markAttribute: Partial<IGraphicAttribute>, themeAttribute: IThemeAttribute) => boolean,\n options?: any\n ) {\n const {\n clipRange = graphicAttribute.clipRange,\n x: originX = graphicAttribute.x,\n y: originY = graphicAttribute.y,\n z = graphicAttribute.z,\n size = graphicAttribute.size,\n scaleX = graphicAttribute.scaleX,\n scaleY = graphicAttribute.scaleY\n } = graphic.attribute;\n const parsedPath = graphic.getParsedPath();\n // todo: 考虑使用path\n if (!(parsedPath && clipRange < 1 && clipRange > 0)) {\n return;\n }\n\n const callback = (p: ICustomPath2D, a: any) => {\n // 如果是svg的话,合并一下fill和stroke\n if (graphic._parsedPath.svgCache) {\n const obj = Object.assign({}, a);\n obj.fill = a.fill ?? graphic.attribute.fill;\n obj.opacity = a.opacity ?? graphic.attribute.opacity;\n obj.fillOpacity = graphic.attribute.fillOpacity;\n obj.stroke = a.stroke ?? graphic.attribute.stroke;\n obj.lineWidth = a.lineWidth ?? graphic.attribute.lineWidth;\n a = obj;\n }\n\n if (a.stroke) {\n if (strokeCb) {\n strokeCb(context, graphic.attribute, graphicAttribute);\n } else if (sVisible) {\n context.setStrokeStyle(graphic, a, (originX - x) / scaleX, (originY - y) / scaleY, graphicAttribute);\n context.stroke();\n }\n }\n };\n\n context.beginPath();\n parsedPath.drawWithClipRange && parsedPath.drawWithClipRange(context, size, x, y, clipRange, z, callback);\n\n if (doStroke && !parsedPath.isSvg) {\n if (strokeCb) {\n strokeCb(context, graphic.attribute, graphicAttribute);\n } else if (sVisible) {\n context.setStrokeStyle(\n graphic,\n graphic.attribute,\n (originX - x) / scaleX,\n (originY - y) / scaleY,\n graphicAttribute\n );\n context.stroke();\n }\n }\n }\n}\n\nexport const defaultSymbolRenderContribution = new DefaultSymbolRenderContribution();\nexport const defaultSymbolClipRangeStrokeRenderContribution = new DefaultSymbolClipRangeStrokeRenderContribution();\nexport const defaultSymbolTextureRenderContribution = defaultBaseTextureRenderContribution;\nexport const defaultSymbolBackgroundRenderContribution = defaultBaseBackgroundRenderContribution;\n"]}