mirror of
https://github.com/penpot/penpot.git
synced 2025-05-06 16:05:53 +02:00
🐛 Avoid datatype problem calculating proportions
This commit is contained in:
parent
b2020c8a66
commit
c2737f2378
3 changed files with 10 additions and 10 deletions
|
@ -1255,7 +1255,7 @@
|
||||||
:frame-id frame-id
|
:frame-id frame-id
|
||||||
:parent-id frame-id})
|
:parent-id frame-id})
|
||||||
(assoc
|
(assoc
|
||||||
:proportion (/ width height)
|
:proportion (float (/ width height))
|
||||||
:proportion-lock true))
|
:proportion-lock true))
|
||||||
|
|
||||||
img-shape (cts/setup-shape
|
img-shape (cts/setup-shape
|
||||||
|
|
|
@ -13,27 +13,27 @@
|
||||||
(defn assign-proportions
|
(defn assign-proportions
|
||||||
[shape]
|
[shape]
|
||||||
(let [{:keys [width height]} (:selrect shape)]
|
(let [{:keys [width height]} (:selrect shape)]
|
||||||
(assoc shape :proportion (/ width height))))
|
(assoc shape :proportion (float (/ width height))))) ; Note: we need to convert explicitly to float.
|
||||||
|
; In Clojure (not clojurescript) when we divide
|
||||||
;; --- Setup Proportions
|
;; --- Setup Proportions ; two integers it does not create a float, but
|
||||||
|
; a clojure.lang.Ratio object.
|
||||||
(defn setup-proportions-image
|
(defn setup-proportions-image
|
||||||
[{:keys [metadata] :as shape}]
|
[{:keys [metadata] :as shape}]
|
||||||
(let [{:keys [width height]} metadata]
|
(let [{:keys [width height]} metadata]
|
||||||
(assoc shape
|
(assoc shape
|
||||||
:proportion (/ width height)
|
:proportion (float (/ width height))
|
||||||
:proportion-lock true)))
|
:proportion-lock true)))
|
||||||
|
|
||||||
(defn setup-proportions-size
|
(defn setup-proportions-size
|
||||||
[{{:keys [width height]} :selrect :as shape}]
|
[{{:keys [width height]} :selrect :as shape}]
|
||||||
(assoc shape
|
(assoc shape
|
||||||
:proportion (/ width height)
|
:proportion (float (/ width height))
|
||||||
:proportion-lock true))
|
:proportion-lock true))
|
||||||
|
|
||||||
(defn setup-proportions-const
|
(defn setup-proportions-const
|
||||||
[shape]
|
[shape]
|
||||||
(assoc shape
|
(assoc shape
|
||||||
:proportion 1
|
:proportion 1.0
|
||||||
:proportion-lock false))
|
:proportion-lock false))
|
||||||
|
|
||||||
(defn setup-proportions
|
(defn setup-proportions
|
||||||
|
|
|
@ -483,8 +483,8 @@
|
||||||
(defn- setup-image
|
(defn- setup-image
|
||||||
[{:keys [metadata] :as shape}]
|
[{:keys [metadata] :as shape}]
|
||||||
(-> shape
|
(-> shape
|
||||||
(assoc :proportion (/ (:width metadata)
|
(assoc :proportion (float (/ (:width metadata)
|
||||||
(:height metadata)))
|
(:height metadata))))
|
||||||
(assoc :proportion-lock true)))
|
(assoc :proportion-lock true)))
|
||||||
|
|
||||||
(defn setup-shape
|
(defn setup-shape
|
||||||
|
|
Loading…
Add table
Reference in a new issue