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.
- package/README.md +193 -0
- package/dist/svg/icon-a.svg +376 -0
- package/dist/svg/icon-b.svg +369 -0
- package/dist/svg/icon-c.svg +369 -0
- package/dist/svg/icon-d.svg +369 -0
- package/dist/tui-image-editor.css +6 -0
- package/dist/tui-image-editor.js +62329 -0
- package/dist/tui-image-editor.min.css +5 -0
- package/dist/tui-image-editor.min.js +15 -0
- package/index.d.ts +334 -0
- package/package.json +52 -0
- package/src/css/buttons.styl +102 -0
- package/src/css/checkbox.styl +86 -0
- package/src/css/colorpicker.styl +98 -0
- package/src/css/gridtable.styl +45 -0
- package/src/css/icon.styl +44 -0
- package/src/css/index.styl +17 -0
- package/src/css/main.styl +163 -0
- package/src/css/position.styl +309 -0
- package/src/css/range.styl +91 -0
- package/src/css/submenu.styl +168 -0
- package/src/index.js +29 -0
- package/src/js/action.js +686 -0
- package/src/js/command/addIcon.js +42 -0
- package/src/js/command/addImageObject.js +34 -0
- package/src/js/command/addObject.js +43 -0
- package/src/js/command/addShape.js +51 -0
- package/src/js/command/addText.js +73 -0
- package/src/js/command/applyFilter.js +95 -0
- package/src/js/command/changeIconColor.js +48 -0
- package/src/js/command/changeSelection.js +31 -0
- package/src/js/command/changeShape.js +84 -0
- package/src/js/command/changeText.js +44 -0
- package/src/js/command/changeTextStyle.js +80 -0
- package/src/js/command/clearObjects.js +33 -0
- package/src/js/command/flip.js +36 -0
- package/src/js/command/loadImage.js +58 -0
- package/src/js/command/removeFilter.js +38 -0
- package/src/js/command/removeObject.js +37 -0
- package/src/js/command/resize.js +41 -0
- package/src/js/command/resizeCanvasDimension.js +40 -0
- package/src/js/command/rotate.js +64 -0
- package/src/js/command/setObjectPosition.js +50 -0
- package/src/js/command/setObjectProperties.js +55 -0
- package/src/js/component/cropper.js +407 -0
- package/src/js/component/filter.js +229 -0
- package/src/js/component/flip.js +146 -0
- package/src/js/component/freeDrawing.js +144 -0
- package/src/js/component/icon.js +246 -0
- package/src/js/component/imageLoader.js +84 -0
- package/src/js/component/line.js +205 -0
- package/src/js/component/resize.js +103 -0
- package/src/js/component/rotation.js +91 -0
- package/src/js/component/shape.js +601 -0
- package/src/js/component/text.js +572 -0
- package/src/js/component/zoom.js +708 -0
- package/src/js/consts.js +404 -0
- package/src/js/drawingMode/cropper.js +35 -0
- package/src/js/drawingMode/freeDrawing.js +36 -0
- package/src/js/drawingMode/icon.js +35 -0
- package/src/js/drawingMode/lineDrawing.js +36 -0
- package/src/js/drawingMode/resize.js +35 -0
- package/src/js/drawingMode/shape.js +35 -0
- package/src/js/drawingMode/text.js +35 -0
- package/src/js/drawingMode/zoom.js +37 -0
- package/src/js/extension/arrowLine.js +172 -0
- package/src/js/extension/blur.js +29 -0
- package/src/js/extension/colorFilter.js +104 -0
- package/src/js/extension/cropzone.js +568 -0
- package/src/js/extension/emboss.js +29 -0
- package/src/js/extension/mask.js +90 -0
- package/src/js/extension/sharpen.js +29 -0
- package/src/js/factory/command.js +36 -0
- package/src/js/factory/errorMessage.js +27 -0
- package/src/js/graphics.js +1539 -0
- package/src/js/helper/imagetracer.js +1396 -0
- package/src/js/helper/selectionModifyHelper.js +86 -0
- package/src/js/helper/shapeFilterFillHelper.js +564 -0
- package/src/js/helper/shapeResizeHelper.js +237 -0
- package/src/js/imageEditor.js +1795 -0
- package/src/js/interface/command.js +131 -0
- package/src/js/interface/component.js +127 -0
- package/src/js/interface/drawingMode.js +47 -0
- package/src/js/invoker.js +292 -0
- package/src/js/polyfill.js +498 -0
- package/src/js/ui/crop.js +139 -0
- package/src/js/ui/draw.js +187 -0
- package/src/js/ui/filter.js +510 -0
- package/src/js/ui/flip.js +87 -0
- package/src/js/ui/history.js +171 -0
- package/src/js/ui/icon.js +191 -0
- package/src/js/ui/locale/locale.js +19 -0
- package/src/js/ui/mask.js +96 -0
- package/src/js/ui/panelMenu.js +130 -0
- package/src/js/ui/resize.js +241 -0
- package/src/js/ui/rotate.js +123 -0
- package/src/js/ui/shape.js +265 -0
- package/src/js/ui/submenuBase.js +122 -0
- package/src/js/ui/template/controls.js +21 -0
- package/src/js/ui/template/mainContainer.js +38 -0
- package/src/js/ui/template/style.js +146 -0
- package/src/js/ui/template/submenu/crop.js +73 -0
- package/src/js/ui/template/submenu/draw.js +42 -0
- package/src/js/ui/template/submenu/filter.js +157 -0
- package/src/js/ui/template/submenu/flip.js +41 -0
- package/src/js/ui/template/submenu/history.js +22 -0
- package/src/js/ui/template/submenu/icon.js +108 -0
- package/src/js/ui/template/submenu/mask.js +30 -0
- package/src/js/ui/template/submenu/resize.js +54 -0
- package/src/js/ui/template/submenu/rotate.js +32 -0
- package/src/js/ui/template/submenu/shape.js +45 -0
- package/src/js/ui/template/submenu/text.js +67 -0
- package/src/js/ui/template/submenu/zoom.js +41 -0
- package/src/js/ui/text.js +279 -0
- package/src/js/ui/theme/standard.js +220 -0
- package/src/js/ui/theme/theme.js +249 -0
- package/src/js/ui/tools/colorpicker.js +250 -0
- package/src/js/ui/tools/range.js +390 -0
- package/src/js/ui.js +858 -0
- package/src/js/util.js +551 -0
- package/src/svg/default.svg +335 -0
- package/src/svg/icon-a/ic-apply.svg +6 -0
- package/src/svg/icon-a/ic-cancel.svg +6 -0
- package/src/svg/icon-a/ic-color-transparent-w.svg +12 -0
- package/src/svg/icon-a/ic-crop.svg +7 -0
- package/src/svg/icon-a/ic-delete-all.svg +6 -0
- package/src/svg/icon-a/ic-delete.svg +6 -0
- package/src/svg/icon-a/ic-draw-free.svg +5 -0
- package/src/svg/icon-a/ic-draw-line.svg +5 -0
- package/src/svg/icon-a/ic-draw.svg +6 -0
- package/src/svg/icon-a/ic-filter.svg +7 -0
- package/src/svg/icon-a/ic-flip-reset.svg +7 -0
- package/src/svg/icon-a/ic-flip-x.svg +6 -0
- package/src/svg/icon-a/ic-flip-y.svg +6 -0
- package/src/svg/icon-a/ic-flip.svg +6 -0
- package/src/svg/icon-a/ic-history-check.svg +5 -0
- package/src/svg/icon-a/ic-history-crop.svg +7 -0
- package/src/svg/icon-a/ic-history-delete.svg +9 -0
- package/src/svg/icon-a/ic-history-draw.svg +7 -0
- package/src/svg/icon-a/ic-history-filter.svg +8 -0
- package/src/svg/icon-a/ic-history-flip.svg +6 -0
- package/src/svg/icon-a/ic-history-group.svg +9 -0
- package/src/svg/icon-a/ic-history-icon.svg +6 -0
- package/src/svg/icon-a/ic-history-load.svg +7 -0
- package/src/svg/icon-a/ic-history-mask.svg +9 -0
- package/src/svg/icon-a/ic-history-resize.svg +12 -0
- package/src/svg/icon-a/ic-history-rotate.svg +16 -0
- package/src/svg/icon-a/ic-history-shape.svg +7 -0
- package/src/svg/icon-a/ic-history-text.svg +8 -0
- package/src/svg/icon-a/ic-history.svg +6 -0
- package/src/svg/icon-a/ic-icon-arrow-2.svg +5 -0
- package/src/svg/icon-a/ic-icon-arrow-3.svg +5 -0
- package/src/svg/icon-a/ic-icon-arrow.svg +5 -0
- package/src/svg/icon-a/ic-icon-bubble.svg +5 -0
- package/src/svg/icon-a/ic-icon-heart.svg +5 -0
- package/src/svg/icon-a/ic-icon-load.svg +8 -0
- package/src/svg/icon-a/ic-icon-location.svg +8 -0
- package/src/svg/icon-a/ic-icon-polygon.svg +5 -0
- package/src/svg/icon-a/ic-icon-star-2.svg +5 -0
- package/src/svg/icon-a/ic-icon-star.svg +5 -0
- package/src/svg/icon-a/ic-icon.svg +5 -0
- package/src/svg/icon-a/ic-mask-load.svg +8 -0
- package/src/svg/icon-a/ic-mask.svg +6 -0
- package/src/svg/icon-a/ic-redo.svg +7 -0
- package/src/svg/icon-a/ic-reset.svg +7 -0
- package/src/svg/icon-a/ic-resize.svg +13 -0
- package/src/svg/icon-a/ic-rotate-clockwise.svg +7 -0
- package/src/svg/icon-a/ic-rotate-counterclockwise.svg +7 -0
- package/src/svg/icon-a/ic-rotate.svg +7 -0
- package/src/svg/icon-a/ic-shape-circle.svg +5 -0
- package/src/svg/icon-a/ic-shape-rectangle.svg +5 -0
- package/src/svg/icon-a/ic-shape-triangle.svg +5 -0
- package/src/svg/icon-a/ic-shape.svg +6 -0
- package/src/svg/icon-a/ic-text-align-center.svg +6 -0
- package/src/svg/icon-a/ic-text-align-left.svg +6 -0
- package/src/svg/icon-a/ic-text-align-right.svg +6 -0
- package/src/svg/icon-a/ic-text-bold.svg +7 -0
- package/src/svg/icon-a/ic-text-italic.svg +6 -0
- package/src/svg/icon-a/ic-text-underline.svg +7 -0
- package/src/svg/icon-a/ic-text.svg +7 -0
- package/src/svg/icon-a/ic-undo.svg +7 -0
- package/src/svg/icon-a/ic-zoom-hand.svg +8 -0
- package/src/svg/icon-a/ic-zoom-zoom-in.svg +10 -0
- package/src/svg/icon-a/ic-zoom-zoom-out.svg +9 -0
- package/src/svg/icon-a/img-bi.svg +5 -0
- package/src/svg/icon-b/ic-apply.svg +6 -0
- package/src/svg/icon-b/ic-cancel.svg +6 -0
- package/src/svg/icon-b/ic-crop.svg +7 -0
- package/src/svg/icon-b/ic-delete-all.svg +6 -0
- package/src/svg/icon-b/ic-delete.svg +6 -0
- package/src/svg/icon-b/ic-draw-free.svg +5 -0
- package/src/svg/icon-b/ic-draw-line.svg +5 -0
- package/src/svg/icon-b/ic-draw.svg +6 -0
- package/src/svg/icon-b/ic-filter.svg +7 -0
- package/src/svg/icon-b/ic-flip-reset.svg +7 -0
- package/src/svg/icon-b/ic-flip-x.svg +6 -0
- package/src/svg/icon-b/ic-flip-y.svg +6 -0
- package/src/svg/icon-b/ic-flip.svg +6 -0
- package/src/svg/icon-b/ic-history-check.svg +5 -0
- package/src/svg/icon-b/ic-history-crop.svg +7 -0
- package/src/svg/icon-b/ic-history-delete.svg +9 -0
- package/src/svg/icon-b/ic-history-draw.svg +7 -0
- package/src/svg/icon-b/ic-history-filter.svg +8 -0
- package/src/svg/icon-b/ic-history-flip.svg +6 -0
- package/src/svg/icon-b/ic-history-group.svg +9 -0
- package/src/svg/icon-b/ic-history-icon.svg +6 -0
- package/src/svg/icon-b/ic-history-load.svg +7 -0
- package/src/svg/icon-b/ic-history-mask.svg +9 -0
- package/src/svg/icon-b/ic-history-resize.svg +12 -0
- package/src/svg/icon-b/ic-history-rotate.svg +16 -0
- package/src/svg/icon-b/ic-history-shape.svg +7 -0
- package/src/svg/icon-b/ic-history-text.svg +8 -0
- package/src/svg/icon-b/ic-history.svg +6 -0
- package/src/svg/icon-b/ic-icon-arrow-2.svg +5 -0
- package/src/svg/icon-b/ic-icon-arrow-3.svg +5 -0
- package/src/svg/icon-b/ic-icon-arrow.svg +5 -0
- package/src/svg/icon-b/ic-icon-bubble.svg +5 -0
- package/src/svg/icon-b/ic-icon-heart.svg +5 -0
- package/src/svg/icon-b/ic-icon-load.svg +8 -0
- package/src/svg/icon-b/ic-icon-location.svg +8 -0
- package/src/svg/icon-b/ic-icon-polygon.svg +5 -0
- package/src/svg/icon-b/ic-icon-star-2.svg +5 -0
- package/src/svg/icon-b/ic-icon-star.svg +5 -0
- package/src/svg/icon-b/ic-icon.svg +5 -0
- package/src/svg/icon-b/ic-mask-load.svg +8 -0
- package/src/svg/icon-b/ic-mask.svg +6 -0
- package/src/svg/icon-b/ic-redo.svg +7 -0
- package/src/svg/icon-b/ic-reset.svg +7 -0
- package/src/svg/icon-b/ic-resize.svg +13 -0
- package/src/svg/icon-b/ic-rotate-clockwise.svg +7 -0
- package/src/svg/icon-b/ic-rotate-counterclockwise.svg +7 -0
- package/src/svg/icon-b/ic-rotate.svg +7 -0
- package/src/svg/icon-b/ic-shape-circle.svg +5 -0
- package/src/svg/icon-b/ic-shape-rectangle.svg +5 -0
- package/src/svg/icon-b/ic-shape-triangle.svg +5 -0
- package/src/svg/icon-b/ic-shape.svg +6 -0
- package/src/svg/icon-b/ic-text-align-center.svg +6 -0
- package/src/svg/icon-b/ic-text-align-left.svg +6 -0
- package/src/svg/icon-b/ic-text-align-right.svg +6 -0
- package/src/svg/icon-b/ic-text-bold.svg +7 -0
- package/src/svg/icon-b/ic-text-italic.svg +6 -0
- package/src/svg/icon-b/ic-text-underline.svg +7 -0
- package/src/svg/icon-b/ic-text.svg +7 -0
- package/src/svg/icon-b/ic-undo.svg +7 -0
- package/src/svg/icon-b/ic-zoom-hand.svg +8 -0
- package/src/svg/icon-b/ic-zoom-zoom-in.svg +12 -0
- package/src/svg/icon-b/ic-zoom-zoom-out.svg +11 -0
- package/src/svg/icon-b/img-bi.svg +5 -0
- package/src/svg/icon-c/ic-apply.svg +6 -0
- package/src/svg/icon-c/ic-cancel.svg +6 -0
- package/src/svg/icon-c/ic-crop.svg +7 -0
- package/src/svg/icon-c/ic-delete-all.svg +6 -0
- package/src/svg/icon-c/ic-delete.svg +6 -0
- package/src/svg/icon-c/ic-draw-free.svg +5 -0
- package/src/svg/icon-c/ic-draw-line.svg +5 -0
- package/src/svg/icon-c/ic-draw.svg +6 -0
- package/src/svg/icon-c/ic-filter.svg +7 -0
- package/src/svg/icon-c/ic-flip-reset.svg +7 -0
- package/src/svg/icon-c/ic-flip-x.svg +6 -0
- package/src/svg/icon-c/ic-flip-y.svg +6 -0
- package/src/svg/icon-c/ic-flip.svg +6 -0
- package/src/svg/icon-c/ic-history-check.svg +5 -0
- package/src/svg/icon-c/ic-history-crop.svg +7 -0
- package/src/svg/icon-c/ic-history-delete.svg +9 -0
- package/src/svg/icon-c/ic-history-draw.svg +7 -0
- package/src/svg/icon-c/ic-history-filter.svg +8 -0
- package/src/svg/icon-c/ic-history-flip.svg +6 -0
- package/src/svg/icon-c/ic-history-group.svg +9 -0
- package/src/svg/icon-c/ic-history-icon.svg +6 -0
- package/src/svg/icon-c/ic-history-load.svg +7 -0
- package/src/svg/icon-c/ic-history-mask.svg +9 -0
- package/src/svg/icon-c/ic-history-resize.svg +12 -0
- package/src/svg/icon-c/ic-history-rotate.svg +16 -0
- package/src/svg/icon-c/ic-history-shape.svg +7 -0
- package/src/svg/icon-c/ic-history-text.svg +8 -0
- package/src/svg/icon-c/ic-history.svg +6 -0
- package/src/svg/icon-c/ic-icon-arrow-2.svg +5 -0
- package/src/svg/icon-c/ic-icon-arrow-3.svg +5 -0
- package/src/svg/icon-c/ic-icon-arrow.svg +5 -0
- package/src/svg/icon-c/ic-icon-bubble.svg +5 -0
- package/src/svg/icon-c/ic-icon-heart.svg +5 -0
- package/src/svg/icon-c/ic-icon-load.svg +8 -0
- package/src/svg/icon-c/ic-icon-location.svg +8 -0
- package/src/svg/icon-c/ic-icon-polygon.svg +5 -0
- package/src/svg/icon-c/ic-icon-star-2.svg +5 -0
- package/src/svg/icon-c/ic-icon-star.svg +5 -0
- package/src/svg/icon-c/ic-icon.svg +5 -0
- package/src/svg/icon-c/ic-mask-load.svg +8 -0
- package/src/svg/icon-c/ic-mask.svg +6 -0
- package/src/svg/icon-c/ic-redo.svg +7 -0
- package/src/svg/icon-c/ic-reset.svg +7 -0
- package/src/svg/icon-c/ic-resize.svg +13 -0
- package/src/svg/icon-c/ic-rotate-clockwise.svg +7 -0
- package/src/svg/icon-c/ic-rotate-counterclockwise.svg +7 -0
- package/src/svg/icon-c/ic-rotate.svg +7 -0
- package/src/svg/icon-c/ic-shape-circle.svg +5 -0
- package/src/svg/icon-c/ic-shape-rectangle.svg +5 -0
- package/src/svg/icon-c/ic-shape-triangle.svg +5 -0
- package/src/svg/icon-c/ic-shape.svg +6 -0
- package/src/svg/icon-c/ic-text-align-center.svg +6 -0
- package/src/svg/icon-c/ic-text-align-left.svg +6 -0
- package/src/svg/icon-c/ic-text-align-right.svg +6 -0
- package/src/svg/icon-c/ic-text-bold.svg +7 -0
- package/src/svg/icon-c/ic-text-italic.svg +6 -0
- package/src/svg/icon-c/ic-text-underline.svg +7 -0
- package/src/svg/icon-c/ic-text.svg +7 -0
- package/src/svg/icon-c/ic-undo.svg +7 -0
- package/src/svg/icon-c/ic-zoom-hand.svg +8 -0
- package/src/svg/icon-c/ic-zoom-zoom-in.svg +12 -0
- package/src/svg/icon-c/ic-zoom-zoom-out.svg +11 -0
- package/src/svg/icon-c/img-bi.svg +5 -0
- package/src/svg/icon-d/ic-apply.svg +6 -0
- package/src/svg/icon-d/ic-cancel.svg +6 -0
- package/src/svg/icon-d/ic-crop.svg +7 -0
- package/src/svg/icon-d/ic-delete-all.svg +6 -0
- package/src/svg/icon-d/ic-delete.svg +6 -0
- package/src/svg/icon-d/ic-draw-free.svg +5 -0
- package/src/svg/icon-d/ic-draw-line.svg +5 -0
- package/src/svg/icon-d/ic-draw.svg +6 -0
- package/src/svg/icon-d/ic-filter.svg +7 -0
- package/src/svg/icon-d/ic-flip-reset.svg +7 -0
- package/src/svg/icon-d/ic-flip-x.svg +6 -0
- package/src/svg/icon-d/ic-flip-y.svg +6 -0
- package/src/svg/icon-d/ic-flip.svg +6 -0
- package/src/svg/icon-d/ic-history-check.svg +5 -0
- package/src/svg/icon-d/ic-history-crop.svg +7 -0
- package/src/svg/icon-d/ic-history-delete.svg +9 -0
- package/src/svg/icon-d/ic-history-draw.svg +7 -0
- package/src/svg/icon-d/ic-history-filter.svg +8 -0
- package/src/svg/icon-d/ic-history-flip.svg +6 -0
- package/src/svg/icon-d/ic-history-group.svg +9 -0
- package/src/svg/icon-d/ic-history-icon.svg +6 -0
- package/src/svg/icon-d/ic-history-load.svg +7 -0
- package/src/svg/icon-d/ic-history-mask.svg +9 -0
- package/src/svg/icon-d/ic-history-resize.svg +12 -0
- package/src/svg/icon-d/ic-history-rotate.svg +16 -0
- package/src/svg/icon-d/ic-history-shape.svg +7 -0
- package/src/svg/icon-d/ic-history-text.svg +8 -0
- package/src/svg/icon-d/ic-history.svg +6 -0
- package/src/svg/icon-d/ic-icon-arrow-2.svg +5 -0
- package/src/svg/icon-d/ic-icon-arrow-3.svg +5 -0
- package/src/svg/icon-d/ic-icon-arrow.svg +5 -0
- package/src/svg/icon-d/ic-icon-bubble.svg +5 -0
- package/src/svg/icon-d/ic-icon-heart.svg +5 -0
- package/src/svg/icon-d/ic-icon-load.svg +8 -0
- package/src/svg/icon-d/ic-icon-location.svg +8 -0
- package/src/svg/icon-d/ic-icon-polygon.svg +5 -0
- package/src/svg/icon-d/ic-icon-star-2.svg +5 -0
- package/src/svg/icon-d/ic-icon-star.svg +5 -0
- package/src/svg/icon-d/ic-icon.svg +5 -0
- package/src/svg/icon-d/ic-mask-load.svg +8 -0
- package/src/svg/icon-d/ic-mask.svg +6 -0
- package/src/svg/icon-d/ic-redo.svg +7 -0
- package/src/svg/icon-d/ic-reset.svg +7 -0
- package/src/svg/icon-d/ic-resize.svg +13 -0
- package/src/svg/icon-d/ic-rotate-clockwise.svg +7 -0
- package/src/svg/icon-d/ic-rotate-counterclockwise.svg +7 -0
- package/src/svg/icon-d/ic-rotate.svg +7 -0
- package/src/svg/icon-d/ic-shape-circle.svg +5 -0
- package/src/svg/icon-d/ic-shape-rectangle.svg +5 -0
- package/src/svg/icon-d/ic-shape-triangle.svg +5 -0
- package/src/svg/icon-d/ic-shape.svg +6 -0
- package/src/svg/icon-d/ic-text-align-center.svg +6 -0
- package/src/svg/icon-d/ic-text-align-left.svg +6 -0
- package/src/svg/icon-d/ic-text-align-right.svg +6 -0
- package/src/svg/icon-d/ic-text-bold.svg +7 -0
- package/src/svg/icon-d/ic-text-italic.svg +6 -0
- package/src/svg/icon-d/ic-text-underline.svg +7 -0
- package/src/svg/icon-d/ic-text.svg +7 -0
- package/src/svg/icon-d/ic-undo.svg +7 -0
- package/src/svg/icon-d/ic-zoom-hand.svg +8 -0
- package/src/svg/icon-d/ic-zoom-zoom-in.svg +12 -0
- package/src/svg/icon-d/ic-zoom-zoom-out.svg +11 -0
- package/src/svg/icon-d/img-bi.svg +5 -0
@@ -0,0 +1,601 @@
|
|
1
|
+
import { fabric } from 'fabric';
|
2
|
+
import extend from 'tui-code-snippet/object/extend';
|
3
|
+
import Component from '@/interface/component';
|
4
|
+
import resizeHelper from '@/helper/shapeResizeHelper';
|
5
|
+
import {
|
6
|
+
getFillImageFromShape,
|
7
|
+
rePositionFilterTypeFillImage,
|
8
|
+
reMakePatternImageSource,
|
9
|
+
makeFillPatternForFilter,
|
10
|
+
makeFilterOptionFromFabricImage,
|
11
|
+
resetFillPatternCanvas,
|
12
|
+
} from '@/helper/shapeFilterFillHelper';
|
13
|
+
import {
|
14
|
+
changeOrigin,
|
15
|
+
getCustomProperty,
|
16
|
+
getFillTypeFromOption,
|
17
|
+
getFillTypeFromObject,
|
18
|
+
isShape,
|
19
|
+
} from '@/util';
|
20
|
+
import {
|
21
|
+
rejectMessages,
|
22
|
+
eventNames,
|
23
|
+
keyCodes as KEY_CODES,
|
24
|
+
componentNames,
|
25
|
+
fObjectOptions,
|
26
|
+
SHAPE_DEFAULT_OPTIONS,
|
27
|
+
SHAPE_FILL_TYPE,
|
28
|
+
} from '@/consts';
|
29
|
+
|
30
|
+
const SHAPE_INIT_OPTIONS = extend(
|
31
|
+
{
|
32
|
+
strokeWidth: 1,
|
33
|
+
stroke: '#000000',
|
34
|
+
fill: '#ffffff',
|
35
|
+
width: 1,
|
36
|
+
height: 1,
|
37
|
+
rx: 0,
|
38
|
+
ry: 0,
|
39
|
+
},
|
40
|
+
SHAPE_DEFAULT_OPTIONS
|
41
|
+
);
|
42
|
+
const DEFAULT_TYPE = 'rect';
|
43
|
+
const DEFAULT_WIDTH = 20;
|
44
|
+
const DEFAULT_HEIGHT = 20;
|
45
|
+
|
46
|
+
/**
|
47
|
+
* Make fill option
|
48
|
+
* @param {Object} options - Options to create the shape
|
49
|
+
* @param {Object.Image} canvasImage - canvas background image
|
50
|
+
* @param {Function} createStaticCanvas - static canvas creater
|
51
|
+
* @returns {Object} - shape option
|
52
|
+
* @private
|
53
|
+
*/
|
54
|
+
function makeFabricFillOption(options, canvasImage, createStaticCanvas) {
|
55
|
+
const fillOption = options.fill;
|
56
|
+
const fillType = getFillTypeFromOption(options.fill);
|
57
|
+
let fill = fillOption;
|
58
|
+
|
59
|
+
if (fillOption.color) {
|
60
|
+
fill = fillOption.color;
|
61
|
+
}
|
62
|
+
|
63
|
+
let extOption = null;
|
64
|
+
if (fillType === 'filter') {
|
65
|
+
const newStaticCanvas = createStaticCanvas();
|
66
|
+
extOption = makeFillPatternForFilter(canvasImage, fillOption.filter, newStaticCanvas);
|
67
|
+
} else {
|
68
|
+
extOption = { fill };
|
69
|
+
}
|
70
|
+
|
71
|
+
return extend({}, options, extOption);
|
72
|
+
}
|
73
|
+
|
74
|
+
/**
|
75
|
+
* Shape
|
76
|
+
* @class Shape
|
77
|
+
* @param {Graphics} graphics - Graphics instance
|
78
|
+
* @extends {Component}
|
79
|
+
* @ignore
|
80
|
+
*/
|
81
|
+
export default class Shape extends Component {
|
82
|
+
constructor(graphics) {
|
83
|
+
super(componentNames.SHAPE, graphics);
|
84
|
+
|
85
|
+
/**
|
86
|
+
* Object of The drawing shape
|
87
|
+
* @type {fabric.Object}
|
88
|
+
* @private
|
89
|
+
*/
|
90
|
+
this._shapeObj = null;
|
91
|
+
|
92
|
+
/**
|
93
|
+
* Type of the drawing shape
|
94
|
+
* @type {string}
|
95
|
+
* @private
|
96
|
+
*/
|
97
|
+
this._type = DEFAULT_TYPE;
|
98
|
+
|
99
|
+
/**
|
100
|
+
* Options to draw the shape
|
101
|
+
* @type {Object}
|
102
|
+
* @private
|
103
|
+
*/
|
104
|
+
this._options = extend({}, SHAPE_INIT_OPTIONS);
|
105
|
+
|
106
|
+
/**
|
107
|
+
* Whether the shape object is selected or not
|
108
|
+
* @type {boolean}
|
109
|
+
* @private
|
110
|
+
*/
|
111
|
+
this._isSelected = false;
|
112
|
+
|
113
|
+
/**
|
114
|
+
* Pointer for drawing shape (x, y)
|
115
|
+
* @type {Object}
|
116
|
+
* @private
|
117
|
+
*/
|
118
|
+
this._startPoint = {};
|
119
|
+
|
120
|
+
/**
|
121
|
+
* Using shortcut on drawing shape
|
122
|
+
* @type {boolean}
|
123
|
+
* @private
|
124
|
+
*/
|
125
|
+
this._withShiftKey = false;
|
126
|
+
|
127
|
+
/**
|
128
|
+
* Event handler list
|
129
|
+
* @type {Object}
|
130
|
+
* @private
|
131
|
+
*/
|
132
|
+
this._handlers = {
|
133
|
+
mousedown: this._onFabricMouseDown.bind(this),
|
134
|
+
mousemove: this._onFabricMouseMove.bind(this),
|
135
|
+
mouseup: this._onFabricMouseUp.bind(this),
|
136
|
+
keydown: this._onKeyDown.bind(this),
|
137
|
+
keyup: this._onKeyUp.bind(this),
|
138
|
+
};
|
139
|
+
}
|
140
|
+
|
141
|
+
/**
|
142
|
+
* Start to draw the shape on canvas
|
143
|
+
* @ignore
|
144
|
+
*/
|
145
|
+
start() {
|
146
|
+
const canvas = this.getCanvas();
|
147
|
+
|
148
|
+
this._isSelected = false;
|
149
|
+
|
150
|
+
canvas.defaultCursor = 'crosshair';
|
151
|
+
canvas.selection = false;
|
152
|
+
canvas.uniformScaling = true;
|
153
|
+
canvas.on({
|
154
|
+
'mouse:down': this._handlers.mousedown,
|
155
|
+
});
|
156
|
+
|
157
|
+
fabric.util.addListener(document, 'keydown', this._handlers.keydown);
|
158
|
+
fabric.util.addListener(document, 'keyup', this._handlers.keyup);
|
159
|
+
}
|
160
|
+
|
161
|
+
/**
|
162
|
+
* End to draw the shape on canvas
|
163
|
+
* @ignore
|
164
|
+
*/
|
165
|
+
end() {
|
166
|
+
const canvas = this.getCanvas();
|
167
|
+
|
168
|
+
this._isSelected = false;
|
169
|
+
|
170
|
+
canvas.defaultCursor = 'default';
|
171
|
+
|
172
|
+
canvas.selection = true;
|
173
|
+
canvas.uniformScaling = false;
|
174
|
+
canvas.off({
|
175
|
+
'mouse:down': this._handlers.mousedown,
|
176
|
+
});
|
177
|
+
|
178
|
+
fabric.util.removeListener(document, 'keydown', this._handlers.keydown);
|
179
|
+
fabric.util.removeListener(document, 'keyup', this._handlers.keyup);
|
180
|
+
}
|
181
|
+
|
182
|
+
/**
|
183
|
+
* Set states of the current drawing shape
|
184
|
+
* @ignore
|
185
|
+
* @param {string} type - Shape type (ex: 'rect', 'circle')
|
186
|
+
* @param {Object} [options] - Shape options
|
187
|
+
* @param {(ShapeFillOption | string)} [options.fill] - {@link ShapeFillOption} or
|
188
|
+
* Shape foreground color (ex: '#fff', 'transparent')
|
189
|
+
* @param {string} [options.stoke] - Shape outline color
|
190
|
+
* @param {number} [options.strokeWidth] - Shape outline width
|
191
|
+
* @param {number} [options.width] - Width value (When type option is 'rect', this options can use)
|
192
|
+
* @param {number} [options.height] - Height value (When type option is 'rect', this options can use)
|
193
|
+
* @param {number} [options.rx] - Radius x value (When type option is 'circle', this options can use)
|
194
|
+
* @param {number} [options.ry] - Radius y value (When type option is 'circle', this options can use)
|
195
|
+
*/
|
196
|
+
setStates(type, options) {
|
197
|
+
this._type = type;
|
198
|
+
|
199
|
+
if (options) {
|
200
|
+
this._options = extend(this._options, options);
|
201
|
+
}
|
202
|
+
}
|
203
|
+
|
204
|
+
/**
|
205
|
+
* Add the shape
|
206
|
+
* @ignore
|
207
|
+
* @param {string} type - Shape type (ex: 'rect', 'circle')
|
208
|
+
* @param {Object} options - Shape options
|
209
|
+
* @param {(ShapeFillOption | string)} [options.fill] - ShapeFillOption or Shape foreground color (ex: '#fff', 'transparent') or ShapeFillOption object
|
210
|
+
* @param {string} [options.stroke] - Shape outline color
|
211
|
+
* @param {number} [options.strokeWidth] - Shape outline width
|
212
|
+
* @param {number} [options.width] - Width value (When type option is 'rect', this options can use)
|
213
|
+
* @param {number} [options.height] - Height value (When type option is 'rect', this options can use)
|
214
|
+
* @param {number} [options.rx] - Radius x value (When type option is 'circle', this options can use)
|
215
|
+
* @param {number} [options.ry] - Radius y value (When type option is 'circle', this options can use)
|
216
|
+
* @param {number} [options.isRegular] - Whether scaling shape has 1:1 ratio or not
|
217
|
+
* @returns {Promise}
|
218
|
+
*/
|
219
|
+
add(type, options) {
|
220
|
+
return new Promise((resolve) => {
|
221
|
+
const canvas = this.getCanvas();
|
222
|
+
const extendOption = this._extendOptions(options);
|
223
|
+
|
224
|
+
const shapeObj = this._createInstance(type, extendOption);
|
225
|
+
const objectProperties = this.graphics.createObjectProperties(shapeObj);
|
226
|
+
|
227
|
+
this._bindEventOnShape(shapeObj);
|
228
|
+
|
229
|
+
canvas.add(shapeObj).setActiveObject(shapeObj);
|
230
|
+
|
231
|
+
this._resetPositionFillFilter(shapeObj);
|
232
|
+
|
233
|
+
resolve(objectProperties);
|
234
|
+
});
|
235
|
+
}
|
236
|
+
|
237
|
+
/**
|
238
|
+
* Change the shape
|
239
|
+
* @ignore
|
240
|
+
* @param {fabric.Object} shapeObj - Selected shape object on canvas
|
241
|
+
* @param {Object} options - Shape options
|
242
|
+
* @param {(ShapeFillOption | string)} [options.fill] - {@link ShapeFillOption} or
|
243
|
+
* Shape foreground color (ex: '#fff', 'transparent')
|
244
|
+
* @param {string} [options.stroke] - Shape outline color
|
245
|
+
* @param {number} [options.strokeWidth] - Shape outline width
|
246
|
+
* @param {number} [options.width] - Width value (When type option is 'rect', this options can use)
|
247
|
+
* @param {number} [options.height] - Height value (When type option is 'rect', this options can use)
|
248
|
+
* @param {number} [options.rx] - Radius x value (When type option is 'circle', this options can use)
|
249
|
+
* @param {number} [options.ry] - Radius y value (When type option is 'circle', this options can use)
|
250
|
+
* @param {number} [options.isRegular] - Whether scaling shape has 1:1 ratio or not
|
251
|
+
* @returns {Promise}
|
252
|
+
*/
|
253
|
+
change(shapeObj, options) {
|
254
|
+
return new Promise((resolve, reject) => {
|
255
|
+
if (!isShape(shapeObj)) {
|
256
|
+
reject(rejectMessages.unsupportedType);
|
257
|
+
}
|
258
|
+
const hasFillOption = getFillTypeFromOption(options.fill) === 'filter';
|
259
|
+
const { canvasImage, createStaticCanvas } = this.graphics;
|
260
|
+
|
261
|
+
shapeObj.set(
|
262
|
+
hasFillOption ? makeFabricFillOption(options, canvasImage, createStaticCanvas) : options
|
263
|
+
);
|
264
|
+
|
265
|
+
if (hasFillOption) {
|
266
|
+
this._resetPositionFillFilter(shapeObj);
|
267
|
+
}
|
268
|
+
|
269
|
+
this.getCanvas().renderAll();
|
270
|
+
resolve();
|
271
|
+
});
|
272
|
+
}
|
273
|
+
|
274
|
+
/**
|
275
|
+
* make fill property for user event
|
276
|
+
* @param {fabric.Object} shapeObj - fabric object
|
277
|
+
* @returns {Object}
|
278
|
+
*/
|
279
|
+
makeFillPropertyForUserEvent(shapeObj) {
|
280
|
+
const fillType = getFillTypeFromObject(shapeObj);
|
281
|
+
const fillProp = {};
|
282
|
+
|
283
|
+
if (fillType === SHAPE_FILL_TYPE.FILTER) {
|
284
|
+
const fillImage = getFillImageFromShape(shapeObj);
|
285
|
+
const filterOption = makeFilterOptionFromFabricImage(fillImage);
|
286
|
+
|
287
|
+
fillProp.type = fillType;
|
288
|
+
fillProp.filter = filterOption;
|
289
|
+
} else {
|
290
|
+
fillProp.type = SHAPE_FILL_TYPE.COLOR;
|
291
|
+
fillProp.color = shapeObj.fill || 'transparent';
|
292
|
+
}
|
293
|
+
|
294
|
+
return fillProp;
|
295
|
+
}
|
296
|
+
|
297
|
+
/**
|
298
|
+
* Copy object handling.
|
299
|
+
* @param {fabric.Object} shapeObj - Shape object
|
300
|
+
* @param {fabric.Object} originalShapeObj - Shape object
|
301
|
+
*/
|
302
|
+
processForCopiedObject(shapeObj, originalShapeObj) {
|
303
|
+
this._bindEventOnShape(shapeObj);
|
304
|
+
|
305
|
+
if (getFillTypeFromObject(shapeObj) === 'filter') {
|
306
|
+
const fillImage = getFillImageFromShape(originalShapeObj);
|
307
|
+
const filterOption = makeFilterOptionFromFabricImage(fillImage);
|
308
|
+
const newStaticCanvas = this.graphics.createStaticCanvas();
|
309
|
+
|
310
|
+
shapeObj.set(
|
311
|
+
makeFillPatternForFilter(this.graphics.canvasImage, filterOption, newStaticCanvas)
|
312
|
+
);
|
313
|
+
this._resetPositionFillFilter(shapeObj);
|
314
|
+
}
|
315
|
+
}
|
316
|
+
|
317
|
+
/**
|
318
|
+
* Create the instance of shape
|
319
|
+
* @param {string} type - Shape type
|
320
|
+
* @param {Object} options - Options to creat the shape
|
321
|
+
* @returns {fabric.Object} Shape instance
|
322
|
+
* @private
|
323
|
+
*/
|
324
|
+
_createInstance(type, options) {
|
325
|
+
let instance;
|
326
|
+
|
327
|
+
switch (type) {
|
328
|
+
case 'rect':
|
329
|
+
instance = new fabric.Rect(options);
|
330
|
+
break;
|
331
|
+
case 'circle':
|
332
|
+
instance = new fabric.Ellipse(
|
333
|
+
extend(
|
334
|
+
{
|
335
|
+
type: 'circle',
|
336
|
+
},
|
337
|
+
options
|
338
|
+
)
|
339
|
+
);
|
340
|
+
break;
|
341
|
+
case 'triangle':
|
342
|
+
instance = new fabric.Triangle(options);
|
343
|
+
break;
|
344
|
+
default:
|
345
|
+
instance = {};
|
346
|
+
}
|
347
|
+
|
348
|
+
return instance;
|
349
|
+
}
|
350
|
+
|
351
|
+
/**
|
352
|
+
* Get the options to create the shape
|
353
|
+
* @param {Object} options - Options to creat the shape
|
354
|
+
* @returns {Object} Shape options
|
355
|
+
* @private
|
356
|
+
*/
|
357
|
+
_extendOptions(options) {
|
358
|
+
const selectionStyles = fObjectOptions.SELECTION_STYLE;
|
359
|
+
const { canvasImage, createStaticCanvas } = this.graphics;
|
360
|
+
|
361
|
+
options = extend({}, SHAPE_INIT_OPTIONS, this._options, selectionStyles, options);
|
362
|
+
|
363
|
+
return makeFabricFillOption(options, canvasImage, createStaticCanvas);
|
364
|
+
}
|
365
|
+
|
366
|
+
/**
|
367
|
+
* Bind fabric events on the creating shape object
|
368
|
+
* @param {fabric.Object} shapeObj - Shape object
|
369
|
+
* @private
|
370
|
+
*/
|
371
|
+
_bindEventOnShape(shapeObj) {
|
372
|
+
const self = this;
|
373
|
+
const canvas = this.getCanvas();
|
374
|
+
|
375
|
+
shapeObj.on({
|
376
|
+
added() {
|
377
|
+
self._shapeObj = this;
|
378
|
+
resizeHelper.setOrigins(self._shapeObj);
|
379
|
+
},
|
380
|
+
selected() {
|
381
|
+
self._isSelected = true;
|
382
|
+
self._shapeObj = this;
|
383
|
+
canvas.uniformScaling = true;
|
384
|
+
canvas.defaultCursor = 'default';
|
385
|
+
resizeHelper.setOrigins(self._shapeObj);
|
386
|
+
},
|
387
|
+
deselected() {
|
388
|
+
self._isSelected = false;
|
389
|
+
self._shapeObj = null;
|
390
|
+
canvas.defaultCursor = 'crosshair';
|
391
|
+
canvas.uniformScaling = false;
|
392
|
+
},
|
393
|
+
modified() {
|
394
|
+
const currentObj = self._shapeObj;
|
395
|
+
|
396
|
+
resizeHelper.adjustOriginToCenter(currentObj);
|
397
|
+
resizeHelper.setOrigins(currentObj);
|
398
|
+
},
|
399
|
+
modifiedInGroup(activeSelection) {
|
400
|
+
self._fillFilterRePositionInGroupSelection(shapeObj, activeSelection);
|
401
|
+
},
|
402
|
+
moving() {
|
403
|
+
self._resetPositionFillFilter(this);
|
404
|
+
},
|
405
|
+
rotating() {
|
406
|
+
self._resetPositionFillFilter(this);
|
407
|
+
},
|
408
|
+
scaling(fEvent) {
|
409
|
+
const pointer = canvas.getPointer(fEvent.e);
|
410
|
+
const currentObj = self._shapeObj;
|
411
|
+
|
412
|
+
canvas.setCursor('crosshair');
|
413
|
+
resizeHelper.resize(currentObj, pointer, true);
|
414
|
+
|
415
|
+
self._resetPositionFillFilter(this);
|
416
|
+
},
|
417
|
+
});
|
418
|
+
}
|
419
|
+
|
420
|
+
/**
|
421
|
+
* MouseDown event handler on canvas
|
422
|
+
* @param {{target: fabric.Object, e: MouseEvent}} fEvent - Fabric event object
|
423
|
+
* @private
|
424
|
+
*/
|
425
|
+
_onFabricMouseDown(fEvent) {
|
426
|
+
if (!fEvent.target) {
|
427
|
+
this._isSelected = false;
|
428
|
+
this._shapeObj = false;
|
429
|
+
}
|
430
|
+
|
431
|
+
if (!this._isSelected && !this._shapeObj) {
|
432
|
+
const canvas = this.getCanvas();
|
433
|
+
this._startPoint = canvas.getPointer(fEvent.e);
|
434
|
+
|
435
|
+
canvas.on({
|
436
|
+
'mouse:move': this._handlers.mousemove,
|
437
|
+
'mouse:up': this._handlers.mouseup,
|
438
|
+
});
|
439
|
+
}
|
440
|
+
}
|
441
|
+
|
442
|
+
/**
|
443
|
+
* MouseDown event handler on canvas
|
444
|
+
* @param {{target: fabric.Object, e: MouseEvent}} fEvent - Fabric event object
|
445
|
+
* @private
|
446
|
+
*/
|
447
|
+
_onFabricMouseMove(fEvent) {
|
448
|
+
const canvas = this.getCanvas();
|
449
|
+
const pointer = canvas.getPointer(fEvent.e);
|
450
|
+
const startPointX = this._startPoint.x;
|
451
|
+
const startPointY = this._startPoint.y;
|
452
|
+
const width = startPointX - pointer.x;
|
453
|
+
const height = startPointY - pointer.y;
|
454
|
+
const shape = this._shapeObj;
|
455
|
+
|
456
|
+
if (!shape) {
|
457
|
+
this.add(this._type, {
|
458
|
+
left: startPointX,
|
459
|
+
top: startPointY,
|
460
|
+
width,
|
461
|
+
height,
|
462
|
+
}).then((objectProps) => {
|
463
|
+
this.fire(eventNames.ADD_OBJECT, objectProps);
|
464
|
+
});
|
465
|
+
} else {
|
466
|
+
this._shapeObj.set({
|
467
|
+
isRegular: this._withShiftKey,
|
468
|
+
});
|
469
|
+
|
470
|
+
resizeHelper.resize(shape, pointer);
|
471
|
+
canvas.renderAll();
|
472
|
+
|
473
|
+
this._resetPositionFillFilter(shape);
|
474
|
+
}
|
475
|
+
}
|
476
|
+
|
477
|
+
/**
|
478
|
+
* MouseUp event handler on canvas
|
479
|
+
* @private
|
480
|
+
*/
|
481
|
+
_onFabricMouseUp() {
|
482
|
+
const canvas = this.getCanvas();
|
483
|
+
const startPointX = this._startPoint.x;
|
484
|
+
const startPointY = this._startPoint.y;
|
485
|
+
const shape = this._shapeObj;
|
486
|
+
|
487
|
+
if (!shape) {
|
488
|
+
this.add(this._type, {
|
489
|
+
left: startPointX,
|
490
|
+
top: startPointY,
|
491
|
+
width: DEFAULT_WIDTH,
|
492
|
+
height: DEFAULT_HEIGHT,
|
493
|
+
}).then((objectProps) => {
|
494
|
+
this.fire(eventNames.ADD_OBJECT, objectProps);
|
495
|
+
});
|
496
|
+
} else if (shape) {
|
497
|
+
resizeHelper.adjustOriginToCenter(shape);
|
498
|
+
this.fire(eventNames.OBJECT_ADDED, this.graphics.createObjectProperties(shape));
|
499
|
+
}
|
500
|
+
|
501
|
+
canvas.off({
|
502
|
+
'mouse:move': this._handlers.mousemove,
|
503
|
+
'mouse:up': this._handlers.mouseup,
|
504
|
+
});
|
505
|
+
}
|
506
|
+
|
507
|
+
/**
|
508
|
+
* Keydown event handler on document
|
509
|
+
* @param {KeyboardEvent} e - Event object
|
510
|
+
* @private
|
511
|
+
*/
|
512
|
+
_onKeyDown(e) {
|
513
|
+
if (e.keyCode === KEY_CODES.SHIFT) {
|
514
|
+
this._withShiftKey = true;
|
515
|
+
|
516
|
+
if (this._shapeObj) {
|
517
|
+
this._shapeObj.isRegular = true;
|
518
|
+
}
|
519
|
+
}
|
520
|
+
}
|
521
|
+
|
522
|
+
/**
|
523
|
+
* Keyup event handler on document
|
524
|
+
* @param {KeyboardEvent} e - Event object
|
525
|
+
* @private
|
526
|
+
*/
|
527
|
+
_onKeyUp(e) {
|
528
|
+
if (e.keyCode === KEY_CODES.SHIFT) {
|
529
|
+
this._withShiftKey = false;
|
530
|
+
|
531
|
+
if (this._shapeObj) {
|
532
|
+
this._shapeObj.isRegular = false;
|
533
|
+
}
|
534
|
+
}
|
535
|
+
}
|
536
|
+
|
537
|
+
/**
|
538
|
+
* Reset shape position and internal proportions in the filter type fill area.
|
539
|
+
* @param {fabric.Object} shapeObj - Shape object
|
540
|
+
* @private
|
541
|
+
*/
|
542
|
+
_resetPositionFillFilter(shapeObj) {
|
543
|
+
if (getFillTypeFromObject(shapeObj) !== 'filter') {
|
544
|
+
return;
|
545
|
+
}
|
546
|
+
|
547
|
+
const { patternSourceCanvas } = getCustomProperty(shapeObj, 'patternSourceCanvas');
|
548
|
+
|
549
|
+
const fillImage = getFillImageFromShape(shapeObj);
|
550
|
+
const { originalAngle } = getCustomProperty(fillImage, 'originalAngle');
|
551
|
+
|
552
|
+
if (this.graphics.canvasImage.angle !== originalAngle) {
|
553
|
+
reMakePatternImageSource(shapeObj, this.graphics.canvasImage);
|
554
|
+
}
|
555
|
+
const { originX, originY } = shapeObj;
|
556
|
+
|
557
|
+
resizeHelper.adjustOriginToCenter(shapeObj);
|
558
|
+
|
559
|
+
shapeObj.width *= shapeObj.scaleX;
|
560
|
+
shapeObj.height *= shapeObj.scaleY;
|
561
|
+
shapeObj.rx *= shapeObj.scaleX;
|
562
|
+
shapeObj.ry *= shapeObj.scaleY;
|
563
|
+
shapeObj.scaleX = 1;
|
564
|
+
shapeObj.scaleY = 1;
|
565
|
+
|
566
|
+
rePositionFilterTypeFillImage(shapeObj);
|
567
|
+
|
568
|
+
changeOrigin(shapeObj, {
|
569
|
+
originX,
|
570
|
+
originY,
|
571
|
+
});
|
572
|
+
|
573
|
+
resetFillPatternCanvas(patternSourceCanvas);
|
574
|
+
}
|
575
|
+
|
576
|
+
/**
|
577
|
+
* Reset filter area position within group selection.
|
578
|
+
* @param {fabric.Object} shapeObj - Shape object
|
579
|
+
* @param {fabric.ActiveSelection} activeSelection - Shape object
|
580
|
+
* @private
|
581
|
+
*/
|
582
|
+
_fillFilterRePositionInGroupSelection(shapeObj, activeSelection) {
|
583
|
+
if (activeSelection.scaleX !== 1 || activeSelection.scaleY !== 1) {
|
584
|
+
// This is necessary because the group's scale transition state affects the relative size of the fill area.
|
585
|
+
// The only way to reset the object transformation scale state to neutral.
|
586
|
+
// {@link https://github.com/fabricjs/fabric.js/issues/5372}
|
587
|
+
activeSelection.addWithUpdate();
|
588
|
+
}
|
589
|
+
|
590
|
+
const { angle, left, top } = shapeObj;
|
591
|
+
|
592
|
+
fabric.util.addTransformToObject(shapeObj, activeSelection.calcTransformMatrix());
|
593
|
+
this._resetPositionFillFilter(shapeObj);
|
594
|
+
|
595
|
+
shapeObj.set({
|
596
|
+
angle,
|
597
|
+
left,
|
598
|
+
top,
|
599
|
+
});
|
600
|
+
}
|
601
|
+
}
|