1use motion_canvas_rs::prelude::*;
2use std::time::Duration;
3
4fn main() {
5 let mut project = Project::default()
6 .with_dimensions(600, 600)
7 .with_title("Images")
8 .close_on_finish();
9
10 let png = ImageNode::default()
12 .with_position(Vec2::new(450.0, 450.0))
13 .with_path("./examples/images/motion-canvas-logo.png")
14 .with_size(Vec2::new(200.0, 200.0));
15
16 let svg = ImageNode::default()
17 .with_position(Vec2::new(150.0, 150.0))
18 .with_path("./examples/images/motion-canvas-rs.svg")
19 .with_size(Vec2::new(200.0, 200.0));
20
21 project.scene.add(Box::new(png.clone()));
22 project.scene.add(Box::new(svg.clone()));
23
24 const MOVE_DUR: Duration = Duration::from_secs(2);
25
26 project.scene.video_timeline.add(loop_anim(
27 move || {
28 with_easing(
29 bounce_out,
30 vec![chain![
31 all!(
32 png.position.to(Vec2::new(150.0, 450.0), MOVE_DUR),
33 svg.position.to(Vec2::new(450.0, 150.0), MOVE_DUR),
34 ),
35 all!(
36 png.position.to(Vec2::new(150.0, 150.0), MOVE_DUR),
37 svg.position.to(Vec2::new(450.0, 450.0), MOVE_DUR),
38 ),
39 all!(
40 png.position.to(Vec2::new(450.0, 150.0), MOVE_DUR),
41 svg.position.to(Vec2::new(150.0, 450.0), MOVE_DUR),
42 ),
43 all!(
44 png.position.to(Vec2::new(450.0, 450.0), MOVE_DUR),
45 svg.position.to(Vec2::new(150.0, 150.0), MOVE_DUR),
46 ),
47 ]],
48 )
49 },
50 None,
51 ));
52
53 project.show().expect("Failed to render");
54}