diff --git a/frontend/src/app/main/render.cljs b/frontend/src/app/main/render.cljs index ec193c6af..6ad3080ab 100644 --- a/frontend/src/app/main/render.cljs +++ b/frontend/src/app/main/render.cljs @@ -189,7 +189,7 @@ (defn get-object-bounds [objects object-id] (let [object (get objects object-id) - padding (filters/calculate-padding object) + padding (filters/calculate-padding object true) bounds (-> (filters/get-filters-bounds object) (update :x - (:horizontal padding)) (update :y - (:vertical padding)) diff --git a/frontend/src/app/main/ui/shapes/filters.cljs b/frontend/src/app/main/ui/shapes/filters.cljs index 378a22397..b5cf278f2 100644 --- a/frontend/src/app/main/ui/shapes/filters.cljs +++ b/frontend/src/app/main/ui/shapes/filters.cljs @@ -200,25 +200,30 @@ :width (- x2 x1) :height (- y2 y1)}))))) -(defn calculate-padding [shape] - (let [stroke-width (apply max 0 (map #(case (:stroke-alignment % :center) - :center (/ (:stroke-width % 0) 2) - :outer (:stroke-width % 0) - 0) (:strokes shape))) +(defn calculate-padding + ([shape] + (calculate-padding shape false)) - margin (apply max 0 (map #(gsh/shape-stroke-margin % stroke-width) (:strokes shape))) + ([shape ignore-margin?] + (let [stroke-width (apply max 0 (map #(case (:stroke-alignment % :center) + :center (/ (:stroke-width % 0) 2) + :outer (:stroke-width % 0) + 0) (:strokes shape))) + margin (if ignore-margin? + 0 + (apply max 0 (map #(gsh/shape-stroke-margin % stroke-width) (:strokes shape)))) - shadow-width (apply max 0 (map #(case (:style % :drop-shadow) - :drop-shadow (+ (mth/abs (:offset-x %)) (* (:spread %) 2) (* (:blur %) 2) 10) - 0) (:shadow shape))) + shadow-width (apply max 0 (map #(case (:style % :drop-shadow) + :drop-shadow (+ (mth/abs (:offset-x %)) (* (:spread %) 2) (* (:blur %) 2) 10) + 0) (:shadow shape))) - shadow-height (apply max 0 (map #(case (:style % :drop-shadow) - :drop-shadow (+ (mth/abs (:offset-y %)) (* (:spread %) 2) (* (:blur %) 2) 10) - 0) (:shadow shape)))] + shadow-height (apply max 0 (map #(case (:style % :drop-shadow) + :drop-shadow (+ (mth/abs (:offset-y %)) (* (:spread %) 2) (* (:blur %) 2) 10) + 0) (:shadow shape)))] - {:horizontal (+ stroke-width margin shadow-width) - :vertical (+ stroke-width margin shadow-height)})) + {:horizontal (+ stroke-width margin shadow-width) + :vertical (+ stroke-width margin shadow-height)}))) (defn change-filter-in "Adds the previous filter as `filter-in` parameter"