mirror of
https://github.com/penpot/penpot.git
synced 2025-01-26 08:29:42 -05:00
🐛 Fixes problems with line paths
This commit is contained in:
parent
3171d9d64d
commit
d517daa045
2 changed files with 30 additions and 1 deletions
|
@ -11,7 +11,7 @@
|
||||||
(:require
|
(:require
|
||||||
[app.common.uuid :as uuid]))
|
[app.common.uuid :as uuid]))
|
||||||
|
|
||||||
(def file-version 5)
|
(def file-version 6)
|
||||||
(def default-color "#b1b2b5") ;; $color-gray-20
|
(def default-color "#b1b2b5") ;; $color-gray-20
|
||||||
(def root uuid/zero)
|
(def root uuid/zero)
|
||||||
|
|
||||||
|
|
|
@ -13,6 +13,7 @@
|
||||||
[app.common.geom.shapes :as gsh]
|
[app.common.geom.shapes :as gsh]
|
||||||
[app.common.geom.shapes.path :as gsp]
|
[app.common.geom.shapes.path :as gsp]
|
||||||
[app.common.geom.matrix :as gmt]
|
[app.common.geom.matrix :as gmt]
|
||||||
|
[app.common.math :as mth]
|
||||||
[app.common.uuid :as uuid]
|
[app.common.uuid :as uuid]
|
||||||
[app.common.data :as d]))
|
[app.common.data :as d]))
|
||||||
|
|
||||||
|
@ -137,3 +138,31 @@
|
||||||
|
|
||||||
(update data :pages-index #(d/mapm update-page %))))
|
(update data :pages-index #(d/mapm update-page %))))
|
||||||
|
|
||||||
|
(defn fix-line-paths
|
||||||
|
"Fixes issues with selrect/points for shapes with width/height = 0 (line-like paths)"
|
||||||
|
[_ shape]
|
||||||
|
(if (= (:type shape) :path)
|
||||||
|
(let [{:keys [width height]} (gsh/points->rect (:points shape))]
|
||||||
|
(if (or (mth/almost-zero? width) (mth/almost-zero? height))
|
||||||
|
(let [selrect (gsh/content->selrect (:content shape))
|
||||||
|
points (gsh/rect->points selrect)
|
||||||
|
transform (gmt/matrix)
|
||||||
|
transform-inv (gmt/matrix)]
|
||||||
|
(assoc shape
|
||||||
|
:selrect selrect
|
||||||
|
:points points
|
||||||
|
:transform transform
|
||||||
|
:transform-inverse transform-inv))
|
||||||
|
shape))
|
||||||
|
shape))
|
||||||
|
|
||||||
|
|
||||||
|
(defmethod migrate 6
|
||||||
|
[data]
|
||||||
|
(letfn [(update-container [_ container]
|
||||||
|
(-> container
|
||||||
|
(update :objects #(d/mapm fix-line-paths %))))]
|
||||||
|
|
||||||
|
(-> data
|
||||||
|
(update :components #(d/mapm update-container %))
|
||||||
|
(update :pages-index #(d/mapm update-container %)))))
|
||||||
|
|
Loading…
Add table
Reference in a new issue