math_animation/
math_animation.rs1use motion_canvas_rs::prelude::*;
2use std::time::Duration;
3
4fn main() {
5 let mut project = Project::default()
7 .with_fps(60)
8 .with_dimensions(500, 500)
9 .with_title("Math Animation")
10 .close_on_finish();
11
12 let tex = MathNode::default()
14 .with_position(Vec2::new(250.0, 250.0))
15 .with_equation("y = a x^2")
16 .with_font_size(48.0)
17 .with_fill(Color::rgb8(0xf2, 0xf2, 0xf2));
18 project.scene.add(Box::new(tex.clone()));
19
20 project.scene.video_timeline.add(loop_anim(
22 move || {
23 chain![
24 tex.tex("y = a x^2 + b x", Duration::from_secs(1)),
25 tex.tex("e^(i pi) + 1 = 0", Duration::from_secs(1)),
26 tex.tex("y = a x^2", Duration::from_secs(1)),
27 ]
28 },
29 None,
30 ));
31
32 project.show().expect("Failed to render");
34}