1use std::f64::consts::PI;
2
3use glam::DVec3;
4use ranim::{
5 animation::{
6 creation::WritingAnimSchedule, fading::FadingAnimSchedule, transform::TransformAnimSchedule,
7 },
8 color::palettes::manim,
9 items::vitem::{Circle, Square},
10 prelude::*,
11};
12
13#[scene]
14struct HelloRanimScene;
15
16impl TimelineConstructor for HelloRanimScene {
17 fn construct(self, timeline: &RanimTimeline, _camera: &mut Rabject<CameraFrame>) {
18 let mut square = Square(2.0).build();
19 square.set_color(manim::BLUE_C);
20
21 let mut square = timeline.insert(square);
22 let mut circle = Circle(2.0).build();
23 circle.rotate(PI / 4.0 + PI, DVec3::Z);
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