0
Fork 0
mirror of https://github.com/penpot/penpot.git synced 2025-04-06 20:11:29 -05:00

Respect proportion of icon or image when is added/imported to workspace.

This commit is contained in:
Andrey Antukh 2016-10-24 22:17:27 +02:00
parent 997876db32
commit d882c2dfdb
No known key found for this signature in database
GPG key ID: 4DFEBCB8316A8B95

View file

@ -110,6 +110,7 @@
(when-let [shape (:drawing @wb/workspace-ref)]
(case (:type shape)
:icon (on-init-draw-icon shape)
:image (on-init-draw-icon shape)
:path (if (:free shape)
(on-init-draw-free-path shape)
(on-init-draw-path shape))
@ -118,9 +119,14 @@
;; --- Icon Drawing
(defn- on-init-draw-icon
[shape]
[{:keys [metadata] :as shape}]
(let [{:keys [x y]} (gpt/divide @wb/mouse-canvas-a @wb/zoom-ref)
props {:x1 x :y1 y :x2 (+ x 100) :y2 (+ y 100)}
{:keys [width height]} metadata
proportion (/ width height)
props {:x1 x
:y1 y
:x2 (+ x 200)
:y2 (+ y (/ 200 proportion))}
shape (geom/setup shape props)]
(rs/emit! (uds/add-shape shape)
(udw/select-for-drawing nil)