mirror of
https://github.com/penpot/penpot.git
synced 2025-05-01 00:56:20 +02:00
♻️ Avoid using get-prop when unneeded in serializers
This commit is contained in:
parent
b41a7b8547
commit
4bf9e24d43
1 changed files with 10 additions and 11 deletions
|
@ -1,6 +1,5 @@
|
||||||
(ns app.render-wasm.serializers.fills
|
(ns app.render-wasm.serializers.fills
|
||||||
(:require
|
(:require
|
||||||
[app.common.data.macros :as dm]
|
|
||||||
[app.render-wasm.serializers.color :as clr]))
|
[app.render-wasm.serializers.color :as clr]))
|
||||||
|
|
||||||
(def GRADIENT-STOP-SIZE 8)
|
(def GRADIENT-STOP-SIZE 8)
|
||||||
|
@ -14,12 +13,12 @@
|
||||||
(defn serialize-gradient-fill
|
(defn serialize-gradient-fill
|
||||||
[gradient opacity heap offset]
|
[gradient opacity heap offset]
|
||||||
(let [dview (js/DataView. (.-buffer heap))
|
(let [dview (js/DataView. (.-buffer heap))
|
||||||
start-x (dm/get-prop gradient :start-x)
|
start-x (:start-x gradient)
|
||||||
start-y (dm/get-prop gradient :start-y)
|
start-y (:start-y gradient)
|
||||||
end-x (dm/get-prop gradient :end-x)
|
end-x (:end-x gradient)
|
||||||
end-y (dm/get-prop gradient :end-y)
|
end-y (:end-y gradient)
|
||||||
width (or (dm/get-prop gradient :width) 0)
|
width (or (:width gradient) 0)
|
||||||
stops (dm/get-prop gradient :stops)]
|
stops (:stops gradient)]
|
||||||
(.setFloat32 dview offset start-x true)
|
(.setFloat32 dview offset start-x true)
|
||||||
(.setFloat32 dview (+ offset 4) start-y true)
|
(.setFloat32 dview (+ offset 4) start-y true)
|
||||||
(.setFloat32 dview (+ offset 8) end-x true)
|
(.setFloat32 dview (+ offset 8) end-x true)
|
||||||
|
@ -29,10 +28,10 @@
|
||||||
(loop [stops (seq stops) offset (+ offset GRADIENT-BASE-SIZE)]
|
(loop [stops (seq stops) offset (+ offset GRADIENT-BASE-SIZE)]
|
||||||
(when-not (empty? stops)
|
(when-not (empty? stops)
|
||||||
(let [stop (first stops)
|
(let [stop (first stops)
|
||||||
hex-color (dm/get-prop stop :color)
|
hex-color (:color stop)
|
||||||
opacity (dm/get-prop stop :opacity)
|
opacity (:opacity stop)
|
||||||
argb (clr/hex->u32argb hex-color opacity)
|
argb (clr/hex->u32argb hex-color opacity)
|
||||||
stop-offset (dm/get-prop stop :offset)]
|
stop-offset (:offset stop)]
|
||||||
(.setUint32 dview offset argb true)
|
(.setUint32 dview offset argb true)
|
||||||
(.setFloat32 dview (+ offset 4) stop-offset true)
|
(.setFloat32 dview (+ offset 4) stop-offset true)
|
||||||
(recur (rest stops) (+ offset GRADIENT-STOP-SIZE)))))))
|
(recur (rest stops) (+ offset GRADIENT-STOP-SIZE)))))))
|
Loading…
Add table
Reference in a new issue