0
Fork 0
mirror of https://github.com/penpot/penpot.git synced 2025-01-10 00:40:30 -05:00

🐛 Fixes tests

This commit is contained in:
alonso.torres 2021-12-27 16:45:41 +01:00
parent 60af960f42
commit c28a2acfc7
3 changed files with 25 additions and 19 deletions

View file

@ -284,13 +284,14 @@
([command coord]
(let [params (:params command)
xkey (cond (= :c1 coord) :c1x
(= :c2 coord) :c2x
:else :x)
ykey (cond (= :c1 coord) :c1y
(= :c2 coord) :c2y
:else :y)
xkey (case coord
:c1 :c1x
:c2 :c2x
:x)
ykey (case coord
:c1 :c1y
:c2 :c2y
:y)
x (get params xkey)
y (get params ykey)]
(when (and (some? x) (some? y))

View file

@ -22,15 +22,18 @@
;; --- Relative Movement
(defn- move-selrect [selrect pt]
(let [dx (.-x pt)
dy (.-y pt)]
(-> selrect
(update :x + dx)
(update :y + dy)
(update :x1 + dx)
(update :y1 + dy)
(update :x2 + dx)
(update :y2 + dy))))
(when (and (some? selrect) (some? pt))
(let [dx (.-x pt)
dy (.-y pt)
{:keys [x y x1 y1 x2 y2 width height]} selrect]
{:x (if (some? x) (+ dx x) x)
:y (if (some? y) (+ dy y) y)
:x1 (if (some? x1) (+ dx x1) x1)
:y1 (if (some? y1) (+ dy y1) y1)
:x2 (if (some? x2) (+ dx x2) x2)
:y2 (if (some? y2) (+ dy y2) y2)
:width width
:height height})))
(defn- move-points [points move-vec]
(->> points

View file

@ -181,9 +181,11 @@
shape-before (-> (create-test-shape type {:modifiers modifiers})
(assoc :selrect selrect))
shape-after (gsh/transform-shape shape-before {:round-coords? false})]
(= (:selrect shape-before) (:selrect shape-after)))
:rect {:x 0 :y 0 :width ##Inf :height ##Inf}
:path {:x 0 :y 0 :width ##Inf :height ##Inf}
(= (:selrect shape-before)
(:selrect shape-after)))
:rect {:x 0 :y 0 :x1 0 :y1 0 :x2 ##Inf :y2 ##Inf :width ##Inf :height ##Inf}
:path {:x 0 :y 0 :x1 0 :y1 0 :x2 ##Inf :y2 ##Inf :width ##Inf :height ##Inf}
:rect nil
:path nil)))