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

Method new

examples/bad_apple.rs:41–85  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

39
40impl App {
41 fn new() -> Self {
42 let frames = include_bytes!("assets/bad_apple_gray.bin");
43 let pixels_per_frame = FRAME_WIDTH * FRAME_HEIGHT;
44 let frame_count = frames.len() / pixels_per_frame;
45 let positions = build_positions(FRAME_WIDTH, FRAME_HEIGHT);
46 let initial_colors = if frame_count > 0 {
47 frame_colors(0, frames, FRAME_WIDTH, FRAME_HEIGHT)
48 } else {
49 vec![Color::from_rgb(0.0, 0.0, 0.0); positions.len()]
50 };
51 let series = Series::markers_only(
52 positions.clone(),
53 MarkerStyle::new_world(1.0, MarkerType::Square),
54 )
55 .with_point_colors(initial_colors);
56 let series_id = series.id;
57 let widget = PlotWidgetBuilder::new()
58 .with_data_aspect(1.0)
59 .with_x_tick_labels(false)
60 .with_y_tick_labels(false)
61 .with_hover_highlight_provider(|context, point| {
62 Some(format!(
63 "frame: {}\nx: {}, y: {}",
64 context.point_index,
65 point.x.round(),
66 point.y.round()
67 ))
68 })
69 .with_cursor_overlay(false)
70 .add_series(series)
71 .disable_controls_help()
72 .build()
73 .unwrap();
74
75 Self {
76 series_id,
77 widget,
78 frames,
79 frame_idx: 0,
80 frame_count,
81 last_tick: None,
82 accumulator: Duration::ZERO,
83 frame_duration: Duration::from_secs_f64(1.0 / FRAME_RATE),
84 }
85 }
86
87 fn update(&mut self, message: Message, now: Instant) {
88 match message {

Callers

nothing calls this directly

Calls 12

build_positionsFunction · 0.85
frame_colorsFunction · 0.85
with_point_colorsMethod · 0.80
buildMethod · 0.80
disable_controls_helpMethod · 0.80
with_cursor_overlayMethod · 0.80
with_y_tick_labelsMethod · 0.80
with_x_tick_labelsMethod · 0.80
with_data_aspectMethod · 0.80
newFunction · 0.70
add_seriesMethod · 0.45

Tested by

no test coverage detected