From f519a707e32679ec512518afc3c56eeec03c260a Mon Sep 17 00:00:00 2001 From: Johannes Hofmann Date: Tue, 27 Oct 2026 14:49:24 +0100 Subject: web: process label layout right-to-left like the desktop MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The desktop lays out labels in alpha-descending order (the C pointer-array sort), which on screen means right to left — so the leftmost peak of a collision cluster ends up on top of the stack. The web port sorted by screen x ascending, inverting every stack and making labels look assigned to the wrong peaks. Sort descending; the break-early scan in layout_label_y stays valid because it only relies on monotonic x, and labels extend rightward just like in C. Verified against the desktop rendering of the same panorama photo and a right-to-left replay of the layout in the label simulator. --- crates/wipfel/src/canvas_view.rs | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/crates/wipfel/src/canvas_view.rs b/crates/wipfel/src/canvas_view.rs index 8f13a1c..76aebfc 100644 --- a/crates/wipfel/src/canvas_view.rs +++ b/crates/wipfel/src/canvas_view.rs @@ -220,13 +220,16 @@ pub fn canvas_view(props: &Props) -> Html { } // layout runs in screen space, sorted by x + // descending (right to left): the desktop processes + // hills in alpha-descending order, which puts the + // leftmost peak on top of a collision stack let mut order: Vec = (0..items.len()) .filter(|&i| { items[i].x.abs() * 2.0 <= bitmap.width() as f64 && items[i].y.abs() * 2.0 <= bitmap.height() as f64 }) .collect(); - order.sort_by(|&a, &b| sx(items[a].x).total_cmp(&sx(items[b].x))); + order.sort_by(|&a, &b| sx(items[b].x).total_cmp(&sx(items[a].x))); let xs: Vec = order.iter().map(|&i| sx(items[i].x) as f32).collect(); let ys: Vec = order.iter().map(|&i| sy(items[i].y) as f32).collect(); let widths: Vec = order -- cgit v1.2.3