1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
//! Test: 3-level nested transforms
//!
//! Run with: cargo run --example transform_test_3level
use guido::prelude::*;
fn main() {
App::new().run(|app| {
app.add_surface(
SurfaceConfig::new()
.height(180)
.anchor(Anchor::TOP | Anchor::LEFT | Anchor::RIGHT)
.background_color(Color::rgb(0.12, 0.12, 0.16)),
move || {
container()
.layout(
Flex::row()
.spacing(60.0)
.main_alignment(MainAlignment::Center),
)
.padding(30.0)
.children([
// Reference: no rotation at any level
three_level(0.0, 0.0, 0.0),
// Only grandparent rotates 20°
three_level(20.0, 0.0, 0.0),
// Each level rotates 10° (total 30°)
three_level(10.0, 10.0, 10.0),
// Grandparent 30°, others 0°
three_level(30.0, 0.0, 0.0),
])
},
);
});
}
fn three_level(gp_rot: f32, p_rot: f32, c_rot: f32) -> Container {
container()
.width(120.0)
.height(120.0)
.background(Color::rgb(0.25, 0.25, 0.35))
.corners(12.0)
.rotate(gp_rot)
.padding(15.0)
.child(
container()
.width(90.0)
.height(90.0)
.background(Color::rgb(0.45, 0.45, 0.55))
.corners(10.0)
.rotate(p_rot)
.padding(12.0)
.child(
container()
.width(50.0)
.height(50.0)
.background(Color::rgb(0.9, 0.6, 0.3))
.corners(6.0)
.rotate(c_rot),
),
)
}