Update tooltip positions for all hovered and picked points This should be called when the plot canvas position changes
(&mut self)
| 395 | world, |
| 396 | x_axis_scale, |
| 397 | y_axis_scale, |
| 398 | transform, |
| 399 | Some(camera.axis_ranges()), |
| 400 | )?; |
| 401 | let ndc_x = (world[0] - camera.position.x) / camera.half_extents.x; |
| 402 | let ndc_y = (world[1] - camera.position.y) / camera.half_extents.y; |
| 403 | let screen_x = (ndc_x as f32 + 1.0) * 0.5 * bounds.width; |
| 404 | let screen_y = (1.0 - ndc_y as f32) * 0.5 * bounds.height; |
| 405 | |
| 406 | (screen_x.is_finite() && screen_y.is_finite()).then_some([screen_x, screen_y]) |
| 407 | } |
| 408 | |
| 409 | /// Compute the world-space anchor point for a tooltip. |
| 410 | /// |
| 411 | /// For pixel-sized markers (or no markers), this is the point's (x, y). |
| 412 | /// For world-sized square markers, the marker is effectively bottom-left anchored, |
| 413 | /// so we anchor the tooltip at the marker's center (x + size/2, y + size/2). |
| 414 | fn tooltip_anchor_world(point: &HighlightPoint) -> [f64; 2] { |
| 415 | if let Some(marker_style) = point.marker_style |
| 416 | && let Size::World(size) = marker_style.size |
| 417 | { |
| 418 | let half = size * 0.5; |