1use motion_canvas_rs::prelude::*;
2
3fn main() {
4 let mut project = Project::default()
5 .with_dimensions(800, 300)
6 .with_title("Shapes");
7
8 let y_shapes = 150.0;
10 let y_labels = 50.0;
11 let spacing = 180.0;
12 let x_start = 130.0;
13
14 let circle_text = TextNode::default()
16 .with_text("Circle")
17 .with_position(Vec2::new(x_start, y_labels))
18 .with_anchor(Vec2::ZERO)
19 .with_font_size(24.0)
20 .with_fill(Color::DIM_GRAY);
21 let circle = Circle::default()
22 .with_position(Vec2::new(x_start, y_shapes))
23 .with_radius(50.0)
24 .with_fill(Color::rgb8(0xe1, 0x32, 0x38));
25
26 let x_rect = x_start + spacing;
28 let rect_text = TextNode::default()
29 .with_text("Rect")
30 .with_position(Vec2::new(x_rect, y_labels))
31 .with_anchor(Vec2::ZERO)
32 .with_font_size(24.0)
33 .with_fill(Color::DIM_GRAY);
34 let rect = Rect::default()
35 .with_position(Vec2::new(x_rect, y_shapes))
36 .with_size(Vec2::new(100.0, 100.0))
37 .with_radius(8.0)
38 .with_fill(Color::rgb8(0x68, 0xab, 0xdf));
39
40 let x_line = x_rect + spacing;
42 let line_text = TextNode::default()
43 .with_text("Line")
44 .with_position(Vec2::new(x_line, y_labels))
45 .with_anchor(Vec2::ZERO)
46 .with_font_size(24.0)
47 .with_fill(Color::DIM_GRAY);
48 let line = Line::default()
49 .with_position(Vec2::new(x_line, y_shapes))
50 .with_start(Vec2::new(-50.0, 50.0))
51 .with_end(Vec2::new(50.0, -50.0))
52 .with_stroke(Color::WHITE, 4.0);
53
54 let x_poly = x_line + spacing;
56 let poly_text = TextNode::default()
57 .with_text("Poly")
58 .with_position(Vec2::new(x_poly, y_labels))
59 .with_anchor(Vec2::ZERO)
60 .with_font_size(24.0)
61 .with_fill(Color::DIM_GRAY);
62 let poly = Polygon::regular(5, 50.0)
63 .with_position(Vec2::new(x_poly, y_shapes))
64 .with_fill(Color::rgb8(0xe6, 0xa7, 0x00));
65
66 project.scene.add(Box::new(circle));
68 project.scene.add(Box::new(circle_text));
69 project.scene.add(Box::new(rect));
70 project.scene.add(Box::new(rect_text));
71 project.scene.add(Box::new(line));
72 project.scene.add(Box::new(line_text));
73 project.scene.add(Box::new(poly));
74 project.scene.add(Box::new(poly_text));
75
76 project.show().expect("Failed to render");
77}