ding-image-editor 3.15.3

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 (374) hide show
  1. package/README.md +193 -0
  2. package/dist/svg/icon-a.svg +376 -0
  3. package/dist/svg/icon-b.svg +369 -0
  4. package/dist/svg/icon-c.svg +369 -0
  5. package/dist/svg/icon-d.svg +369 -0
  6. package/dist/tui-image-editor.css +6 -0
  7. package/dist/tui-image-editor.js +62329 -0
  8. package/dist/tui-image-editor.min.css +5 -0
  9. package/dist/tui-image-editor.min.js +15 -0
  10. package/index.d.ts +334 -0
  11. package/package.json +52 -0
  12. package/src/css/buttons.styl +102 -0
  13. package/src/css/checkbox.styl +86 -0
  14. package/src/css/colorpicker.styl +98 -0
  15. package/src/css/gridtable.styl +45 -0
  16. package/src/css/icon.styl +44 -0
  17. package/src/css/index.styl +17 -0
  18. package/src/css/main.styl +163 -0
  19. package/src/css/position.styl +309 -0
  20. package/src/css/range.styl +91 -0
  21. package/src/css/submenu.styl +168 -0
  22. package/src/index.js +29 -0
  23. package/src/js/action.js +686 -0
  24. package/src/js/command/addIcon.js +42 -0
  25. package/src/js/command/addImageObject.js +34 -0
  26. package/src/js/command/addObject.js +43 -0
  27. package/src/js/command/addShape.js +51 -0
  28. package/src/js/command/addText.js +73 -0
  29. package/src/js/command/applyFilter.js +95 -0
  30. package/src/js/command/changeIconColor.js +48 -0
  31. package/src/js/command/changeSelection.js +31 -0
  32. package/src/js/command/changeShape.js +84 -0
  33. package/src/js/command/changeText.js +44 -0
  34. package/src/js/command/changeTextStyle.js +80 -0
  35. package/src/js/command/clearObjects.js +33 -0
  36. package/src/js/command/flip.js +36 -0
  37. package/src/js/command/loadImage.js +58 -0
  38. package/src/js/command/removeFilter.js +38 -0
  39. package/src/js/command/removeObject.js +37 -0
  40. package/src/js/command/resize.js +41 -0
  41. package/src/js/command/resizeCanvasDimension.js +40 -0
  42. package/src/js/command/rotate.js +64 -0
  43. package/src/js/command/setObjectPosition.js +50 -0
  44. package/src/js/command/setObjectProperties.js +55 -0
  45. package/src/js/component/cropper.js +407 -0
  46. package/src/js/component/filter.js +229 -0
  47. package/src/js/component/flip.js +146 -0
  48. package/src/js/component/freeDrawing.js +144 -0
  49. package/src/js/component/icon.js +246 -0
  50. package/src/js/component/imageLoader.js +84 -0
  51. package/src/js/component/line.js +205 -0
  52. package/src/js/component/resize.js +103 -0
  53. package/src/js/component/rotation.js +91 -0
  54. package/src/js/component/shape.js +601 -0
  55. package/src/js/component/text.js +572 -0
  56. package/src/js/component/zoom.js +708 -0
  57. package/src/js/consts.js +404 -0
  58. package/src/js/drawingMode/cropper.js +35 -0
  59. package/src/js/drawingMode/freeDrawing.js +36 -0
  60. package/src/js/drawingMode/icon.js +35 -0
  61. package/src/js/drawingMode/lineDrawing.js +36 -0
  62. package/src/js/drawingMode/resize.js +35 -0
  63. package/src/js/drawingMode/shape.js +35 -0
  64. package/src/js/drawingMode/text.js +35 -0
  65. package/src/js/drawingMode/zoom.js +37 -0
  66. package/src/js/extension/arrowLine.js +172 -0
  67. package/src/js/extension/blur.js +29 -0
  68. package/src/js/extension/colorFilter.js +104 -0
  69. package/src/js/extension/cropzone.js +568 -0
  70. package/src/js/extension/emboss.js +29 -0
  71. package/src/js/extension/mask.js +90 -0
  72. package/src/js/extension/sharpen.js +29 -0
  73. package/src/js/factory/command.js +36 -0
  74. package/src/js/factory/errorMessage.js +27 -0
  75. package/src/js/graphics.js +1539 -0
  76. package/src/js/helper/imagetracer.js +1396 -0
  77. package/src/js/helper/selectionModifyHelper.js +86 -0
  78. package/src/js/helper/shapeFilterFillHelper.js +564 -0
  79. package/src/js/helper/shapeResizeHelper.js +237 -0
  80. package/src/js/imageEditor.js +1795 -0
  81. package/src/js/interface/command.js +131 -0
  82. package/src/js/interface/component.js +127 -0
  83. package/src/js/interface/drawingMode.js +47 -0
  84. package/src/js/invoker.js +292 -0
  85. package/src/js/polyfill.js +498 -0
  86. package/src/js/ui/crop.js +139 -0
  87. package/src/js/ui/draw.js +187 -0
  88. package/src/js/ui/filter.js +510 -0
  89. package/src/js/ui/flip.js +87 -0
  90. package/src/js/ui/history.js +171 -0
  91. package/src/js/ui/icon.js +191 -0
  92. package/src/js/ui/locale/locale.js +19 -0
  93. package/src/js/ui/mask.js +96 -0
  94. package/src/js/ui/panelMenu.js +130 -0
  95. package/src/js/ui/resize.js +241 -0
  96. package/src/js/ui/rotate.js +123 -0
  97. package/src/js/ui/shape.js +265 -0
  98. package/src/js/ui/submenuBase.js +122 -0
  99. package/src/js/ui/template/controls.js +21 -0
  100. package/src/js/ui/template/mainContainer.js +38 -0
  101. package/src/js/ui/template/style.js +146 -0
  102. package/src/js/ui/template/submenu/crop.js +73 -0
  103. package/src/js/ui/template/submenu/draw.js +42 -0
  104. package/src/js/ui/template/submenu/filter.js +157 -0
  105. package/src/js/ui/template/submenu/flip.js +41 -0
  106. package/src/js/ui/template/submenu/history.js +22 -0
  107. package/src/js/ui/template/submenu/icon.js +108 -0
  108. package/src/js/ui/template/submenu/mask.js +30 -0
  109. package/src/js/ui/template/submenu/resize.js +54 -0
  110. package/src/js/ui/template/submenu/rotate.js +32 -0
  111. package/src/js/ui/template/submenu/shape.js +45 -0
  112. package/src/js/ui/template/submenu/text.js +67 -0
  113. package/src/js/ui/template/submenu/zoom.js +41 -0
  114. package/src/js/ui/text.js +279 -0
  115. package/src/js/ui/theme/standard.js +220 -0
  116. package/src/js/ui/theme/theme.js +249 -0
  117. package/src/js/ui/tools/colorpicker.js +250 -0
  118. package/src/js/ui/tools/range.js +390 -0
  119. package/src/js/ui.js +858 -0
  120. package/src/js/util.js +551 -0
  121. package/src/svg/default.svg +335 -0
  122. package/src/svg/icon-a/ic-apply.svg +6 -0
  123. package/src/svg/icon-a/ic-cancel.svg +6 -0
  124. package/src/svg/icon-a/ic-color-transparent-w.svg +12 -0
  125. package/src/svg/icon-a/ic-crop.svg +7 -0
  126. package/src/svg/icon-a/ic-delete-all.svg +6 -0
  127. package/src/svg/icon-a/ic-delete.svg +6 -0
  128. package/src/svg/icon-a/ic-draw-free.svg +5 -0
  129. package/src/svg/icon-a/ic-draw-line.svg +5 -0
  130. package/src/svg/icon-a/ic-draw.svg +6 -0
  131. package/src/svg/icon-a/ic-filter.svg +7 -0
  132. package/src/svg/icon-a/ic-flip-reset.svg +7 -0
  133. package/src/svg/icon-a/ic-flip-x.svg +6 -0
  134. package/src/svg/icon-a/ic-flip-y.svg +6 -0
  135. package/src/svg/icon-a/ic-flip.svg +6 -0
  136. package/src/svg/icon-a/ic-history-check.svg +5 -0
  137. package/src/svg/icon-a/ic-history-crop.svg +7 -0
  138. package/src/svg/icon-a/ic-history-delete.svg +9 -0
  139. package/src/svg/icon-a/ic-history-draw.svg +7 -0
  140. package/src/svg/icon-a/ic-history-filter.svg +8 -0
  141. package/src/svg/icon-a/ic-history-flip.svg +6 -0
  142. package/src/svg/icon-a/ic-history-group.svg +9 -0
  143. package/src/svg/icon-a/ic-history-icon.svg +6 -0
  144. package/src/svg/icon-a/ic-history-load.svg +7 -0
  145. package/src/svg/icon-a/ic-history-mask.svg +9 -0
  146. package/src/svg/icon-a/ic-history-resize.svg +12 -0
  147. package/src/svg/icon-a/ic-history-rotate.svg +16 -0
  148. package/src/svg/icon-a/ic-history-shape.svg +7 -0
  149. package/src/svg/icon-a/ic-history-text.svg +8 -0
  150. package/src/svg/icon-a/ic-history.svg +6 -0
  151. package/src/svg/icon-a/ic-icon-arrow-2.svg +5 -0
  152. package/src/svg/icon-a/ic-icon-arrow-3.svg +5 -0
  153. package/src/svg/icon-a/ic-icon-arrow.svg +5 -0
  154. package/src/svg/icon-a/ic-icon-bubble.svg +5 -0
  155. package/src/svg/icon-a/ic-icon-heart.svg +5 -0
  156. package/src/svg/icon-a/ic-icon-load.svg +8 -0
  157. package/src/svg/icon-a/ic-icon-location.svg +8 -0
  158. package/src/svg/icon-a/ic-icon-polygon.svg +5 -0
  159. package/src/svg/icon-a/ic-icon-star-2.svg +5 -0
  160. package/src/svg/icon-a/ic-icon-star.svg +5 -0
  161. package/src/svg/icon-a/ic-icon.svg +5 -0
  162. package/src/svg/icon-a/ic-mask-load.svg +8 -0
  163. package/src/svg/icon-a/ic-mask.svg +6 -0
  164. package/src/svg/icon-a/ic-redo.svg +7 -0
  165. package/src/svg/icon-a/ic-reset.svg +7 -0
  166. package/src/svg/icon-a/ic-resize.svg +13 -0
  167. package/src/svg/icon-a/ic-rotate-clockwise.svg +7 -0
  168. package/src/svg/icon-a/ic-rotate-counterclockwise.svg +7 -0
  169. package/src/svg/icon-a/ic-rotate.svg +7 -0
  170. package/src/svg/icon-a/ic-shape-circle.svg +5 -0
  171. package/src/svg/icon-a/ic-shape-rectangle.svg +5 -0
  172. package/src/svg/icon-a/ic-shape-triangle.svg +5 -0
  173. package/src/svg/icon-a/ic-shape.svg +6 -0
  174. package/src/svg/icon-a/ic-text-align-center.svg +6 -0
  175. package/src/svg/icon-a/ic-text-align-left.svg +6 -0
  176. package/src/svg/icon-a/ic-text-align-right.svg +6 -0
  177. package/src/svg/icon-a/ic-text-bold.svg +7 -0
  178. package/src/svg/icon-a/ic-text-italic.svg +6 -0
  179. package/src/svg/icon-a/ic-text-underline.svg +7 -0
  180. package/src/svg/icon-a/ic-text.svg +7 -0
  181. package/src/svg/icon-a/ic-undo.svg +7 -0
  182. package/src/svg/icon-a/ic-zoom-hand.svg +8 -0
  183. package/src/svg/icon-a/ic-zoom-zoom-in.svg +10 -0
  184. package/src/svg/icon-a/ic-zoom-zoom-out.svg +9 -0
  185. package/src/svg/icon-a/img-bi.svg +5 -0
  186. package/src/svg/icon-b/ic-apply.svg +6 -0
  187. package/src/svg/icon-b/ic-cancel.svg +6 -0
  188. package/src/svg/icon-b/ic-crop.svg +7 -0
  189. package/src/svg/icon-b/ic-delete-all.svg +6 -0
  190. package/src/svg/icon-b/ic-delete.svg +6 -0
  191. package/src/svg/icon-b/ic-draw-free.svg +5 -0
  192. package/src/svg/icon-b/ic-draw-line.svg +5 -0
  193. package/src/svg/icon-b/ic-draw.svg +6 -0
  194. package/src/svg/icon-b/ic-filter.svg +7 -0
  195. package/src/svg/icon-b/ic-flip-reset.svg +7 -0
  196. package/src/svg/icon-b/ic-flip-x.svg +6 -0
  197. package/src/svg/icon-b/ic-flip-y.svg +6 -0
  198. package/src/svg/icon-b/ic-flip.svg +6 -0
  199. package/src/svg/icon-b/ic-history-check.svg +5 -0
  200. package/src/svg/icon-b/ic-history-crop.svg +7 -0
  201. package/src/svg/icon-b/ic-history-delete.svg +9 -0
  202. package/src/svg/icon-b/ic-history-draw.svg +7 -0
  203. package/src/svg/icon-b/ic-history-filter.svg +8 -0
  204. package/src/svg/icon-b/ic-history-flip.svg +6 -0
  205. package/src/svg/icon-b/ic-history-group.svg +9 -0
  206. package/src/svg/icon-b/ic-history-icon.svg +6 -0
  207. package/src/svg/icon-b/ic-history-load.svg +7 -0
  208. package/src/svg/icon-b/ic-history-mask.svg +9 -0
  209. package/src/svg/icon-b/ic-history-resize.svg +12 -0
  210. package/src/svg/icon-b/ic-history-rotate.svg +16 -0
  211. package/src/svg/icon-b/ic-history-shape.svg +7 -0
  212. package/src/svg/icon-b/ic-history-text.svg +8 -0
  213. package/src/svg/icon-b/ic-history.svg +6 -0
  214. package/src/svg/icon-b/ic-icon-arrow-2.svg +5 -0
  215. package/src/svg/icon-b/ic-icon-arrow-3.svg +5 -0
  216. package/src/svg/icon-b/ic-icon-arrow.svg +5 -0
  217. package/src/svg/icon-b/ic-icon-bubble.svg +5 -0
  218. package/src/svg/icon-b/ic-icon-heart.svg +5 -0
  219. package/src/svg/icon-b/ic-icon-load.svg +8 -0
  220. package/src/svg/icon-b/ic-icon-location.svg +8 -0
  221. package/src/svg/icon-b/ic-icon-polygon.svg +5 -0
  222. package/src/svg/icon-b/ic-icon-star-2.svg +5 -0
  223. package/src/svg/icon-b/ic-icon-star.svg +5 -0
  224. package/src/svg/icon-b/ic-icon.svg +5 -0
  225. package/src/svg/icon-b/ic-mask-load.svg +8 -0
  226. package/src/svg/icon-b/ic-mask.svg +6 -0
  227. package/src/svg/icon-b/ic-redo.svg +7 -0
  228. package/src/svg/icon-b/ic-reset.svg +7 -0
  229. package/src/svg/icon-b/ic-resize.svg +13 -0
  230. package/src/svg/icon-b/ic-rotate-clockwise.svg +7 -0
  231. package/src/svg/icon-b/ic-rotate-counterclockwise.svg +7 -0
  232. package/src/svg/icon-b/ic-rotate.svg +7 -0
  233. package/src/svg/icon-b/ic-shape-circle.svg +5 -0
  234. package/src/svg/icon-b/ic-shape-rectangle.svg +5 -0
  235. package/src/svg/icon-b/ic-shape-triangle.svg +5 -0
  236. package/src/svg/icon-b/ic-shape.svg +6 -0
  237. package/src/svg/icon-b/ic-text-align-center.svg +6 -0
  238. package/src/svg/icon-b/ic-text-align-left.svg +6 -0
  239. package/src/svg/icon-b/ic-text-align-right.svg +6 -0
  240. package/src/svg/icon-b/ic-text-bold.svg +7 -0
  241. package/src/svg/icon-b/ic-text-italic.svg +6 -0
  242. package/src/svg/icon-b/ic-text-underline.svg +7 -0
  243. package/src/svg/icon-b/ic-text.svg +7 -0
  244. package/src/svg/icon-b/ic-undo.svg +7 -0
  245. package/src/svg/icon-b/ic-zoom-hand.svg +8 -0
  246. package/src/svg/icon-b/ic-zoom-zoom-in.svg +12 -0
  247. package/src/svg/icon-b/ic-zoom-zoom-out.svg +11 -0
  248. package/src/svg/icon-b/img-bi.svg +5 -0
  249. package/src/svg/icon-c/ic-apply.svg +6 -0
  250. package/src/svg/icon-c/ic-cancel.svg +6 -0
  251. package/src/svg/icon-c/ic-crop.svg +7 -0
  252. package/src/svg/icon-c/ic-delete-all.svg +6 -0
  253. package/src/svg/icon-c/ic-delete.svg +6 -0
  254. package/src/svg/icon-c/ic-draw-free.svg +5 -0
  255. package/src/svg/icon-c/ic-draw-line.svg +5 -0
  256. package/src/svg/icon-c/ic-draw.svg +6 -0
  257. package/src/svg/icon-c/ic-filter.svg +7 -0
  258. package/src/svg/icon-c/ic-flip-reset.svg +7 -0
  259. package/src/svg/icon-c/ic-flip-x.svg +6 -0
  260. package/src/svg/icon-c/ic-flip-y.svg +6 -0
  261. package/src/svg/icon-c/ic-flip.svg +6 -0
  262. package/src/svg/icon-c/ic-history-check.svg +5 -0
  263. package/src/svg/icon-c/ic-history-crop.svg +7 -0
  264. package/src/svg/icon-c/ic-history-delete.svg +9 -0
  265. package/src/svg/icon-c/ic-history-draw.svg +7 -0
  266. package/src/svg/icon-c/ic-history-filter.svg +8 -0
  267. package/src/svg/icon-c/ic-history-flip.svg +6 -0
  268. package/src/svg/icon-c/ic-history-group.svg +9 -0
  269. package/src/svg/icon-c/ic-history-icon.svg +6 -0
  270. package/src/svg/icon-c/ic-history-load.svg +7 -0
  271. package/src/svg/icon-c/ic-history-mask.svg +9 -0
  272. package/src/svg/icon-c/ic-history-resize.svg +12 -0
  273. package/src/svg/icon-c/ic-history-rotate.svg +16 -0
  274. package/src/svg/icon-c/ic-history-shape.svg +7 -0
  275. package/src/svg/icon-c/ic-history-text.svg +8 -0
  276. package/src/svg/icon-c/ic-history.svg +6 -0
  277. package/src/svg/icon-c/ic-icon-arrow-2.svg +5 -0
  278. package/src/svg/icon-c/ic-icon-arrow-3.svg +5 -0
  279. package/src/svg/icon-c/ic-icon-arrow.svg +5 -0
  280. package/src/svg/icon-c/ic-icon-bubble.svg +5 -0
  281. package/src/svg/icon-c/ic-icon-heart.svg +5 -0
  282. package/src/svg/icon-c/ic-icon-load.svg +8 -0
  283. package/src/svg/icon-c/ic-icon-location.svg +8 -0
  284. package/src/svg/icon-c/ic-icon-polygon.svg +5 -0
  285. package/src/svg/icon-c/ic-icon-star-2.svg +5 -0
  286. package/src/svg/icon-c/ic-icon-star.svg +5 -0
  287. package/src/svg/icon-c/ic-icon.svg +5 -0
  288. package/src/svg/icon-c/ic-mask-load.svg +8 -0
  289. package/src/svg/icon-c/ic-mask.svg +6 -0
  290. package/src/svg/icon-c/ic-redo.svg +7 -0
  291. package/src/svg/icon-c/ic-reset.svg +7 -0
  292. package/src/svg/icon-c/ic-resize.svg +13 -0
  293. package/src/svg/icon-c/ic-rotate-clockwise.svg +7 -0
  294. package/src/svg/icon-c/ic-rotate-counterclockwise.svg +7 -0
  295. package/src/svg/icon-c/ic-rotate.svg +7 -0
  296. package/src/svg/icon-c/ic-shape-circle.svg +5 -0
  297. package/src/svg/icon-c/ic-shape-rectangle.svg +5 -0
  298. package/src/svg/icon-c/ic-shape-triangle.svg +5 -0
  299. package/src/svg/icon-c/ic-shape.svg +6 -0
  300. package/src/svg/icon-c/ic-text-align-center.svg +6 -0
  301. package/src/svg/icon-c/ic-text-align-left.svg +6 -0
  302. package/src/svg/icon-c/ic-text-align-right.svg +6 -0
  303. package/src/svg/icon-c/ic-text-bold.svg +7 -0
  304. package/src/svg/icon-c/ic-text-italic.svg +6 -0
  305. package/src/svg/icon-c/ic-text-underline.svg +7 -0
  306. package/src/svg/icon-c/ic-text.svg +7 -0
  307. package/src/svg/icon-c/ic-undo.svg +7 -0
  308. package/src/svg/icon-c/ic-zoom-hand.svg +8 -0
  309. package/src/svg/icon-c/ic-zoom-zoom-in.svg +12 -0
  310. package/src/svg/icon-c/ic-zoom-zoom-out.svg +11 -0
  311. package/src/svg/icon-c/img-bi.svg +5 -0
  312. package/src/svg/icon-d/ic-apply.svg +6 -0
  313. package/src/svg/icon-d/ic-cancel.svg +6 -0
  314. package/src/svg/icon-d/ic-crop.svg +7 -0
  315. package/src/svg/icon-d/ic-delete-all.svg +6 -0
  316. package/src/svg/icon-d/ic-delete.svg +6 -0
  317. package/src/svg/icon-d/ic-draw-free.svg +5 -0
  318. package/src/svg/icon-d/ic-draw-line.svg +5 -0
  319. package/src/svg/icon-d/ic-draw.svg +6 -0
  320. package/src/svg/icon-d/ic-filter.svg +7 -0
  321. package/src/svg/icon-d/ic-flip-reset.svg +7 -0
  322. package/src/svg/icon-d/ic-flip-x.svg +6 -0
  323. package/src/svg/icon-d/ic-flip-y.svg +6 -0
  324. package/src/svg/icon-d/ic-flip.svg +6 -0
  325. package/src/svg/icon-d/ic-history-check.svg +5 -0
  326. package/src/svg/icon-d/ic-history-crop.svg +7 -0
  327. package/src/svg/icon-d/ic-history-delete.svg +9 -0
  328. package/src/svg/icon-d/ic-history-draw.svg +7 -0
  329. package/src/svg/icon-d/ic-history-filter.svg +8 -0
  330. package/src/svg/icon-d/ic-history-flip.svg +6 -0
  331. package/src/svg/icon-d/ic-history-group.svg +9 -0
  332. package/src/svg/icon-d/ic-history-icon.svg +6 -0
  333. package/src/svg/icon-d/ic-history-load.svg +7 -0
  334. package/src/svg/icon-d/ic-history-mask.svg +9 -0
  335. package/src/svg/icon-d/ic-history-resize.svg +12 -0
  336. package/src/svg/icon-d/ic-history-rotate.svg +16 -0
  337. package/src/svg/icon-d/ic-history-shape.svg +7 -0
  338. package/src/svg/icon-d/ic-history-text.svg +8 -0
  339. package/src/svg/icon-d/ic-history.svg +6 -0
  340. package/src/svg/icon-d/ic-icon-arrow-2.svg +5 -0
  341. package/src/svg/icon-d/ic-icon-arrow-3.svg +5 -0
  342. package/src/svg/icon-d/ic-icon-arrow.svg +5 -0
  343. package/src/svg/icon-d/ic-icon-bubble.svg +5 -0
  344. package/src/svg/icon-d/ic-icon-heart.svg +5 -0
  345. package/src/svg/icon-d/ic-icon-load.svg +8 -0
  346. package/src/svg/icon-d/ic-icon-location.svg +8 -0
  347. package/src/svg/icon-d/ic-icon-polygon.svg +5 -0
  348. package/src/svg/icon-d/ic-icon-star-2.svg +5 -0
  349. package/src/svg/icon-d/ic-icon-star.svg +5 -0
  350. package/src/svg/icon-d/ic-icon.svg +5 -0
  351. package/src/svg/icon-d/ic-mask-load.svg +8 -0
  352. package/src/svg/icon-d/ic-mask.svg +6 -0
  353. package/src/svg/icon-d/ic-redo.svg +7 -0
  354. package/src/svg/icon-d/ic-reset.svg +7 -0
  355. package/src/svg/icon-d/ic-resize.svg +13 -0
  356. package/src/svg/icon-d/ic-rotate-clockwise.svg +7 -0
  357. package/src/svg/icon-d/ic-rotate-counterclockwise.svg +7 -0
  358. package/src/svg/icon-d/ic-rotate.svg +7 -0
  359. package/src/svg/icon-d/ic-shape-circle.svg +5 -0
  360. package/src/svg/icon-d/ic-shape-rectangle.svg +5 -0
  361. package/src/svg/icon-d/ic-shape-triangle.svg +5 -0
  362. package/src/svg/icon-d/ic-shape.svg +6 -0
  363. package/src/svg/icon-d/ic-text-align-center.svg +6 -0
  364. package/src/svg/icon-d/ic-text-align-left.svg +6 -0
  365. package/src/svg/icon-d/ic-text-align-right.svg +6 -0
  366. package/src/svg/icon-d/ic-text-bold.svg +7 -0
  367. package/src/svg/icon-d/ic-text-italic.svg +6 -0
  368. package/src/svg/icon-d/ic-text-underline.svg +7 -0
  369. package/src/svg/icon-d/ic-text.svg +7 -0
  370. package/src/svg/icon-d/ic-undo.svg +7 -0
  371. package/src/svg/icon-d/ic-zoom-hand.svg +8 -0
  372. package/src/svg/icon-d/ic-zoom-zoom-in.svg +12 -0
  373. package/src/svg/icon-d/ic-zoom-zoom-out.svg +11 -0
  374. package/src/svg/icon-d/img-bi.svg +5 -0
