0
Fork 0
mirror of https://github.com/penpot/penpot.git synced 2025-01-24 07:29:08 -05:00

🐛 Ensure float on rect-center operation.

This commit is contained in:
Andrey Antukh 2021-01-27 14:42:52 +01:00
parent bd3921b91b
commit af478c83cd
4 changed files with 9 additions and 12 deletions

View file

@ -44,16 +44,14 @@
v
(number? v)
(Point. v v)
(point v v)
(point-like? v)
(Point. (:x v) (:y v))
(point (:x v) (:y v))
:else
(throw (ex-info "Invalid arguments" {:v v}))))
([x y]
;;(assert (not (nil? x)))
;;(assert (not (nil? y)))
(Point. x y)))
(defn angle->point [{:keys [x y]} angle distance]

View file

@ -18,8 +18,8 @@
(mth/finite? y)
(mth/finite? width)
(mth/finite? height))
(gpt/point (+ x (/ width 2))
(+ y (/ height 2)))))
(gpt/point (+ x (/ width 2.0))
(+ y (/ height 2.0)))))
(defn center-selrect
"Calculate the center of the shape."
@ -36,8 +36,8 @@
miny (reduce min ##Inf pty)
maxx (reduce max ##-Inf ptx)
maxy (reduce max ##-Inf pty)]
(gpt/point (/ (+ minx maxx) 2)
(/ (+ miny maxy) 2))))
(gpt/point (/ (+ minx maxx) 2.0)
(/ (+ miny maxy) 2.0))))
(defn center-shape
"Calculate the center of the shape."
@ -47,7 +47,7 @@
(defn make-centered-rect
"Creates a rect given a center and a width and height"
[center width height]
{:x (- (:x center) (/ width 2))
:y (- (:y center) (/ height 2))
{:x (- (:x center) (/ width 2.0))
:y (- (:y center) (/ height 2.0))
:width width
:height height})

View file

@ -62,9 +62,7 @@
(defn transform-points
([points matrix]
(transform-points points nil matrix))
([points center matrix]
(let [prev (if center (gmt/translate-matrix center) (gmt/matrix))
post (if center (gmt/translate-matrix (gpt/negate center)) (gmt/matrix))

View file

@ -53,6 +53,7 @@
files (some->> recent-ids
(map #(get files-map %))
(sort-by :modified-at)
(filter some?)
(reverse))
project-id (:id project)