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
//! Test: Nested transforms (parent rotation affects child)
//!
//! Run with: cargo run --example transform_test_nested
use guido::prelude::*;
fn main() {
App::new().run(|app| {
app.add_surface(
SurfaceConfig::new()
.height(160)
.anchor(Anchor::TOP | Anchor::LEFT | Anchor::RIGHT)
.background_color(Color::rgb(0.12, 0.12, 0.16)),
move || {
container()
.layout(
Flex::row()
.spacing(40.0)
.main_alignment(MainAlignment::Center),
)
.padding(20.0)
.children([
// Reference: no rotation
nested(0.0, Color::rgb(0.9, 0.5, 0.3)),
// Parent rotated 15°
nested(15.0, Color::rgb(0.3, 0.9, 0.5)),
// Parent rotated 30°
nested(30.0, Color::rgb(0.5, 0.3, 0.9)),
// Parent rotated 45°
nested(45.0, Color::rgb(0.9, 0.9, 0.3)),
])
},
);
});
}
fn nested(parent_rotation: f32, child_color: Color) -> Container {
container()
.width(100.0)
.height(100.0)
.background(Color::rgb(0.3, 0.3, 0.4))
.corners(10.0)
.rotate(parent_rotation)
.padding(20.0)
.child(
container()
.width(60.0)
.height(60.0)
.background(child_color)
.corners(6.0),
)
}