-
Notifications
You must be signed in to change notification settings - Fork 32
/
image.rs
86 lines (84 loc) · 2.52 KB
/
image.rs
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
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
use belly::prelude::*;
use bevy::prelude::*;
fn main() {
App::new()
.add_plugins(DefaultPlugins)
.add_plugins(BellyPlugin)
.add_systems(Startup, setup)
.run();
}
fn setup(mut commands: Commands) {
commands.spawn(Camera2dBundle::default());
let img = commands.spawn_empty().id();
commands.add(StyleSheet::parse(
r#"
body {
flex-wrap: no-wrap;
flex-direction: column;
align-content: center;
align-items: center;
justify-content: center;
padding: 20px;
}
img {
width: 50%;
height: 70%;
background-color: grey;
margin-bottom: 20px;
}
.group {
width: 600px;
align-content: center;
align-items: center;
}
.group .sliders {
flex-grow: 1.0;
justify-content: space-around;
}
slider {
width: 150px;
}
buttongroup button {
flex-grow: 1.0;
color: black;
}
.red .range-low {
background-color: #F54C36;
}
.green .range-low {
background-color: #40B052;
}
.blue .range-low {
background-color: #69A1F5;
}
.header {
min-width: 90px;
}
"#,
));
commands.add(eml! {
<body>
<img {img} src="icon.png" mode="fit"/>
<buttongroup bind:value=to!(img, Img:mode) c:group>
<span c:header>"Mode:"</span>
<for mode in = &["fit", "cover", "stretch", "source"]>
<button value=mode>{mode}</button>
</for>
</buttongroup>
<buttongroup bind:value=to!(img, Img:src) c:group>
<span c:header>"Source:"</span>
<button value="icon.png">"Bevy icon"</button>
<button value="bevy_logo_light.png">"Bevy logo light"</button>
<button pressed value="bevy_logo_dark.png">"Bevy logo dark"</button>
</buttongroup>
<span c:group>
<span c:header>"Modulate:"</span>
<span c:sliders>
<slider c:red value=1.0 bind:value=to!(img, Img:modulate|r)/>
<slider c:green value=1.0 bind:value=to!(img, Img:modulate|g)/>
<slider c:blue value=1.0 bind:value=to!(img, Img:modulate|b)/>
</span>
</span>
</body>
});
}