mirror of
https://github.com/penpot/penpot.git
synced 2025-08-07 14:38:33 +02: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)]
|
(when-let [shape (:drawing @wb/workspace-ref)]
|
||||||
(case (:type shape)
|
(case (:type shape)
|
||||||
:icon (on-init-draw-icon shape)
|
:icon (on-init-draw-icon shape)
|
||||||
|
:image (on-init-draw-icon shape)
|
||||||
:path (if (:free shape)
|
:path (if (:free shape)
|
||||||
(on-init-draw-free-path shape)
|
(on-init-draw-free-path shape)
|
||||||
(on-init-draw-path shape))
|
(on-init-draw-path shape))
|
||||||
|
@ -118,9 +119,14 @@
|
||||||
;; --- Icon Drawing
|
;; --- Icon Drawing
|
||||||
|
|
||||||
(defn- on-init-draw-icon
|
(defn- on-init-draw-icon
|
||||||
[shape]
|
[{:keys [metadata] :as shape}]
|
||||||
(let [{:keys [x y]} (gpt/divide @wb/mouse-canvas-a @wb/zoom-ref)
|
(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)]
|
shape (geom/setup shape props)]
|
||||||
(rs/emit! (uds/add-shape shape)
|
(rs/emit! (uds/add-shape shape)
|
||||||
(udw/select-for-drawing nil)
|
(udw/select-for-drawing nil)
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue