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
use super::*;
#[derive(Clone, Copy, Debug, Default, PartialEq)]
#[cfg_attr(feature = "persistence", derive(serde::Deserialize, serde::Serialize))]
pub struct Shadow {
pub extrusion: f32,
pub color: Color32,
}
impl Shadow {
pub fn small_dark() -> Self {
Self {
extrusion: 16.0,
color: Color32::from_black_alpha(96),
}
}
pub fn small_light() -> Self {
Self {
extrusion: 16.0,
color: Color32::from_black_alpha(32),
}
}
pub fn big_dark() -> Self {
Self {
extrusion: 32.0,
color: Color32::from_black_alpha(96),
}
}
pub fn big_light() -> Self {
Self {
extrusion: 32.0,
color: Color32::from_black_alpha(40),
}
}
pub fn tessellate(&self, rect: emath::Rect, corner_radius: f32) -> Mesh {
let Self { extrusion, color } = *self;
use crate::tessellator::*;
let rect = PaintRect {
rect: rect.expand(0.5 * extrusion),
corner_radius: corner_radius + 0.5 * extrusion,
fill: color,
stroke: Default::default(),
};
let mut tessellator = Tessellator::from_options(TessellationOptions {
aa_size: extrusion,
anti_alias: true,
..Default::default()
});
let mut mesh = Mesh::default();
tessellator.tessellate_rect(&rect, &mut mesh);
mesh
}
}