0
Fork 0
mirror of https://github.com/penpot/penpot.git synced 2025-01-25 07:58:49 -05:00

Make translate-coords parametrizable with operation.

This commit is contained in:
Andrey Antukh 2016-01-22 19:36:47 +02:00
parent f4ba1f4fdb
commit d73781f51c

View file

@ -144,10 +144,12 @@
(defn translate-coords
"Given a shape and initial coords, transform
it mapping its coords to new provided initial coords."
[shape x y]
(let [x' (:x shape)
y' (:y shape)]
(assoc shape :x (- x' x) :y (- y' y))))
([shape x y]
(translate-coords shape x y -))
([shape x y op]
(let [x' (:x shape)
y' (:y shape)]
(assoc shape :x (op x' x) :y (op y' y)))))
(defn resolve-position
"Recursively resolve the real shape position in