From c8b42478b0d570115bde4a1e37f34de0eb414c7b Mon Sep 17 00:00:00 2001 From: Andrey Antukh Date: Tue, 5 Sep 2023 23:19:16 +0200 Subject: [PATCH] :zap: Add minor optimizations to shapes/circle component --- frontend/src/app/main/ui/shapes/circle.cljs | 28 +++++++++++---------- 1 file changed, 15 insertions(+), 13 deletions(-) diff --git a/frontend/src/app/main/ui/shapes/circle.cljs b/frontend/src/app/main/ui/shapes/circle.cljs index 4501098ba..50a947252 100644 --- a/frontend/src/app/main/ui/shapes/circle.cljs +++ b/frontend/src/app/main/ui/shapes/circle.cljs @@ -6,6 +6,7 @@ (ns app.main.ui.shapes.circle (:require + [app.common.data.macros :as dm] [app.common.geom.shapes :as gsh] [app.main.ui.shapes.attrs :as attrs] [app.main.ui.shapes.custom-stroke :refer [shape-custom-strokes]] @@ -16,21 +17,22 @@ {::mf/wrap-props false} [props] (let [shape (unchecked-get props "shape") - {:keys [x y width height]} shape - transform (gsh/transform-str shape) - cx (+ x (/ width 2)) - cy (+ y (/ height 2)) - rx (/ width 2) - ry (/ height 2) + x (dm/get-prop shape :x) + y (dm/get-prop shape :y) + w (dm/get-prop shape :width) + h (dm/get-prop shape :height) - props (-> (attrs/extract-style-attrs shape) - (obj/merge! - #js {:cx cx - :cy cy - :rx rx - :ry ry - :transform transform}))] + t (gsh/transform-str shape) + + cx (+ x (/ w 2)) + cy (+ y (/ h 2)) + rx (/ w 2) + ry (/ h 2) + + props (mf/with-memo [shape] + (-> (attrs/extract-style-attrs shape) + (obj/merge! #js {:cx cx :cy cy :rx rx :ry ry :transform t})))] [:& shape-custom-strokes {:shape shape} [:> :ellipse props]]))