(&mut self, message: Message, now: Instant)
| 85 | } |
| 86 | |
| 87 | fn update(&mut self, message: Message, now: Instant) { |
| 88 | match message { |
| 89 | Message::PlotMessage(plot_msg) => { |
| 90 | self.widget.update(plot_msg); |
| 91 | } |
| 92 | Message::Tick => { |
| 93 | if self.frame_count == 0 { |
| 94 | return; |
| 95 | } |
| 96 | let elapsed = match self.last_tick { |
| 97 | Some(prev) => now.saturating_duration_since(prev), |
| 98 | None => Duration::ZERO, |
| 99 | }; |
| 100 | self.last_tick = Some(now); |
| 101 | self.accumulator += elapsed; |
| 102 | |
| 103 | let mut steps = 0usize; |
| 104 | while self.accumulator >= self.frame_duration { |
| 105 | self.accumulator -= self.frame_duration; |
| 106 | steps += 1; |
| 107 | } |
| 108 | if steps > 0 { |
| 109 | self.frame_idx = (self.frame_idx + steps) % self.frame_count; |
| 110 | self.update_frame(); |
| 111 | } |
| 112 | } |
| 113 | } |
| 114 | } |
| 115 | |
| 116 | fn update_frame(&mut self) { |
| 117 | if self.frame_count == 0 { |
nothing calls this directly
no test coverage detected