diff options
| author | Johannes Hofmann <Johannes.Hofmann@gmx.de> | 2026-10-27 14:49:24 +0100 |
|---|---|---|
| committer | Johannes Hofmann <Johannes.Hofmann@gmx.de> | 2026-10-27 14:49:24 +0100 |
| commit | f519a707e32679ec512518afc3c56eeec03c260a (patch) | |
| tree | 4feafb56364dc1b7692ea25c0e20adeb4019c890 /crates/wipfel/src | |
| parent | a9b47f2414cb662de5fab5660602e6de03eb1ba2 (diff) | |
web: process label layout right-to-left like the desktop
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.
Diffstat (limited to 'crates/wipfel/src')
| -rw-r--r-- | crates/wipfel/src/canvas_view.rs | 5 |
1 files changed, 4 insertions, 1 deletions
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<usize> = (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<f32> = order.iter().map(|&i| sx(items[i].x) as f32).collect(); let ys: Vec<f32> = order.iter().map(|&i| sy(items[i].y) as f32).collect(); let widths: Vec<f32> = order |
