mirror of
https://github.com/penpot/penpot.git
synced 2025-05-17 20:26:10 +02:00
🐛 Fix import svg with exterior strokes
This commit is contained in:
parent
4cdf8cec4e
commit
96aa756eb6
2 changed files with 20 additions and 15 deletions
|
@ -189,7 +189,7 @@
|
||||||
(defn get-object-bounds
|
(defn get-object-bounds
|
||||||
[objects object-id]
|
[objects object-id]
|
||||||
(let [object (get 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)
|
bounds (-> (filters/get-filters-bounds object)
|
||||||
(update :x - (:horizontal padding))
|
(update :x - (:horizontal padding))
|
||||||
(update :y - (:vertical padding))
|
(update :y - (:vertical padding))
|
||||||
|
|
|
@ -200,25 +200,30 @@
|
||||||
:width (- x2 x1)
|
:width (- x2 x1)
|
||||||
:height (- y2 y1)})))))
|
:height (- y2 y1)})))))
|
||||||
|
|
||||||
(defn calculate-padding [shape]
|
(defn calculate-padding
|
||||||
(let [stroke-width (apply max 0 (map #(case (:stroke-alignment % :center)
|
([shape]
|
||||||
:center (/ (:stroke-width % 0) 2)
|
(calculate-padding shape false))
|
||||||
:outer (:stroke-width % 0)
|
|
||||||
0) (:strokes shape)))
|
|
||||||
|
|
||||||
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)
|
shadow-width (apply max 0 (map #(case (:style % :drop-shadow)
|
||||||
:drop-shadow (+ (mth/abs (:offset-x %)) (* (:spread %) 2) (* (:blur %) 2) 10)
|
:drop-shadow (+ (mth/abs (:offset-x %)) (* (:spread %) 2) (* (:blur %) 2) 10)
|
||||||
0) (:shadow shape)))
|
0) (:shadow shape)))
|
||||||
|
|
||||||
shadow-height (apply max 0 (map #(case (:style % :drop-shadow)
|
shadow-height (apply max 0 (map #(case (:style % :drop-shadow)
|
||||||
:drop-shadow (+ (mth/abs (:offset-y %)) (* (:spread %) 2) (* (:blur %) 2) 10)
|
:drop-shadow (+ (mth/abs (:offset-y %)) (* (:spread %) 2) (* (:blur %) 2) 10)
|
||||||
0) (:shadow shape)))]
|
0) (:shadow shape)))]
|
||||||
|
|
||||||
{:horizontal (+ stroke-width margin shadow-width)
|
{:horizontal (+ stroke-width margin shadow-width)
|
||||||
:vertical (+ stroke-width margin shadow-height)}))
|
:vertical (+ stroke-width margin shadow-height)})))
|
||||||
|
|
||||||
(defn change-filter-in
|
(defn change-filter-in
|
||||||
"Adds the previous filter as `filter-in` parameter"
|
"Adds the previous filter as `filter-in` parameter"
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue