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

Function draw_marker

src/plot_renderer/canvas.rs:381–451  ·  view source on GitHub ↗
(
    frame: &mut Frame,
    world_position: [f64; 2],
    size: f32,
    size_mode: u32,
    marker: u32,
    color: Color,
    camera: &Camera,
    bounds: &Rectangle,
)

Source from the content-addressed store, hash-verified

379
380#[allow(clippy::too_many_arguments)]
381fn draw_marker(
382 frame: &mut Frame,
383 world_position: [f64; 2],
384 size: f32,
385 size_mode: u32,
386 marker: u32,
387 color: Color,
388 camera: &Camera,
389 bounds: &Rectangle,
390) {
391 let mut center_world = world_position;
392 if size_mode == MARKER_SIZE_WORLD {
393 let half = f64::from(size) * 0.5;
394 center_world[0] += half;
395 center_world[1] += half;
396 }
397
398 let center = world_to_canvas_point(center_world, camera, bounds);
399 let radius = Size::size_px(size, size_mode, camera, bounds) * 0.5;
400 let marker_type = marker_type_from_u32(marker);
401
402 if marker_type == MarkerType::Square {
403 if size_mode == MARKER_SIZE_WORLD {
404 let top_left = world_to_canvas_point(
405 [world_position[0], world_position[1] + f64::from(size)],
406 camera,
407 bounds,
408 );
409 let bottom_right = world_to_canvas_point(
410 [world_position[0] + f64::from(size), world_position[1]],
411 camera,
412 bounds,
413 );
414 frame.fill_rectangle(
415 iced::Point::new(
416 top_left.x.min(bottom_right.x),
417 top_left.y.min(bottom_right.y),
418 ),
419 iced::Size::new(
420 (bottom_right.x - top_left.x).abs(),
421 (bottom_right.y - top_left.y).abs(),
422 ),
423 color,
424 );
425 } else {
426 let center = world_to_canvas_point(world_position, camera, bounds);
427 let side = Size::size_px(size, size_mode, camera, bounds);
428 let half = side * 0.5;
429 frame.fill_rectangle(
430 iced::Point::new(center.x - half, center.y - half),
431 iced::Size::new(side, side),
432 color,
433 );
434 }
435 return;
436 }
437
438 let path = marker_path(center, radius, marker_type);

Callers 2

draw_markersFunction · 0.85
draw_highlightsFunction · 0.85

Calls 6

world_to_canvas_pointFunction · 0.85
marker_type_from_u32Function · 0.85
marker_pathFunction · 0.85
newFunction · 0.50
with_colorMethod · 0.45
with_widthMethod · 0.45

Tested by

no test coverage detected