0
Fork 0
mirror of https://github.com/penpot/penpot.git synced 2025-01-24 15:39:50 -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 v
(number? v) (number? v)
(Point. v v) (point v v)
(point-like? v) (point-like? v)
(Point. (:x v) (:y v)) (point (:x v) (:y v))
:else :else
(throw (ex-info "Invalid arguments" {:v v})))) (throw (ex-info "Invalid arguments" {:v v}))))
([x y] ([x y]
;;(assert (not (nil? x)))
;;(assert (not (nil? y)))
(Point. x y))) (Point. x y)))
(defn angle->point [{:keys [x y]} angle distance] (defn angle->point [{:keys [x y]} angle distance]

View file

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

View file

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

View file

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