fix(engine): box a turned outline by its own points

Review: the outline bounds turned the unturned box's corners, so a turned
or skewed shape was measured bigger than it is. The points are now carried
into stage space first, then boxed.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
Ayberk A.andClaude Opus 5.5 committed 2026-11-23 12:18:36 +03:00
1 parent 781077861c
commit 7bf24041db
2 files changed
+12 -1

No files matched your search

+3 -1
View File
@@ -242,7 +242,9 @@ impl Session {
pub fn element_outline_bounds_on(&self, layer: LayerId, id: ElementId) -> Rect {
let mut r = Rect::EMPTY;
for item in self.display_list().items.iter().filter(|i| i.element == id && i.layer == layer) {
r = r.union(&item.path.bounds().transformed(&item.transform));
// The points carried into stage space, then boxed: a turned or skewed outline's box
// is no bigger than the outline.
r = r.union(&item.path.transformed(&item.transform).bounds());
}
r
}
+9
View File
@@ -392,6 +392,15 @@ fn align_lines_up_outlines_not_stroke_edges() {
assert!(o.min.x.abs() < 0.01 && o.min.y.abs() < 0.01, "the outline's corner is on the stage's (object: {object}): {o:?}");
assert!(c.min.x < o.min.x && c.min.y < o.min.y, "the stroke hangs over the edge (object: {object})");
}
// A turned outline is measured by its own points, not by its unturned box turned with it.
let mut s = Session::default();
run(&mut s, "draw.ellipse", json!({"x": 100, "y": 100, "w": 200, "h": 40, "stroke": null, "object": true}));
run(&mut s, "edit.select_all", json!({}));
run(&mut s, "element.set_transform", json!({"rotation": 45}));
let (l, e) = s.selected_elements()[0].clone();
let outline = s.element_outline_bounds_on(l, e.id);
let boxed = s.display_list().items.iter().filter(|i| i.element == e.id).fold(Rect::EMPTY, |r, i| r.union(&i.path.bounds().transformed(&i.transform)));
assert!(outline.width() < boxed.width() - 1.0, "{outline:?} inside {boxed:?}");
}
#[test]