Merge pull request #5526 from penpot/superalex-render-wasm-stroke-caps

🎉 Stroke caps support for wasm render
This commit is contained in:
Belén Albeza 2025-01-09 12:35:05 +01:00 committed by GitHub
commit 194cca4b64
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
5 changed files with 288 additions and 35 deletions

View file

@ -219,21 +219,35 @@
:mixed 3
0))
(defn- translate-stroke-cap
[stroke-cap]
(case stroke-cap
:line-arrow 1
:triangle-arrow 2
:square-marker 3
:circle-marker 4
:diamond-marker 5
:round 6
:square 7
0))
(defn set-shape-strokes
[strokes]
(h/call internal-module "_clear_shape_strokes")
(keep (fn [stroke]
(let [opacity (or (:stroke-opacity stroke) 1.0)
color (:stroke-color stroke)
gradient (:stroke-color-gradient stroke)
image (:stroke-image stroke)
width (:stroke-width stroke)
align (:stroke-alignment stroke)
style (-> stroke :stroke-style translate-stroke-style)]
(let [opacity (or (:stroke-opacity stroke) 1.0)
color (:stroke-color stroke)
gradient (:stroke-color-gradient stroke)
image (:stroke-image stroke)
width (:stroke-width stroke)
align (:stroke-alignment stroke)
style (-> stroke :stroke-style translate-stroke-style)
cap-start (-> stroke :stroke-cap-start translate-stroke-cap)
cap-end (-> stroke :stroke-cap-end translate-stroke-cap)]
(case align
:inner (h/call internal-module "_add_shape_inner_stroke" width style)
:outer (h/call internal-module "_add_shape_outer_stroke" width style)
(h/call internal-module "_add_shape_center_stroke" width style))
:inner (h/call internal-module "_add_shape_inner_stroke" width style cap-start cap-end)
:outer (h/call internal-module "_add_shape_outer_stroke" width style cap-start cap-end)
(h/call internal-module "_add_shape_center_stroke" width style cap-start cap-end))
(cond
(some? gradient)