summaryrefslogtreecommitdiff
path: root/crates/wipfel/src
diff options
context:
space:
mode:
authorJohannes Hofmann <Johannes.Hofmann@gmx.de>2026-10-27 14:38:46 +0100
committerJohannes Hofmann <Johannes.Hofmann@gmx.de>2026-10-27 14:38:46 +0100
commita9b47f2414cb662de5fab5660602e6de03eb1ba2 (patch)
tree2e6f5de32aca1d1740df1e1f29d63b73d47b8af5 /crates/wipfel/src
parent6fa2ffc8964b31c4e85393527599b5da97b53c9a (diff)
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.
Diffstat (limited to 'crates/wipfel/src')
-rw-r--r--crates/wipfel/src/canvas_view.rs24
1 files changed, 15 insertions, 9 deletions
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);