💄 Change naming and args order of write-gradient-fill!

This commit is contained in:
Belén Albeza 2025-04-16 12:05:06 +02:00
parent 4bf9e24d43
commit 1da623e63f
2 changed files with 6 additions and 5 deletions

View file

@ -227,7 +227,7 @@
(let [size (sr-fills/gradient-byte-size gradient)
offset (mem/alloc-bytes size)
heap (mem/get-heap-u32)]
(sr-fills/serialize-gradient-fill gradient opacity heap offset)
(sr-fills/write-gradient-fill! offset heap gradient opacity)
(case (:type gradient)
:linear
(h/call wasm/internal-module "_add_shape_linear_fill")
@ -273,7 +273,7 @@
(let [size (sr-fills/gradient-byte-size gradient)
offset (mem/alloc-bytes size)
heap (mem/get-heap-u32)]
(sr-fills/serialize-gradient-fill gradient opacity heap offset)
(sr-fills/write-gradient-fill! offset heap gradient opacity)
(case (:type gradient)
:linear
(h/call wasm/internal-module "_add_shape_stroke_linear_fill")

View file

@ -10,8 +10,8 @@
(let [stops (:stops gradient)]
(+ GRADIENT-BASE-SIZE (* (count stops) GRADIENT-STOP-SIZE))))
(defn serialize-gradient-fill
[gradient opacity heap offset]
(defn write-gradient-fill!
[offset heap gradient opacity]
(let [dview (js/DataView. (.-buffer heap))
start-x (:start-x gradient)
start-y (:start-y gradient)
@ -26,7 +26,8 @@
(.setFloat32 dview (+ offset 16) opacity true)
(.setFloat32 dview (+ offset 20) width true)
(loop [stops (seq stops) offset (+ offset GRADIENT-BASE-SIZE)]
(when-not (empty? stops)
(if (empty? stops)
offset
(let [stop (first stops)
hex-color (:color stop)
opacity (:opacity stop)