From 07384e599e11dc39bbcf79650259ab2d88bb681e Mon Sep 17 00:00:00 2001 From: "alonso.torres" Date: Fri, 13 Nov 2026 16:12:27 +0100 Subject: [PATCH] :bug: Read a bool's orientation from its turn and flips when syncing A group keeps its transform when it fits its children but clears its flip flags; a bool keeps its flags while fitting it resets its transform. Sync read the orientation of both from their transform, so a bool in a copy whose main was flipped, resized afterwards, looked unflipped, and a full sync unflipped its shapes, apart from the settled file. A bool's orientation now comes from its turn and flips, a group's from its transform. The harness generates resizes of copy bools again. Test: a-copy-bool-and-its-shapes-are-compared-by-their-corners, now reached; group, sync, switch, golden master and generated group and bool tests pass (376). Benchmark (alone): | :world | :baseline | :now | :mean | :ratio | |------------------------------------+-----------+--------+---------+--------| | deepest-edit-through-three-levels | 35.215 | 21.34 | 27.387 | 0.61 | | edit-through-a-chain-of-dependents | 68.931 | 46.931 | 67.865 | 0.68 | | library-update-into-copies | 83.083 | 63.966 | 74.531 | 0.77 | | main-edit-among-many-shapes | 4.837 | 2.42 | 2.623 | 0.5 | | main-edit-into-10-copies | 1.79 | 1.122 | 1.169 | 0.63 | | main-edit-into-100-copies | 15.415 | 10.589 | 11.406 | 0.69 | | main-edit-into-1000-copies | 153.086 | 101.69 | 106.961 | 0.66 | | variant-switch-into-copies | 32.052 | 21.962 | 26.736 | 0.69 | AI-assisted-by: claude-opus-5-5 --- common/src/app/common/logic/libraries.cljc | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/common/src/app/common/logic/libraries.cljc b/common/src/app/common/logic/libraries.cljc index 1d52ee917a..9f05d9221d 100644 --- a/common/src/app/common/logic/libraries.cljc +++ b/common/src/app/common/logic/libraries.cljc @@ -2554,11 +2554,12 @@ plus))) (defn- flips - "The flips of `shape`: its flags, or for a group or bool, which takes its - bounds from its children and keeps no flags, whether its transform - mirrors, as a horizontal flip." + "The flips of `shape`: its flags, or for a group, which takes its bounds + from its children and clears its flags while its transform keeps the + mirror, whether its transform mirrors, as a horizontal flip. A bool keeps + its flags while fitting it resets its transform." [shape] - (if (#{:group :bool} (:type shape)) + (if (= :group (:type shape)) (let [{:keys [a b c d]} (axes-matrix shape)] {:flip-x (neg? (- (* a d) (* b c))) :flip-y false}) {:flip-x (boolean (:flip-x shape)) :flip-y (boolean (:flip-y shape))})) @@ -2568,7 +2569,11 @@ `target`'s; the lengths of the axes are left to constraints. Compose flip flags with the roots, independent of rotation step size." [head target center] - (let [head-flips (flips head) + (let [;; a bool keeps its turn and flips while fitting it resets its + ;; transform, so its orientation comes from them + head (cond-> head (= :bool (:type head)) (unskewed)) + target (cond-> target (= :bool (:type target)) (unskewed)) + head-flips (flips head) target-flips (flips target) flip-x? (not= (:flip-x head-flips) (:flip-x target-flips)) flip-y? (not= (:flip-y head-flips) (:flip-y target-flips))]