🐛 Close the outline of a rect converted to a path

Converting a rect to a path gave an outline that went back to its start
with a line and stayed open, so a stroke missed its join at the first
corner. With the WASM engine on, the engine converts the rect and closes
the outline, so the two engines gave different paths for one shape.

The rect's outline now ends with `close-path`, as the WASM engine's does
(user decision). The path editor closes subpaths its own way on entry,
which its lifecycle test now expects.

Found by the WASM replay of the pinned generated programs (program 329),
which passes with the change.

Tests: `path-data-test/shape-to-path-rect-closes-its-outline`.

The conversion is outside the paths the component benchmark measures;
it is not run.

AI-assisted-by: claude-opus-5-5
This commit is contained in:
alonso.torres 2026-11-16 09:07:04 +01:00
parent 415206fa9f
commit dabda4a752
3 changed files with 15 additions and 2 deletions

View File

@ -123,7 +123,8 @@
(conj (helpers/make-line-to p7))
(cond-> (not= p7 p8)
(conj (make-corner-arc p7 p8 :bottom-left r4)))
(conj (helpers/make-line-to p1))))))
;; the outline closes, so a stroke joins at its first corner too
(conj {:command :close-path :params {}})))))
(defn- rect->path
"Creates a bezier curve that approximates a rounded corner rectangle"

View File

@ -2545,6 +2545,17 @@
;; so we just check it doesn't throw and returns a :path type
(t/is (some? (:content result)))))
(t/deftest shape-to-path-rect-closes-its-outline
;; as the WASM engine converts it: a stroke joins at the first corner too
(doseq [r [0.0 10.0]]
(let [shape {:type :rect :x 0.0 :y 0.0 :width 100.0 :height 50.0
:r1 r :r2 r :r3 r :r4 r
:selrect (make-selrect 0.0 0.0 100.0 50.0)}
segs (vec (:content (path/convert-to-path shape {})))]
(t/is (= :move-to (:command (first segs))))
(t/is (= :close-path (:command (peek segs))))
(t/is (= 1 (count (filter #(= :close-path (:command %)) segs)))))))
(t/deftest shape-to-path-circle
(let [shape {:type :circle :x 0.0 :y 0.0 :width 100.0 :height 100.0
:selrect (make-selrect 0.0 0.0 100.0 100.0)}

View File

@ -310,8 +310,9 @@
drawing-copy (get-in new-state [:workspace-drawing :object])]
(t/is (= original-rect stored-shape))
(t/is (= :path (:type drawing-copy)))
;; the editor edits the converted outline with its subpaths closed
(t/is (= (path/move-content
(:content (path/convert-to-path original-rect))
(path/close-subpaths (:content (path/convert-to-path original-rect)))
delta)
(:content drawing-copy)))))))))