From a9b47f2414cb662de5fab5660602e6de03eb1ba2 Mon Sep 17 00:00:00 2001 From: Johannes Hofmann Date: Tue, 27 Oct 2026 14:38:46 +0100 Subject: web: leader lines for unmarked peak labels The C++ original draws a cross + vertical + horizontal leader for every labeled peak, not just marked ones. Without them, collision- pushed peak labels float unattached and it is impossible to tell which dot they belong to (verified by replaying layout_label_y on a synthetic ridge scene). Peak leaders use the muted pale green of the label text; marker leaders stay yellow with the small cross. --- crates/wipfel/src/canvas_view.rs | 24 +++++++++++++++--------- 1 file changed, 15 insertions(+), 9 deletions(-) (limited to 'crates') diff --git a/crates/wipfel/src/canvas_view.rs b/crates/wipfel/src/canvas_view.rs index 808ba1a..8f13a1c 100644 --- a/crates/wipfel/src/canvas_view.rs +++ b/crates/wipfel/src/canvas_view.rs @@ -240,21 +240,27 @@ pub fn canvas_view(props: &Props) -> Html { let in_img = vec![true; order.len()]; let entries = layout_label_y(&xs, &ys, &widths, &in_img, line_h); - // leaders (yellow): cross, vertical, horizontal — - // drawn for markers only - #[allow(deprecated)] - ctx.set_stroke_style(&wasm_bindgen::JsValue::from_str("rgb(255, 230, 51)")); + // leaders: vertical + horizontal line connecting each + // label to its peak (C++ draws these for every + // labeled peak); markers yellow with a small cross, + // unmarked peaks a muted pale green ctx.set_line_width(1.0); for (k, &i) in order.iter().enumerate() { - if !items[i].marker { - continue; - } let (px, py) = (sx(items[i].x), sy(items[i].y)); let (lx, ly) = entries[k]; let label_line = py + ly as f64 - line_h as f64; + let color = if items[i].marker { + "rgb(255, 230, 51)" + } else { + "rgba(196, 240, 214, 0.75)" + }; + #[allow(deprecated)] + ctx.set_stroke_style(&wasm_bindgen::JsValue::from_str(color)); ctx.begin_path(); - ctx.move_to(px - 4.0, py); - ctx.line_to(px + 4.0, py); + if items[i].marker { + ctx.move_to(px - 4.0, py); + ctx.line_to(px + 4.0, py); + } ctx.move_to(px, py); ctx.line_to(px, label_line); ctx.move_to(px, label_line); -- cgit v1.2.3