()
| 34 | |
| 35 | impl App { |
| 36 | fn new() -> Self { |
| 37 | let control_points = vec![ |
| 38 | [-4.0, -0.5], |
| 39 | [-2.0, 1.5], |
| 40 | [0.0, -1.2], |
| 41 | [2.5, 1.8], |
| 42 | [4.0, 0.2], |
| 43 | ]; |
| 44 | |
| 45 | let control_poly = Series::line_only(control_points.clone(), LineStyle::dashed(8.0)) |
| 46 | .with_label("control polygon") |
| 47 | .with_color(Color::from_rgb(0.5, 0.5, 0.5)); |
| 48 | |
| 49 | let control_series = Series::markers_only(control_points.clone(), MarkerStyle::circle(7.0)) |
| 50 | .with_label("control points") |
| 51 | .with_color(Color::from_rgb(1.0, 0.5, 0.2)); |
| 52 | |
| 53 | let spline = Series::line_only(sample_catmull_rom(&control_points, 28), LineStyle::solid()) |
| 54 | .with_label("catmull-rom spline") |
| 55 | .with_color(Color::from_rgb(0.2, 0.8, 1.0)); |
| 56 | |
| 57 | let mut controls_cfg = PlotControls::default(); |
| 58 | controls_cfg.unbind_drag(mouse::Button::Left); |
| 59 | controls_cfg.bind_scroll(iced::keyboard::Modifiers::NONE, ScrollAction::Pan); |
| 60 | |
| 61 | let control_series_id = control_series.id; |
| 62 | let control_poly_id = control_poly.id; |
| 63 | let spline_series_id = spline.id; |
| 64 | |
| 65 | let widget = PlotWidgetBuilder::new() |
| 66 | .with_controls(controls_cfg) |
| 67 | .with_cursor_overlay(true) |
| 68 | .with_x_label("x") |
| 69 | .with_y_label("y") |
| 70 | .add_series(control_poly) |
| 71 | .add_series(spline) |
| 72 | .add_series(control_series) |
| 73 | .build() |
| 74 | .unwrap(); |
| 75 | |
| 76 | Self { |
| 77 | widget, |
| 78 | control_series_id, |
| 79 | control_poly_id, |
| 80 | spline_series_id, |
| 81 | control_points, |
| 82 | active_control_point: None, |
| 83 | } |
| 84 | } |
| 85 | |
| 86 | fn update(&mut self, message: Message) { |
| 87 | const DRAG_PICK_RADIUS_WORLD: f64 = 0.5; |
nothing calls this directly
no test coverage detected