MCPcopy Create free account
hub / github.com/angular-rust/ux-charts / draw_frame

Method draw_frame

src/bar.rs:822–860  ·  view source on GitHub ↗

Draws the current animation frame. If [time] is `null`, draws the last frame (i.e. no animation).

(&self, ctx: &C, time: Option<i64>)

Source from the content-addressed store, hash-verified

820 ///
821 /// If [time] is `null`, draws the last frame (i.e. no animation).
822 fn draw_frame(&self, ctx: &C, time: Option<i64>) {
823 // clear surface
824 self.base.draw_frame(ctx, time);
825 self.draw_axes_and_grid(ctx);
826
827 let mut percent = self.base.calculate_percent(time);
828
829 if percent >= 1.0 {
830 percent = 1.0;
831
832 // Update the visibility states of all channel before the last frame.
833 let mut channels = self.base.channels.borrow_mut();
834 for channel in channels.iter_mut() {
835 if channel.state == Visibility::Showing {
836 channel.state = Visibility::Shown;
837 } else if channel.state == Visibility::Hiding {
838 channel.state = Visibility::Hidden;
839 }
840 }
841 }
842
843 let props = self.base.props.borrow();
844
845 let ease = match props.easing {
846 Some(val) => val,
847 None => get_easing(Easing::Linear),
848 };
849
850 self.draw_channels(ctx, ease(percent));
851 // ctx.drawImageScaled(ctx.canvas, 0, 0, width, height);
852 // ctx.drawImageScaled(ctx.canvas, 0, 0, width, height);
853 self.base.draw_title(ctx);
854
855 if percent < 1.0 {
856 // animation_frame_id = window.requestAnimationFrame(draw_frame);
857 } else if time.is_some() {
858 self.base.animation_end();
859 }
860 }
861
862 fn draw_channels(&self, ctx: &C, percent: f64) -> bool {
863 let channels = self.base.channels.borrow();

Callers 1

drawMethod · 0.45

Calls 5

calculate_percentMethod · 0.80
draw_titleMethod · 0.80
animation_endMethod · 0.80
draw_axes_and_gridMethod · 0.45
draw_channelsMethod · 0.45

Tested by

no test coverage detected