From ba5cf0e3b73eb30edfc24aebd733b9f402694de5 Mon Sep 17 00:00:00 2001 From: Igor Zinken Date: Tue, 29 Dec 2020 12:46:50 +0100 Subject: [PATCH] Implemented layer mirroring effect --- README.md | 1 + src/assets/icons/tool-mirror.svg | 22 ++++++ .../components/layers/layers.vue | 11 +-- .../tool-options-brush/tool-options-brush.vue | 2 +- .../tool-options-eraser.vue | 2 +- .../tool-options-mirror/messages.json | 7 ++ .../tool-options-mirror.vue | 77 +++++++++++++++++++ .../tool-options-rotate.vue | 2 +- .../tool-options-zoom/tool-options-zoom.vue | 11 +-- .../options-panel/options-panel.vue | 2 + src/components/toolbox/messages.json | 1 + src/components/toolbox/toolbox.vue | 21 +++-- src/factories/effects-factory.js | 56 ++++++++++++++ src/factories/layer-factory.js | 9 ++- src/services/keyboard-service.js | 6 ++ src/services/render-service.js | 32 +++++--- .../{tool-option.scss => options-panel.scss} | 10 +++ tests/unit/factories/effects-factory.spec.js | 41 ++++++++++ tests/unit/factories/layer-factory.spec.js | 51 ++++++------ 19 files changed, 298 insertions(+), 66 deletions(-) create mode 100644 src/assets/icons/tool-mirror.svg create mode 100644 src/components/options-panel/components/tool-options-mirror/messages.json create mode 100644 src/components/options-panel/components/tool-options-mirror/tool-options-mirror.vue create mode 100644 src/factories/effects-factory.js rename src/styles/{tool-option.scss => options-panel.scss} (62%) create mode 100644 tests/unit/factories/effects-factory.spec.js diff --git a/README.md b/README.md index a31fc5f..99bbba3 100644 --- a/README.md +++ b/README.md @@ -56,6 +56,7 @@ npm run lint # TODO / Roadmap * Moving of masks broken ? +* Issue with drawing mask on mirrored content * Verify saving and restoring of masked and rotated and positioned content * Transparency blocks should be rendered by zCanvas, not parent div * Copying selections on rotated content doesn't work diff --git a/src/assets/icons/tool-mirror.svg b/src/assets/icons/tool-mirror.svg new file mode 100644 index 0000000..e94ec5a --- /dev/null +++ b/src/assets/icons/tool-mirror.svg @@ -0,0 +1,22 @@ + + + + + + + + + + + + diff --git a/src/components/options-panel/components/layers/layers.vue b/src/components/options-panel/components/layers/layers.vue index e2b63a1..8e9cd62 100644 --- a/src/components/options-panel/components/layers/layers.vue +++ b/src/components/options-panel/components/layers/layers.vue @@ -160,6 +160,7 @@ export default { diff --git a/src/components/options-panel/components/tool-options-brush/tool-options-brush.vue b/src/components/options-panel/components/tool-options-brush/tool-options-brush.vue index bc03211..446e628 100644 --- a/src/components/options-panel/components/tool-options-brush/tool-options-brush.vue +++ b/src/components/options-panel/components/tool-options-brush/tool-options-brush.vue @@ -74,5 +74,5 @@ export default { diff --git a/src/components/options-panel/components/tool-options-eraser/tool-options-eraser.vue b/src/components/options-panel/components/tool-options-eraser/tool-options-eraser.vue index 3bd7598..950fe02 100644 --- a/src/components/options-panel/components/tool-options-eraser/tool-options-eraser.vue +++ b/src/components/options-panel/components/tool-options-eraser/tool-options-eraser.vue @@ -94,5 +94,5 @@ export default { diff --git a/src/components/options-panel/components/tool-options-mirror/messages.json b/src/components/options-panel/components/tool-options-mirror/messages.json new file mode 100644 index 0000000..e3207b8 --- /dev/null +++ b/src/components/options-panel/components/tool-options-mirror/messages.json @@ -0,0 +1,7 @@ +{ + "en-US": { + "mirror": "Mirror", + "flipHorizontal": "Flip horizontal", + "flipVertical": "Flip vertical" + } +} diff --git a/src/components/options-panel/components/tool-options-mirror/tool-options-mirror.vue b/src/components/options-panel/components/tool-options-mirror/tool-options-mirror.vue new file mode 100644 index 0000000..4a0de72 --- /dev/null +++ b/src/components/options-panel/components/tool-options-mirror/tool-options-mirror.vue @@ -0,0 +1,77 @@ +/** + * The MIT License (MIT) + * + * Igor Zinken 2020 - https://www.igorski.nl + * + * Permission is hereby granted, free of charge, to any person obtaining a copy of + * this software and associated documentation files (the "Software"), to deal in + * the Software without restriction, including without limitation the rights to + * use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of + * the Software, and to permit persons to whom the Software is furnished to do so, + * subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS + * FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR + * COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER + * IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN + * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + */ + + + + + diff --git a/src/components/options-panel/components/tool-options-rotate/tool-options-rotate.vue b/src/components/options-panel/components/tool-options-rotate/tool-options-rotate.vue index dbd5ed6..7df8194 100644 --- a/src/components/options-panel/components/tool-options-rotate/tool-options-rotate.vue +++ b/src/components/options-panel/components/tool-options-rotate/tool-options-rotate.vue @@ -75,5 +75,5 @@ export default { diff --git a/src/components/options-panel/components/tool-options-zoom/tool-options-zoom.vue b/src/components/options-panel/components/tool-options-zoom/tool-options-zoom.vue index 87bd451..7e14108 100644 --- a/src/components/options-panel/components/tool-options-zoom/tool-options-zoom.vue +++ b/src/components/options-panel/components/tool-options-zoom/tool-options-zoom.vue @@ -95,14 +95,5 @@ export default { diff --git a/src/components/options-panel/options-panel.vue b/src/components/options-panel/options-panel.vue index c4309d1..4ca811f 100644 --- a/src/components/options-panel/options-panel.vue +++ b/src/components/options-panel/options-panel.vue @@ -126,6 +126,8 @@ export default { return () => import( "./components/tool-options-brush/tool-options-brush" ); case ToolTypes.ROTATE: return () => import( "./components/tool-options-rotate/tool-options-rotate" ); + case ToolTypes.MIRROR: + return () => import( "./components/tool-options-mirror/tool-options-mirror" ); } }, }, diff --git a/src/components/toolbox/messages.json b/src/components/toolbox/messages.json index 552fc1f..a374442 100644 --- a/src/components/toolbox/messages.json +++ b/src/components/toolbox/messages.json @@ -5,6 +5,7 @@ "polygonalLasso": "Polygonal lasso", "eyedropper": "Eyedropper", "rotateLayer": "Rotate layer", + "mirrorLayer": "Mirror layer", "zoom": "Zoom", "eraser": "Eraser", "brush": "Brush", diff --git a/src/components/toolbox/toolbox.vue b/src/components/toolbox/toolbox.vue index 70598b0..8f50d30 100644 --- a/src/components/toolbox/toolbox.vue +++ b/src/components/toolbox/toolbox.vue @@ -35,7 +35,7 @@