0
Fork 0
mirror of https://github.com/penpot/penpot.git synced 2025-01-07 15:39:42 -05:00

🐛 Fix problem with borders on shape export

This commit is contained in:
alonso.torres 2021-08-30 16:47:57 +02:00 committed by Andrés Moya
parent 2dfa4f9ec9
commit 1b6e6ec2e4
3 changed files with 29 additions and 8 deletions

View file

@ -20,6 +20,7 @@
- Prevent adding numeric suffix to layer names when not needed [Taiga #1929](https://tree.taiga.io/project/penpot/us/1929).
- Prevent deleting or moving the drafts project [Taiga #1935](https://tree.taiga.io/project/penpot/issue/1935).
- Fix problem with zoom and selection [Taiga #1919](https://tree.taiga.io/project/penpot/issue/1919)
- Fix problem with borders on shape export [#1092](https://github.com/penpot/penpot/issues/1092)
### :arrow_up: Deps updates
### :boom: Breaking changes

View file

@ -55,7 +55,12 @@
width (* width zoom)
height (* height zoom)
vbox (str/join " " [x y width height])
padding (* (filters/calculate-padding object) zoom)
vbox (str/join " " [(- x padding)
(- y padding)
(+ width padding padding)
(+ height padding padding)])
frame-wrapper
(mf/use-memo
@ -81,8 +86,8 @@
[:& (mf/provider embed/context) {:value true}
[:svg {:id "screenshot"
:view-box vbox
:width width
:height height
:width (+ width padding padding)
:height (+ height padding padding)
:version "1.1"
:xmlns "http://www.w3.org/2000/svg"
:xmlnsXlink "http://www.w3.org/1999/xlink"

View file

@ -201,6 +201,19 @@
:width (- x2 x1)
: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)))
(mf/defc filters
[{:keys [filter-id shape]}]
@ -209,15 +222,17 @@
;; 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))]
bounds (get-filters-bounds shape filters (or (-> shape :blur :value) 0))
padding (calculate-padding shape)]
[:*
(when (> (count filters) 2)
[:filter {:id filter-id
:x (:x bounds)
:y (:y bounds)
:width (:width bounds)
:height (:height bounds)
:x (- (:x bounds) padding)
:y (- (:y bounds) padding)
:width (+ (:width bounds) (* 2 padding))
:height (+ (:height bounds) (* 2 padding))
:filterUnits "userSpaceOnUse"
:color-interpolation-filters "sRGB"}