1use ranim::{
2 animation::{
3 creation::WritingAnimSchedule, fading::FadingAnimSchedule, transform::TransformAnimSchedule,
4 },
5 color::palettes::manim,
6 items::vitem::{Circle, Square},
7 prelude::*,
8};
9
10#[scene]
11struct HelloRanimScene;
12
13impl TimelineConstructor for HelloRanimScene {
14 fn construct<'t: 'r, 'r>(
15 self,
16 timeline: &'t RanimTimeline,
17 _camera: &'r mut Rabject<'t, CameraFrame>,
18 ) {
19 let mut square = Square(2.0).build();
20 square.set_color(manim::BLUE_C);
21
22 let mut square = timeline.insert(square);
23 let mut circle = Circle(2.0).build();
24 circle.set_color(manim::RED_C);
25
26 timeline.play(square.transform_to(circle).apply()); // Use `apply` on an anim schedule to update rabject data
27 timeline.play(square.unwrite()); // Do not use `apply` to keep the data in Rabject not changed
28 timeline.play(square.write());
29 timeline.play(square.fade_out());
30 }
31}
32
33fn main() {
34 #[cfg(feature = "app")]
35 run_scene_app(HelloRanimScene);
36 #[cfg(not(feature = "app"))]
37 {
38 render_scene(HelloRanimScene, &AppOptions::default());
39 render_scene_at_sec(HelloRanimScene, 0.0, "preview.png", &AppOptions::default());
40 }
41}
42