From c65e8b4a5e97dc1498e43ad6e5ee4ceacf4ff1a0 Mon Sep 17 00:00:00 2001 From: "alonso.torres" Date: Wed, 20 Oct 2021 14:25:32 +0200 Subject: [PATCH] :bug: Fix problem with stroke inside/outside --- CHANGES.md | 1 + .../src/app/main/ui/shapes/custom_stroke.cljs | 22 +++++++++++++++---- 2 files changed, 19 insertions(+), 4 deletions(-) diff --git a/CHANGES.md b/CHANGES.md index 093004ca9..c0959056d 100644 --- a/CHANGES.md +++ b/CHANGES.md @@ -41,6 +41,7 @@ - Fix path stroke is not working properly with high thickness [Taiga #2154](https://tree.taiga.io/project/penpot/issue/2154). - Fix bug with transformation operations [Taiga #2155](https://tree.taiga.io/project/penpot/issue/2155). - Fix bug in firefox when a text box is inside a mask [Taiga #2152](https://tree.taiga.io/project/penpot/issue/2152). +- Fix problem with stroke inside/outside [Taiga #2186](https://tree.taiga.io/project/penpot/issue/2186) - Fix paste in place in arboards [Taiga #2188](https://tree.taiga.io/project/penpot/issue/2188) - Fix stroke cut on shapes export [Taiga #2171](https://tree.taiga.io/project/penpot/issue/2171) diff --git a/frontend/src/app/main/ui/shapes/custom_stroke.cljs b/frontend/src/app/main/ui/shapes/custom_stroke.cljs index 619e9954e..35d7691de 100644 --- a/frontend/src/app/main/ui/shapes/custom_stroke.cljs +++ b/frontend/src/app/main/ui/shapes/custom_stroke.cljs @@ -35,8 +35,22 @@ [{:keys [shape render-id]}] (let [stroke-mask-id (str "outer-stroke-" render-id) shape-id (str "stroke-shape-" render-id) - stroke-width (:stroke-width shape 0)] - [:mask {:id stroke-mask-id} + stroke-width (case (:stroke-alignment shape :center) + :center (/ (:stroke-width shape 0) 2) + :outer (:stroke-width shape 0) + 0) + margin (gsh/shape-stroke-margin shape stroke-width) + bounding-box (-> (gsh/points->selrect (:points shape)) + (update :x - (+ stroke-width margin)) + (update :y - (+ stroke-width margin)) + (update :width + (* 2 (+ stroke-width margin))) + (update :height + (* 2 (+ stroke-width margin))))] + [:mask {:id stroke-mask-id + :x (:x bounding-box) + :y (:y bounding-box) + :width (:width bounding-box) + :height (:height bounding-box) + :maskUnits "userSpaceOnUse"} [:use {:xlinkHref (str "#" shape-id) :style #js {:fill "none" :stroke "white" :strokeWidth (* stroke-width 2)}}] @@ -146,8 +160,8 @@ (mf/defc stroke-defs [{:keys [shape render-id]}] - (when (and (= (:type shape) :path) - (gsh/open-path? shape)) + (when (or (not= (:type shape) :path) + (not (gsh/open-path? shape))) (cond (and (= :inner (:stroke-alignment shape :center)) (> (:stroke-width shape 0) 0))