(
frame: &mut Frame,
world_position: [f64; 2],
size: f32,
size_mode: u32,
marker: u32,
color: Color,
camera: &Camera,
bounds: &Rectangle,
)
| 379 | |
| 380 | #[allow(clippy::too_many_arguments)] |
| 381 | fn 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); |
no test coverage detected