From eed75bcbdad23d7d4d5550f4dac6b5e06126212b Mon Sep 17 00:00:00 2001 From: "alonso.torres" Date: Wed, 20 Oct 2021 14:25:08 +0200 Subject: [PATCH] :bug: Fix stroke cut on shapes export --- CHANGES.md | 1 + common/src/app/common/geom/shapes.cljc | 10 +++++++++- frontend/src/app/main/ui/shapes/filters.cljs | 19 ++++++------------- 3 files changed, 16 insertions(+), 14 deletions(-) diff --git a/CHANGES.md b/CHANGES.md index 8d9f88979..093004ca9 100644 --- a/CHANGES.md +++ b/CHANGES.md @@ -42,6 +42,7 @@ - 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 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) ### :arrow_up: Deps updates diff --git a/common/src/app/common/geom/shapes.cljc b/common/src/app/common/geom/shapes.cljc index 86cd32d81..91a7043ba 100644 --- a/common/src/app/common/geom/shapes.cljc +++ b/common/src/app/common/geom/shapes.cljc @@ -13,7 +13,8 @@ [app.common.geom.shapes.intersect :as gin] [app.common.geom.shapes.path :as gsp] [app.common.geom.shapes.rect :as gpr] - [app.common.geom.shapes.transforms :as gtr])) + [app.common.geom.shapes.transforms :as gtr] + [app.common.math :as mth])) ;; --- Setup (Initialize) ;; FIXME: Is this the correct place for these functions? @@ -127,6 +128,13 @@ (assoc :selrect selrect :points points)))) +(defn shape-stroke-margin + [shape stroke-width] + (if (= (:type shape) :path) + ;; TODO: Calculate with the stroke offset (not implemented yet + (mth/sqrt (* 2 stroke-width stroke-width)) + (- (mth/sqrt (* 2 stroke-width stroke-width)) stroke-width))) + ;; EXPORTS (d/export gco/center-shape) diff --git a/frontend/src/app/main/ui/shapes/filters.cljs b/frontend/src/app/main/ui/shapes/filters.cljs index 25af34796..60ba3fee6 100644 --- a/frontend/src/app/main/ui/shapes/filters.cljs +++ b/frontend/src/app/main/ui/shapes/filters.cljs @@ -202,17 +202,12 @@ :height (- y2 y1)}))))) (defn calculate-padding [shape] - (let [{:keys [stroke-style stroke-alignment stroke-width]} shape] - (cond - (and (not= stroke-style :none) - (= stroke-alignment :outer)) - stroke-width - - (and (not= stroke-style :none) - (= stroke-alignment :center)) - (mth/ceil (/ stroke-width 2)) - - :else 0))) + (let [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)] + (+ stroke-width margin))) (mf/defc filters [{:keys [filter-id shape]}] @@ -221,9 +216,7 @@ ;; Adds the previous filter as `filter-in` parameter filters (map #(assoc %1 :filter-in %2) filters (cons nil (map :id filters))) - bounds (get-filters-bounds shape filters (or (-> shape :blur :value) 0)) - padding (calculate-padding shape)] [:*