| 532 | } |
| 533 | |
| 534 | fn marker_path(center: iced::Point, radius: f32, marker_type: MarkerType) -> canvas::Path { |
| 535 | match marker_type { |
| 536 | MarkerType::FilledCircle | MarkerType::EmptyCircle => canvas::Path::circle(center, radius), |
| 537 | MarkerType::Square => canvas::Path::rectangle( |
| 538 | iced::Point::new(center.x - radius, center.y - radius), |
| 539 | iced::Size::new(radius * 2.0, radius * 2.0), |
| 540 | ), |
| 541 | MarkerType::Triangle => canvas::Path::new(|builder| { |
| 542 | builder.move_to(iced::Point::new(center.x, center.y - radius * 0.866)); |
| 543 | builder.line_to(iced::Point::new( |
| 544 | center.x + radius, |
| 545 | center.y + radius * 0.866, |
| 546 | )); |
| 547 | builder.line_to(iced::Point::new( |
| 548 | center.x - radius, |
| 549 | center.y + radius * 0.866, |
| 550 | )); |
| 551 | builder.close(); |
| 552 | }), |
| 553 | MarkerType::Star => canvas::Path::new(|builder| { |
| 554 | for index in 0..5 { |
| 555 | let outer_angle = |
| 556 | -std::f32::consts::FRAC_PI_2 + index as f32 * std::f32::consts::TAU / 5.0; |
| 557 | let inner_angle = outer_angle + std::f32::consts::TAU / 10.0; |
| 558 | let outer = iced::Point::new( |
| 559 | center.x + outer_angle.cos() * radius, |
| 560 | center.y + outer_angle.sin() * radius, |
| 561 | ); |
| 562 | let inner = iced::Point::new( |
| 563 | center.x + inner_angle.cos() * radius * 0.45, |
| 564 | center.y + inner_angle.sin() * radius * 0.45, |
| 565 | ); |
| 566 | if index == 0 { |
| 567 | builder.move_to(outer); |
| 568 | } else { |
| 569 | builder.line_to(outer); |
| 570 | } |
| 571 | builder.line_to(inner); |
| 572 | } |
| 573 | builder.close(); |
| 574 | }), |
| 575 | } |
| 576 | } |
| 577 | |
| 578 | fn world_to_canvas_point(world: [f64; 2], camera: &Camera, bounds: &Rectangle) -> iced::Point { |
| 579 | let ndc_x = (world[0] - camera.position.x) / camera.half_extents.x; |