fix(canvas): arc-sector hit-test handles a negative sweep

A negative `sweep_angle` covers the angular range `[start + sweep,
start]`; the hit-test compared against `sweep.abs()` from `start`,
rejecting points that are actually inside such an arc. Normalise to
a forward sweep before the angle-window test.

Self-review follow-up to the arc/pen-handle work (the codex second
review stalled mid-run). op-editor-ui 148 tests green.

🤖 Generated with [Claude Code](https://claude.com/claude-code)
This commit is contained in:
Kayshen-X 2026-05-17 18:56:04 +08:00
parent 442dbabb78
commit 82d33e27df

View file

@ -191,10 +191,16 @@ fn point_in_node(node: &SceneNode, local: Point2D, bounds: Rect, zoom: f32) -> b
let sweep = node.arc_sweep_angle.unwrap_or(360.0);
if sweep.abs() < 359.9 {
let start = node.arc_start_angle.unwrap_or(0.0);
// Angle of the point, normalised into [0, sweep).
// Normalise to a forward sweep — a negative sweep
// covers the angular range `[start + sweep, start]`.
let (sector_start, span) = if sweep < 0.0 {
(start + sweep, -sweep)
} else {
(start, sweep)
};
let ang = dy.atan2(dx).to_degrees();
let rel = (ang - start).rem_euclid(360.0);
if rel > sweep.abs() {
let rel = (ang - sector_start).rem_euclid(360.0);
if rel > span {
return false;
}
}