🎉 Allow to edit measures of multiple and grouped objects

This commit is contained in:
Andrés Moya 2020-07-01 13:38:41 +02:00
parent b640bc06ab
commit ceaea9d679
13 changed files with 152 additions and 98 deletions

View file

@ -168,24 +168,7 @@
:proportion 1
:proportion-lock false))
;; --- Resize (Dimentsions)
(defn resize-rect
[shape attr value]
(us/assert map? shape)
(us/assert #{:width :height} attr)
(us/assert number? value)
(let [{:keys [proportion proportion-lock]} shape]
(if-not proportion-lock
(assoc shape attr value)
(if (= attr :width)
(-> shape
(assoc :width value)
(assoc :height (/ value proportion)))
(-> shape
(assoc :height value)
(assoc :width (* value proportion)))))))
;; --- Resize (Dimensions)
(defn resize
[shape width height]
@ -199,6 +182,24 @@
:x2 (+ (:x1 selrect) width)
:y2 (+ (:y1 selrect) height))))))
(defn resize-rect
[shape attr value]
(us/assert map? shape)
(us/assert #{:width :height} attr)
(us/assert number? value)
(let [{:keys [proportion proportion-lock]} shape
size (select-keys shape [:width :height])
new-size (if-not proportion-lock
(assoc size attr value)
(if (= attr :width)
(-> size
(assoc :width value)
(assoc :height (/ value proportion)))
(-> size
(assoc :height value)
(assoc :width (* value proportion)))))]
(resize shape (:width new-size) (:height new-size))))
;; --- Setup (Initialize)
(declare setup-rect)