use motion_canvas_rs::prelude::*;
use std::time::Duration;

fn main() {
    // 1. Initialize Project
    let mut project = Project::default()
        .with_fps(60)
        .with_dimensions(500, 500)
        .with_title("Math Animation")
        .close_on_finish();

    // 2. Create MathNode (Typst syntax)
    let tex = MathNode::default()
        .with_position(Vec2::new(250.0, 250.0))
        .with_equation("y = a x^2")
        .with_font_size(48.0)
        .with_fill(Color::rgb8(0xf2, 0xf2, 0xf2));
    project.scene.add(Box::new(tex.clone()));

    // 3. Define Animation Sequence
    project.scene.video_timeline.add(loop_anim(
        move || {
            chain![
                tex.tex("y = a x^2 + b x", Duration::from_secs(1)),
                tex.tex("e^(i pi) + 1 = 0", Duration::from_secs(1)),
                tex.tex("y = a x^2", Duration::from_secs(1)),
            ]
        },
        None,
    ));

    // 4. Run interactive preview
    project.show().expect("Failed to render");
}
