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

fn main() {
    let mut project = Project::default()
        .with_dimensions(600, 600)
        .with_title("Images")
        .close_on_finish();

    // Using the sample logo path from the project
    let png = ImageNode::default()
        .with_position(Vec2::new(450.0, 450.0))
        .with_path("./examples/images/motion-canvas-logo.png")
        .with_size(Vec2::new(200.0, 200.0));

    let svg = ImageNode::default()
        .with_position(Vec2::new(150.0, 150.0))
        .with_path("./examples/images/motion-canvas-rs.svg")
        .with_size(Vec2::new(200.0, 200.0));

    project.scene.add(Box::new(png.clone()));
    project.scene.add(Box::new(svg.clone()));

    const MOVE_DUR: Duration = Duration::from_secs(2);

    project.scene.video_timeline.add(loop_anim(
        move || {
            with_easing(
                bounce_out,
                vec![chain![
                    all!(
                        png.position.to(Vec2::new(150.0, 450.0), MOVE_DUR),
                        svg.position.to(Vec2::new(450.0, 150.0), MOVE_DUR),
                    ),
                    all!(
                        png.position.to(Vec2::new(150.0, 150.0), MOVE_DUR),
                        svg.position.to(Vec2::new(450.0, 450.0), MOVE_DUR),
                    ),
                    all!(
                        png.position.to(Vec2::new(450.0, 150.0), MOVE_DUR),
                        svg.position.to(Vec2::new(150.0, 450.0), MOVE_DUR),
                    ),
                    all!(
                        png.position.to(Vec2::new(450.0, 450.0), MOVE_DUR),
                        svg.position.to(Vec2::new(150.0, 150.0), MOVE_DUR),
                    ),
                ]],
            )
        },
        None,
    ));

    project.show().expect("Failed to render");
}