@@ -0,0 +1,86 @@
1
+ import { fabric } from 'fabric';
2
+ import extend from 'tui-code-snippet/object/extend';
3
+
4
+ /**
5
+ * Cached selection's info
6
+ * @type {Array}
7
+ * @private
8
+ */
9
+ let cachedUndoDataForChangeDimension = null;
10
+
11
+ /**
12
+ * Set cached undo data
13
+ * @param {Array} undoData - selection object
14
+ * @private
15
+ */
16
+ export function setCachedUndoDataForDimension(undoData) {
17
+ cachedUndoDataForChangeDimension = undoData;
18
+ }
19
+
20
+ /**
21
+ * Get cached undo data
22
+ * @returns {Object} cached undo data
23
+ * @private
24
+ */
25
+ export function getCachedUndoDataForDimension() {
26
+ return cachedUndoDataForChangeDimension;
27
+ }
28
+
29
+ /**
30
+ * Make undo data
31
+ * @param {fabric.Object} obj - selection object
32
+ * @param {Function} undoDatumMaker - make undo datum
33
+ * @returns {Array} undoData
34
+ * @private
35
+ */
36
+ export function makeSelectionUndoData(obj, undoDatumMaker) {
37
+ let undoData;
38
+
39
+ if (obj.type === 'activeSelection') {
40
+ undoData = obj.getObjects().map((item) => {
41
+ const { angle, left, top, scaleX, scaleY, width, height } = item;
42
+
43
+ fabric.util.addTransformToObject(item, obj.calcTransformMatrix());
44
+ const result = undoDatumMaker(item);
45
+
46
+ item.set({
47
+ angle,
48
+ left,
49
+ top,
50
+ width,
51
+ height,
52
+ scaleX,
53
+ scaleY,
54
+ });
55
+
56
+ return result;
57
+ });
58
+ } else {
59
+ undoData = [undoDatumMaker(obj)];
60
+ }
61
+
62
+ return undoData;
63
+ }
64
+
65
+ /**
66
+ * Make undo datum
67
+ * @param {number} id - object id
68
+ * @param {fabric.Object} obj - selection object
69
+ * @param {boolean} isSelection - whether or not object is selection
70
+ * @returns {Object} undo datum
71
+ * @private
72
+ */
73
+ export function makeSelectionUndoDatum(id, obj, isSelection) {
74
+ return isSelection
75
+ ? {
76
+ id,
77
+ width: obj.width,
78
+ height: obj.height,
79
+ top: obj.top,
80
+ left: obj.left,
81
+ angle: obj.angle,
82
+ scaleX: obj.scaleX,
83
+ scaleY: obj.scaleY,
84
+ }
85
+ : extend({ id }, obj);
86
+ }
@@ -0,0 +1,564 @@
1
+ import { fabric } from 'fabric';
2
+ import forEach from 'tui-code-snippet/collection/forEach';
3
+ import extend from 'tui-code-snippet/object/extend';
4
+ import resizeHelper from '@/helper/shapeResizeHelper';
5
+ import { capitalizeString, flipObject, setCustomProperty, getCustomProperty } from '@/util';
6
+
7
+ const FILTER_OPTION_MAP = {
8
+ pixelate: 'blocksize',
9
+ blur: 'blur',
10
+ };
11
+ const POSITION_DIMENSION_MAP = {
12
+ x: 'width',
13
+ y: 'height',
14
+ };
15
+
16
+ const FILTER_NAME_VALUE_MAP = flipObject(FILTER_OPTION_MAP);
17
+
18
+ /**
19
+ * Cached canvas image element for fill image
20
+ * @type {boolean}
21
+ * @private
22
+ */
23
+ let cachedCanvasImageElement = null;
24
+
25
+ /**
26
+ * Get background image of fill
27
+ * @param {fabric.Object} shapeObj - Shape object
28
+ * @returns {fabric.Image}
29
+ * @private
30
+ */
31
+ export function getFillImageFromShape(shapeObj) {
32
+ const { patternSourceCanvas } = getCustomProperty(shapeObj, 'patternSourceCanvas');
33
+ const [fillImage] = patternSourceCanvas.getObjects();
34
+
35
+ return fillImage;
36
+ }
37
+
38
+ /**
39
+ * Reset the image position in the filter type fill area.
40
+ * @param {fabric.Object} shapeObj - Shape object
41
+ * @private
42
+ */
43
+ export function rePositionFilterTypeFillImage(shapeObj) {
44
+ const { angle, flipX, flipY } = shapeObj;
45
+ const fillImage = getFillImageFromShape(shapeObj);
46
+ const rotatedShapeCornerDimension = getRotatedDimension(shapeObj);
47
+ const { right, bottom } = rotatedShapeCornerDimension;
48
+ let { width, height } = rotatedShapeCornerDimension;
49
+ const diffLeft = (width - shapeObj.width) / 2;
50
+ const diffTop = (height - shapeObj.height) / 2;
51
+ const cropX = shapeObj.left - shapeObj.width / 2 - diffLeft;
52
+ const cropY = shapeObj.top - shapeObj.height / 2 - diffTop;
53
+ let left = width / 2 - diffLeft;
54
+ let top = height / 2 - diffTop;
55
+ const fillImageMaxSize = Math.max(width, height) + Math.max(diffLeft, diffTop);
56
+
57
+ [left, top, width, height] = calculateFillImageDimensionOutsideCanvas({
58
+ shapeObj,
59
+ left,
60
+ top,
61
+ width,
62
+ height,
63
+ cropX,
64
+ cropY,
65
+ flipX,
66
+ flipY,
67
+ right,
68
+ bottom,
69
+ });
70
+
71
+ fillImage.set({
72
+ angle: flipX === flipY ? -angle : angle,
73
+ left,
74
+ top,
75
+ width,
76
+ height,
77
+ cropX,
78
+ cropY,
79
+ flipX,
80
+ flipY,
81
+ });
82
+
83
+ setCustomProperty(fillImage, { fillImageMaxSize });
84
+ }
85
+
86
+ /**
87
+ * Make filter option from fabric image
88
+ * @param {fabric.Image} imageObject - fabric image object
89
+ * @returns {object}
90
+ */
91
+ export function makeFilterOptionFromFabricImage(imageObject) {
92
+ return imageObject.filters.map((filter) => {
93
+ const [key] = Object.keys(filter);
94
+
95
+ return {
96
+ [FILTER_NAME_VALUE_MAP[key]]: filter[key],
97
+ };
98
+ });
99
+ }
100
+
101
+ /**
102
+ * Calculate fill image position and size for out of Canvas
103
+ * @param {Object} options - options for position dimension calculate
104
+ * @param {fabric.Object} shapeObj - shape object
105
+ * @param {number} left - original left position
106
+ * @param {number} top - original top position
107
+ * @param {number} width - image width
108
+ * @param {number} height - image height
109
+ * @param {number} cropX - image cropX
110
+ * @param {number} cropY - image cropY
111
+ * @param {boolean} flipX - shape flipX
112
+ * @param {boolean} flipY - shape flipY
113
+ * @returns {Object}
114
+ */
115
+ function calculateFillImageDimensionOutsideCanvas({
116
+ shapeObj,
117
+ left,
118
+ top,
119
+ width,
120
+ height,
121
+ cropX,
122
+ cropY,
123
+ flipX,
124
+ flipY,
125
+ right,
126
+ bottom,
127
+ }) {
128
+ const overflowAreaPositionFixer = (type, outDistance, imageLeft, imageTop) =>
129
+ calculateDistanceOverflowPart({
130
+ type,
131
+ outDistance,
132
+ shapeObj,
133
+ flipX,
134
+ flipY,
135
+ left: imageLeft,
136
+ top: imageTop,
137
+ });
138
+ const [originalWidth, originalHeight] = [width, height];
139
+
140
+ [left, top, width, height] = calculateDimensionLeftTopEdge(overflowAreaPositionFixer, {
141
+ left,
142
+ top,
143
+ width,
144
+ height,
145
+ cropX,
146
+ cropY,
147
+ });
148
+
149
+ [left, top, width, height] = calculateDimensionRightBottomEdge(overflowAreaPositionFixer, {
150
+ left,
151
+ top,
152
+ insideCanvasRealImageWidth: width,
153
+ insideCanvasRealImageHeight: height,
154
+ right,
155
+ bottom,
156
+ cropX,
157
+ cropY,
158
+ originalWidth,
159
+ originalHeight,
160
+ });
161
+
162
+ return [left, top, width, height];
163
+ }
164
+
165
+ /**
166
+ * Calculate fill image position and size for for right bottom edge
167
+ * @param {Function} overflowAreaPositionFixer - position fixer
168
+ * @param {Object} options - options for position dimension calculate
169
+ * @param {fabric.Object} shapeObj - shape object
170
+ * @param {number} left - original left position
171
+ * @param {number} top - original top position
172
+ * @param {number} width - image width
173
+ * @param {number} height - image height
174
+ * @param {number} right - image right
175
+ * @param {number} bottom - image bottom
176
+ * @param {number} cropX - image cropX
177
+ * @param {number} cropY - image cropY
178
+ * @param {boolean} originalWidth - image original width
179
+ * @param {boolean} originalHeight - image original height
180
+ * @returns {Object}
181
+ */
182
+ function calculateDimensionRightBottomEdge(
183
+ overflowAreaPositionFixer,
184
+ {
185
+ left,
186
+ top,
187
+ insideCanvasRealImageWidth,
188
+ insideCanvasRealImageHeight,
189
+ right,
190
+ bottom,
191
+ cropX,
192
+ cropY,
193
+ originalWidth,
194
+ originalHeight,
195
+ }
196
+ ) {
197
+ let [width, height] = [insideCanvasRealImageWidth, insideCanvasRealImageHeight];
198
+ const { width: canvasWidth, height: canvasHeight } = cachedCanvasImageElement;
199
+
200
+ if (right > canvasWidth && cropX > 0) {
201
+ width = originalWidth - Math.abs(right - canvasWidth);
202
+ }
203
+ if (bottom > canvasHeight && cropY > 0) {
204
+ height = originalHeight - Math.abs(bottom - canvasHeight);
205
+ }
206
+
207
+ const diff = {
208
+ x: (insideCanvasRealImageWidth - width) / 2,
209
+ y: (insideCanvasRealImageHeight - height) / 2,
210
+ };
211
+
212
+ forEach(['x', 'y'], (type) => {
213
+ const cropDistance2 = diff[type];
214
+ if (cropDistance2 > 0) {
215
+ [left, top] = overflowAreaPositionFixer(type, cropDistance2, left, top);
216
+ }
217
+ });
218
+
219
+ return [left, top, width, height];
220
+ }
221
+
222
+ /**
223
+ * Calculate fill image position and size for for left top
224
+ * @param {Function} overflowAreaPositionFixer - position fixer
225
+ * @param {Object} options - options for position dimension calculate
226
+ * @param {fabric.Object} shapeObj - shape object
227
+ * @param {number} left - original left position
228
+ * @param {number} top - original top position
229
+ * @param {number} width - image width
230
+ * @param {number} height - image height
231
+ * @param {number} cropX - image cropX
232
+ * @param {number} cropY - image cropY
233
+ * @returns {Object}
234
+ */
235
+ function calculateDimensionLeftTopEdge(
236
+ overflowAreaPositionFixer,
237
+ { left, top, width, height, cropX, cropY }
238
+ ) {
239
+ const dimension = {
240
+ width,
241
+ height,
242
+ };
243
+
244
+ forEach(['x', 'y'], (type) => {
245
+ const cropDistance = type === 'x' ? cropX : cropY;
246
+ const compareSize = dimension[POSITION_DIMENSION_MAP[type]];
247
+ const standardSize = cachedCanvasImageElement[POSITION_DIMENSION_MAP[type]];
248
+
249
+ if (compareSize > standardSize) {
250
+ const outDistance = (compareSize - standardSize) / 2;
251
+
252
+ dimension[POSITION_DIMENSION_MAP[type]] = standardSize;
253
+ [left, top] = overflowAreaPositionFixer(type, outDistance, left, top);
254
+ }
255
+ if (cropDistance < 0) {
256
+ [left, top] = overflowAreaPositionFixer(type, cropDistance, left, top);
257
+ }
258
+ });
259
+
260
+ return [left, top, dimension.width, dimension.height];
261
+ }
262
+
263
+ /**
264
+ * Make fill property of dynamic pattern type
265
+ * @param {fabric.Image} canvasImage - canvas background image
266
+ * @param {Array} filterOption - filter option
267
+ * @param {fabric.StaticCanvas} patternSourceCanvas - fabric static canvas
268
+ * @returns {Object}
269
+ */
270
+ export function makeFillPatternForFilter(canvasImage, filterOption, patternSourceCanvas) {
271
+ const copiedCanvasElement = getCachedCanvasImageElement(canvasImage);
272
+ const fillImage = makeFillImage(copiedCanvasElement, canvasImage.angle, filterOption);
273
+ patternSourceCanvas.add(fillImage);
274
+
275
+ const fabricProperty = {
276
+ fill: new fabric.Pattern({
277
+ source: patternSourceCanvas.getElement(),
278
+ repeat: 'no-repeat',
279
+ }),
280
+ };
281
+
282
+ setCustomProperty(fabricProperty, { patternSourceCanvas });
283
+
284
+ return fabricProperty;
285
+ }
286
+
287
+ /**
288
+ * Reset fill pattern canvas
289
+ * @param {fabric.StaticCanvas} patternSourceCanvas - fabric static canvas
290
+ */
291
+ export function resetFillPatternCanvas(patternSourceCanvas) {
292
+ const [innerImage] = patternSourceCanvas.getObjects();
293
+ let { fillImageMaxSize } = getCustomProperty(innerImage, 'fillImageMaxSize');
294
+ fillImageMaxSize = Math.max(1, fillImageMaxSize);
295
+
296
+ patternSourceCanvas.setDimensions({
297
+ width: fillImageMaxSize,
298
+ height: fillImageMaxSize,
299
+ });
300
+ patternSourceCanvas.renderAll();
301
+ }
302
+
303
+ /**
304
+ * Remake filter pattern image source
305
+ * @param {fabric.Object} shapeObj - Shape object
306
+ * @param {fabric.Image} canvasImage - canvas background image
307
+ */
308
+ export function reMakePatternImageSource(shapeObj, canvasImage) {
309
+ const { patternSourceCanvas } = getCustomProperty(shapeObj, 'patternSourceCanvas');
310
+ const [fillImage] = patternSourceCanvas.getObjects();
311
+ const filterOption = makeFilterOptionFromFabricImage(fillImage);
312
+
313
+ patternSourceCanvas.remove(fillImage);
314
+
315
+ const copiedCanvasElement = getCachedCanvasImageElement(canvasImage, true);
316
+ const newFillImage = makeFillImage(copiedCanvasElement, canvasImage.angle, filterOption);
317
+
318
+ patternSourceCanvas.add(newFillImage);
319
+ }
320
+
321
+ /**
322
+ * Calculate a point line outside the canvas.
323
+ * @param {fabric.Image} canvasImage - canvas background image
324
+ * @param {boolean} reset - default is false
325
+ * @returns {HTMLImageElement}
326
+ */
327
+ export function getCachedCanvasImageElement(canvasImage, reset = false) {
328
+ if (!cachedCanvasImageElement || reset) {
329
+ cachedCanvasImageElement = canvasImage.toCanvasElement();
330
+ }
331
+
332
+ return cachedCanvasImageElement;
333
+ }
334
+
335
+ /**
336
+ * Calculate fill image position for out of Canvas
337
+ * @param {string} type - 'x' or 'y'
338
+ * @param {fabric.Object} shapeObj - shape object
339
+ * @param {number} outDistance - distance away
340
+ * @param {number} left - original left position
341
+ * @param {number} top - original top position
342
+ * @returns {Array}
343
+ */
344
+ function calculateDistanceOverflowPart({ type, shapeObj, outDistance, left, top, flipX, flipY }) {
345
+ const shapePointNavigation = getShapeEdgePoint(shapeObj);
346
+ const shapeNeighborPointNavigation = [
347
+ [1, 2],
348
+ [0, 3],
349
+ [0, 3],
350
+ [1, 2],
351
+ ];
352
+ const linePointsOutsideCanvas = calculateLinePointsOutsideCanvas(
353
+ type,
354
+ shapePointNavigation,
355
+ shapeNeighborPointNavigation
356
+ );
357
+ const reatAngles = calculateLineAngleOfOutsideCanvas(
358
+ type,
359
+ shapePointNavigation,
360
+ linePointsOutsideCanvas
361
+ );
362
+ const { startPointIndex } = linePointsOutsideCanvas;
363
+ const diffPosition = getReversePositionForFlip({
364
+ outDistance,
365
+ startPointIndex,
366
+ flipX,
367
+ flipY,
368
+ reatAngles,
369
+ });
370
+
371
+ return [left + diffPosition.left, top + diffPosition.top];
372
+ }
373
+
374
+ /**
375
+ * Calculate fill image position for out of Canvas
376
+ * @param {number} outDistance - distance away
377
+ * @param {boolean} flipX - flip x statux
378
+ * @param {boolean} flipY - flip y statux
379
+ * @param {Array} reatAngles - Line angle of the rectangle vertex.
380
+ * @returns {Object} diffPosition
381
+ */
382
+ function getReversePositionForFlip({ outDistance, startPointIndex, flipX, flipY, reatAngles }) {
383
+ const rotationChangePoint1 = outDistance * Math.cos((reatAngles[0] * Math.PI) / 180);
384
+ const rotationChangePoint2 = outDistance * Math.cos((reatAngles[1] * Math.PI) / 180);
385
+ const isForward = startPointIndex === 2 || startPointIndex === 3;
386
+ const diffPosition = {
387
+ top: isForward ? rotationChangePoint1 : rotationChangePoint2,
388
+ left: isForward ? rotationChangePoint2 : rotationChangePoint1,
389
+ };
390
+
391
+ if (isReverseLeftPositionForFlip(startPointIndex, flipX, flipY)) {
392
+ diffPosition.left = diffPosition.left * -1;
393
+ }
394
+ if (isReverseTopPositionForFlip(startPointIndex, flipX, flipY)) {
395
+ diffPosition.top = diffPosition.top * -1;
396
+ }
397
+
398
+ return diffPosition;
399
+ }
400
+
401
+ /**
402
+ * Calculate a point line outside the canvas.
403
+ * @param {string} type - 'x' or 'y'
404
+ * @param {Array} shapePointNavigation - shape edge positions
405
+ * @param {Object} shapePointNavigation.lefttop - left top position
406
+ * @param {Object} shapePointNavigation.righttop - right top position
407
+ * @param {Object} shapePointNavigation.leftbottom - lefttop position
408
+ * @param {Object} shapePointNavigation.rightbottom - rightbottom position
409
+ * @param {Array} shapeNeighborPointNavigation - Array to find adjacent edges.
410
+ * @returns {Object}
411
+ */
412
+ function calculateLinePointsOutsideCanvas(
413
+ type,
414
+ shapePointNavigation,
415
+ shapeNeighborPointNavigation
416
+ ) {
417
+ let minimumPoint = 0;
418
+ let minimumPointIndex = 0;
419
+ forEach(shapePointNavigation, (point, index) => {
420
+ if (point[type] < minimumPoint) {
421
+ minimumPoint = point[type];
422
+ minimumPointIndex = index;
423
+ }
424
+ });
425
+
426
+ const [endPointIndex1, endPointIndex2] = shapeNeighborPointNavigation[minimumPointIndex];
427
+
428
+ return {
429
+ startPointIndex: minimumPointIndex,
430
+ endPointIndex1,
431
+ endPointIndex2,
432
+ };
433
+ }
434
+
435
+ /**
436
+ * Calculate a point line outside the canvas.
437
+ * @param {string} type - 'x' or 'y'
438
+ * @param {Array} shapePointNavigation - shape edge positions
439
+ * @param {object} shapePointNavigation.lefttop - left top position
440
+ * @param {object} shapePointNavigation.righttop - right top position
441
+ * @param {object} shapePointNavigation.leftbottom - lefttop position
442
+ * @param {object} shapePointNavigation.rightbottom - rightbottom position
443
+ * @param {Object} linePointsOfOneVertexIndex - Line point of one vertex
444
+ * @param {Object} linePointsOfOneVertexIndex.startPoint - start point index
445
+ * @param {Object} linePointsOfOneVertexIndex.endPointIndex1 - end point index
446
+ * @param {Object} linePointsOfOneVertexIndex.endPointIndex2 - end point index
447
+ * @returns {Object}
448
+ */
449
+ function calculateLineAngleOfOutsideCanvas(type, shapePointNavigation, linePointsOfOneVertexIndex) {
450
+ const { startPointIndex, endPointIndex1, endPointIndex2 } = linePointsOfOneVertexIndex;
451
+ const horizontalVerticalAngle = type === 'x' ? 180 : 270;
452
+
453
+ return [endPointIndex1, endPointIndex2].map((pointIndex) => {
454
+ const startPoint = shapePointNavigation[startPointIndex];
455
+ const endPoint = shapePointNavigation[pointIndex];
456
+ const diffY = startPoint.y - endPoint.y;
457
+ const diffX = startPoint.x - endPoint.x;
458
+
459
+ return (Math.atan2(diffY, diffX) * 180) / Math.PI - horizontalVerticalAngle;
460
+ });
461
+ }
462
+
463
+ /* eslint-disable complexity */
464
+ /**
465
+ * Calculate a point line outside the canvas for horizontal.
466
+ * @param {number} startPointIndex - start point index
467
+ * @param {boolean} flipX - flip x statux
468
+ * @param {boolean} flipY - flip y statux
469
+ * @returns {boolean} flipY - flip y statux
470
+ */
471
+ function isReverseLeftPositionForFlip(startPointIndex, flipX, flipY) {
472
+ return (
473
+ (((!flipX && flipY) || (!flipX && !flipY)) && startPointIndex === 0) ||
474
+ (((flipX && flipY) || (flipX && !flipY)) && startPointIndex === 1) ||
475
+ (((!flipX && !flipY) || (!flipX && flipY)) && startPointIndex === 2) ||
476
+ (((flipX && !flipY) || (flipX && flipY)) && startPointIndex === 3)
477
+ );
478
+ }
479
+ /* eslint-enable complexity */
480
+
481
+ /* eslint-disable complexity */
482
+ /**
483
+ * Calculate a point line outside the canvas for vertical.
484
+ * @param {number} startPointIndex - start point index
485
+ * @param {boolean} flipX - flip x statux
486
+ * @param {boolean} flipY - flip y statux
487
+ * @returns {boolean} flipY - flip y statux
488
+ */
489
+ function isReverseTopPositionForFlip(startPointIndex, flipX, flipY) {
490
+ return (
491
+ (((flipX && !flipY) || (!flipX && !flipY)) && startPointIndex === 0) ||
492
+ (((!flipX && !flipY) || (flipX && !flipY)) && startPointIndex === 1) ||
493
+ (((flipX && flipY) || (!flipX && flipY)) && startPointIndex === 2) ||
494
+ (((!flipX && flipY) || (flipX && flipY)) && startPointIndex === 3)
495
+ );
496
+ }
497
+ /* eslint-enable complexity */
498
+
499
+ /**
500
+ * Shape edge points
501
+ * @param {fabric.Object} shapeObj - Selected shape object on canvas
502
+ * @returns {Array} shapeEdgePoint - shape edge positions
503
+ */
504
+ function getShapeEdgePoint(shapeObj) {
505
+ return [
506
+ shapeObj.getPointByOrigin('left', 'top'),
507
+ shapeObj.getPointByOrigin('right', 'top'),
508
+ shapeObj.getPointByOrigin('left', 'bottom'),
509
+ shapeObj.getPointByOrigin('right', 'bottom'),
510
+ ];
511
+ }
512
+
513
+ /**
514
+ * Rotated shape dimension
515
+ * @param {fabric.Object} shapeObj - Shape object
516
+ * @returns {Object} Rotated shape dimension
517
+ */
518
+ function getRotatedDimension(shapeObj) {
519
+ const [{ x: ax, y: ay }, { x: bx, y: by }, { x: cx, y: cy }, { x: dx, y: dy }] =
520
+ getShapeEdgePoint(shapeObj);
521
+
522
+ const left = Math.min(ax, bx, cx, dx);
523
+ const top = Math.min(ay, by, cy, dy);
524
+ const right = Math.max(ax, bx, cx, dx);
525
+ const bottom = Math.max(ay, by, cy, dy);
526
+
527
+ return {
528
+ left,
529
+ top,
530
+ right,
531
+ bottom,
532
+ width: right - left,
533
+ height: bottom - top,
534
+ };
535
+ }
536
+
537
+ /**
538
+ * Make fill image
539
+ * @param {HTMLImageElement} copiedCanvasElement - html image element
540
+ * @param {number} currentCanvasImageAngle - current canvas angle
541
+ * @param {Array} filterOption - filter option
542
+ * @returns {fabric.Image}
543
+ * @private
544
+ */
545
+ function makeFillImage(copiedCanvasElement, currentCanvasImageAngle, filterOption) {
546
+ const fillImage = new fabric.Image(copiedCanvasElement);
547
+
548
+ forEach(extend({}, ...filterOption), (value, key) => {
549
+ const fabricFilterClassName = capitalizeString(key);
550
+ const filter = new fabric.Image.filters[fabricFilterClassName]({
551
+ [FILTER_OPTION_MAP[key]]: value,
552
+ });
553
+ fillImage.filters.push(filter);
554
+ });
555
+ fillImage.applyFilters();
556
+
557
+ setCustomProperty(fillImage, {
558
+ originalAngle: currentCanvasImageAngle,
559
+ fillImageMaxSize: Math.max(fillImage.width, fillImage.height),
560
+ });
561
+ resizeHelper.adjustOriginToCenter(fillImage);
562
+
563
+ return fillImage;
564
+ }