diff --git a/backend/src/app/features/components_v2.clj b/backend/src/app/features/components_v2.clj index aa8695ee8..db4ca2536 100644 --- a/backend/src/app/features/components_v2.clj +++ b/backend/src/app/features/components_v2.clj @@ -1255,7 +1255,7 @@ :frame-id frame-id :parent-id frame-id}) (assoc - :proportion (/ width height) + :proportion (float (/ width height)) :proportion-lock true)) img-shape (cts/setup-shape diff --git a/common/src/app/common/geom/proportions.cljc b/common/src/app/common/geom/proportions.cljc index c884aa369..342145b68 100644 --- a/common/src/app/common/geom/proportions.cljc +++ b/common/src/app/common/geom/proportions.cljc @@ -13,27 +13,27 @@ (defn assign-proportions [shape] (let [{:keys [width height]} (:selrect shape)] - (assoc shape :proportion (/ width height)))) - -;; --- Setup Proportions - + (assoc shape :proportion (float (/ width height))))) ; Note: we need to convert explicitly to float. + ; In Clojure (not clojurescript) when we divide +;; --- Setup Proportions ; two integers it does not create a float, but + ; a clojure.lang.Ratio object. (defn setup-proportions-image [{:keys [metadata] :as shape}] (let [{:keys [width height]} metadata] (assoc shape - :proportion (/ width height) + :proportion (float (/ width height)) :proportion-lock true))) (defn setup-proportions-size [{{:keys [width height]} :selrect :as shape}] (assoc shape - :proportion (/ width height) + :proportion (float (/ width height)) :proportion-lock true)) (defn setup-proportions-const [shape] (assoc shape - :proportion 1 + :proportion 1.0 :proportion-lock false)) (defn setup-proportions diff --git a/common/src/app/common/types/shape.cljc b/common/src/app/common/types/shape.cljc index e76fbe2a6..2b610ca45 100644 --- a/common/src/app/common/types/shape.cljc +++ b/common/src/app/common/types/shape.cljc @@ -483,8 +483,8 @@ (defn- setup-image [{:keys [metadata] :as shape}] (-> shape - (assoc :proportion (/ (:width metadata) - (:height metadata))) + (assoc :proportion (float (/ (:width metadata) + (:height metadata)))) (assoc :proportion-lock true))) (defn setup-shape