diff --git a/common/src/app/common/types/path/shape_to_path.cljc b/common/src/app/common/types/path/shape_to_path.cljc index 665eb592fe..62cf231479 100644 --- a/common/src/app/common/types/path/shape_to_path.cljc +++ b/common/src/app/common/types/path/shape_to_path.cljc @@ -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" diff --git a/common/test/common_tests/types/path_data_test.cljc b/common/test/common_tests/types/path_data_test.cljc index 42a40d3abc..dbf92931d5 100644 --- a/common/test/common_tests/types/path_data_test.cljc +++ b/common/test/common_tests/types/path_data_test.cljc @@ -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)} diff --git a/frontend/test/frontend_tests/logic/path_lifecycle_test.cljs b/frontend/test/frontend_tests/logic/path_lifecycle_test.cljs index 2dca2a405f..3b765025a1 100644 --- a/frontend/test/frontend_tests/logic/path_lifecycle_test.cljs +++ b/frontend/test/frontend_tests/logic/path_lifecycle_test.cljs @@ -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)))))))))