🐛 Relax schema for importing plain path data related to curve-to command

This commit is contained in:
Andrey Antukh
2025-11-03 14:26:00 +01:00
parent 21fb38e5bd
commit 78e2d6fec3
2 changed files with 25 additions and 4 deletions

View File

@@ -498,10 +498,10 @@
[:map [:map
[:x schema:safe-number] [:x schema:safe-number]
[:y schema:safe-number] [:y schema:safe-number]
[:c1x schema:safe-number] [:c1x {:optional true} schema:safe-number]
[:c1y schema:safe-number] [:c1y {:optional true} schema:safe-number]
[:c2x schema:safe-number] [:c2x {:optional true} schema:safe-number]
[:c2y schema:safe-number]]]]) [:c2y {:optional true} schema:safe-number]]]])
(def ^:private schema:segment (def ^:private schema:segment
[:multi {:title "PathSegment" [:multi {:title "PathSegment"

View File

@@ -116,6 +116,27 @@
(t/is (= sample-content (t/is (= sample-content
(vec pdata))))) (vec pdata)))))
;; Test the specific case where cuve-to commands comes without the
;; optional attrs
(t/deftest path-data-plain-to-binary-2
(let [plain-content
[{:command :move-to :params {:x 480.0 :y 839.0}}
{:command :line-to :params {:x 439.0 :y 802.0}}
{:command :curve-to :params {:x 264.0 :y 634.0}}
{:command :curve-to :params {:x 154.0 :y 508.0}}]
binary-content
(path/content plain-content)]
#?(:clj
(t/is (= "M480.0,839.0L439.0,802.0C264.0,634.0,264.0,634.0,264.0,634.0C154.0,508.0,154.0,508.0,154.0,508.0"
(str binary-content)))
:cljs
(t/is (= "M480,839L439,802C264,634,264,634,264,634C154,508,154,508,154,508"
(str binary-content))))))
(t/deftest path-data-from-binary (t/deftest path-data-from-binary
(let [barray #?(:clj (byte-array sample-bytes) (let [barray #?(:clj (byte-array sample-bytes)
:cljs (js/Int8Array.from sample-bytes)) :cljs (js/Int8Array.from sample-bytes))