MCPcopy Create free account
hub / github.com/donkeyteethUX/iced_plot / draw_highlights

Function draw_highlights

src/plot_renderer/canvas.rs:273–346  ·  view source on GitHub ↗
(frame: &mut Frame, state: &PlotState, bounds: Rectangle)

Source from the content-addressed store, hash-verified

271}
272
273fn draw_highlights(frame: &mut Frame, state: &PlotState, bounds: Rectangle) {
274 for highlight in state.highlighted_points.iter() {
275 if let Some(marker_style) = highlight.marker_style
276 && let Some(plot_pos) = highlight_marker_plot_position(highlight, state)
277 {
278 let (size, size_mode) = marker_style.size.to_raw();
279 draw_marker(
280 frame,
281 plot_pos,
282 size,
283 size_mode,
284 marker_style.marker_type as u32,
285 highlight.color,
286 &state.camera,
287 &bounds,
288 );
289 }
290
291 let Some(mask_padding) = highlight.mask_padding else {
292 continue;
293 };
294 let Some(marker_style) = highlight.marker_style else {
295 continue;
296 };
297 let Some(plot_pos) = highlight_mask_plot_position(highlight, state) else {
298 continue;
299 };
300
301 if marker_style.marker_type == MarkerType::Square
302 && let Size::World(size) = marker_style.size
303 {
304 let Some(top_left_plot) = data_point_to_plot_with_transform(
305 [highlight.x, highlight.y + size],
306 state.x_axis_scale,
307 state.y_axis_scale,
308 &highlight.transform,
309 Some(state.camera.axis_ranges()),
310 ) else {
311 continue;
312 };
313 let Some(bottom_right_plot) = data_point_to_plot_with_transform(
314 [highlight.x + size, highlight.y],
315 state.x_axis_scale,
316 state.y_axis_scale,
317 &highlight.transform,
318 Some(state.camera.axis_ranges()),
319 ) else {
320 continue;
321 };
322 let top_left = world_to_canvas_point(top_left_plot, &state.camera, &bounds);
323 let bottom_right = world_to_canvas_point(bottom_right_plot, &state.camera, &bounds);
324 frame.fill_rectangle(
325 iced::Point::new(
326 top_left.x.min(bottom_right.x),
327 top_left.y.min(bottom_right.y),
328 ),
329 iced::Size::new(
330 (bottom_right.x - top_left.x).abs(),

Callers 1

drawFunction · 0.85

Calls 10

draw_markerFunction · 0.85
world_to_canvas_pointFunction · 0.85
highlight_mask_colorFunction · 0.85
to_rawMethod · 0.80
axis_rangesMethod · 0.80
to_pxMethod · 0.80
newFunction · 0.50

Tested by

no test coverage detected