mirror of
https://github.com/penpot/penpot.git
synced 2025-03-15 01:01:30 -05:00
⚡ Add minor optimizations to shapes/circle component
This commit is contained in:
parent
9993d357da
commit
c8b42478b0
1 changed files with 15 additions and 13 deletions
|
@ -6,6 +6,7 @@
|
||||||
|
|
||||||
(ns app.main.ui.shapes.circle
|
(ns app.main.ui.shapes.circle
|
||||||
(:require
|
(:require
|
||||||
|
[app.common.data.macros :as dm]
|
||||||
[app.common.geom.shapes :as gsh]
|
[app.common.geom.shapes :as gsh]
|
||||||
[app.main.ui.shapes.attrs :as attrs]
|
[app.main.ui.shapes.attrs :as attrs]
|
||||||
[app.main.ui.shapes.custom-stroke :refer [shape-custom-strokes]]
|
[app.main.ui.shapes.custom-stroke :refer [shape-custom-strokes]]
|
||||||
|
@ -16,21 +17,22 @@
|
||||||
{::mf/wrap-props false}
|
{::mf/wrap-props false}
|
||||||
[props]
|
[props]
|
||||||
(let [shape (unchecked-get props "shape")
|
(let [shape (unchecked-get props "shape")
|
||||||
{:keys [x y width height]} shape
|
|
||||||
transform (gsh/transform-str shape)
|
|
||||||
|
|
||||||
cx (+ x (/ width 2))
|
x (dm/get-prop shape :x)
|
||||||
cy (+ y (/ height 2))
|
y (dm/get-prop shape :y)
|
||||||
rx (/ width 2)
|
w (dm/get-prop shape :width)
|
||||||
ry (/ height 2)
|
h (dm/get-prop shape :height)
|
||||||
|
|
||||||
props (-> (attrs/extract-style-attrs shape)
|
t (gsh/transform-str shape)
|
||||||
(obj/merge!
|
|
||||||
#js {:cx cx
|
cx (+ x (/ w 2))
|
||||||
:cy cy
|
cy (+ y (/ h 2))
|
||||||
:rx rx
|
rx (/ w 2)
|
||||||
:ry ry
|
ry (/ h 2)
|
||||||
:transform transform}))]
|
|
||||||
|
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}
|
[:& shape-custom-strokes {:shape shape}
|
||||||
[:> :ellipse props]]))
|
[:> :ellipse props]]))
|
||||||
|
|
Loading…
Add table
Reference in a new issue