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:
parent
997876db32
commit
d882c2dfdb
1 changed files with 8 additions and 2 deletions
|
@ -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)
|
||||
|
|
Loading…
Add table
Reference in a new issue