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

Method draw_frame

src/line.rs:861–900  ·  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

859 ///
860 /// If [time] is `null`, draws the last frame (i.e. no animation).
861 fn draw_frame(&self, ctx: &C, time: Option<i64>) {
862 // clear surface
863 self.base.draw_frame(ctx, time);
864
865 self.draw_axes_and_grid(ctx);
866
867 let mut percent = self.base.calculate_percent(time);
868
869 if percent >= 1.0 {
870 percent = 1.0;
871
872 // Update the visibility states of all channel before the last frame.
873 let mut channels = self.base.channels.borrow_mut();
874 for channel in channels.iter_mut() {
875 if channel.state == Visibility::Showing {
876 channel.state = Visibility::Shown;
877 } else if channel.state == Visibility::Hiding {
878 channel.state = Visibility::Hidden;
879 }
880 }
881 }
882
883 let props = self.base.props.borrow();
884
885 let ease = match props.easing {
886 Some(val) => val,
887 None => get_easing(Easing::Linear),
888 };
889
890 self.draw_channels(ctx, ease(percent));
891 // ctx.drawImageScaled(ctx.canvas, 0, 0, width, height);
892 // ctx.drawImageScaled(ctx.canvas, 0, 0, width, height);
893 self.base.draw_title(ctx);
894
895 if percent < 1.0 {
896 // animation_frame_id = window.requestAnimationFrame(draw_frame);
897 } else if time.is_some() {
898 self.base.animation_end();
899 }
900 }
901
902 fn draw_channels(&self, ctx: &C, percent: f64) -> bool {
903 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