Improve initial shape drawing impl.

This commit is contained in:
Andrey Antukh 2019-08-22 23:07:01 +02:00
parent 12637bbfe4
commit 363b2db695

View file

@ -118,24 +118,13 @@
:y2 (+ (:y point) 2)})] :y2 (+ (:y point) 2)})]
(assoc-in state [:workspace pid :drawing] (assoc shape ::initialized? true)))) (assoc-in state [:workspace pid :drawing] (assoc shape ::initialized? true))))
;; NOTE: this is a new approach for resizing, when all the
;; subsystem are migrated to the new resize approach, this
;; function should be moved into uxbox.main.geom ns.
(resize-shape [shape point lock?] (resize-shape [shape point lock?]
(if (= (:type shape) :circle) (let [shape (-> (geom/shape->rect-shape shape)
(let [rx (mth/abs (- (:x point) (:cx shape))) (geom/size))
ry (mth/abs (- (:y point) (:cy shape)))] result (geom/resize-shape :bottom-right shape point lock?)
(if lock? scale (geom/calculate-scale-ratio shape result)
(assoc shape :rx rx :ry ry) mtx (geom/generate-resize-matrix :bottom-right shape scale)]
(assoc shape :rx rx :ry rx))) (assoc shape :modifier-mtx mtx)))
(let [width (- (:x point) (:x1 shape))
height (- (:y point) (:y1 shape))
proportion (:proportion shape 1)]
(assoc shape
:x2 (+ (:x1 shape) width)
:y2 (if lock?
(+ (:y1 shape) (/ width proportion))
(+ (:y1 shape) height))))))
(update-drawing [state point lock?] (update-drawing [state point lock?]
(let [pid (get-in state [:workspace :current])] (let [pid (get-in state [:workspace :current])]