返回 CodeWhale
appearance.rs
根目录 / crates / tui / src / tui / pet_watch / appearance.rs
1 //! Presentation preferences never enter the simulation or its replay journal.
2 use serde::{Deserialize, Serialize};
3 #[derive(Clone, Debug, PartialEq, Serialize, Deserialize)]
4 #[serde(rename_all = "camelCase", deny_unknown_fields)]
5 pub struct Appearance {
6 pub background: [u8; 3],
7 pub background_top: [u8; 3],
8 pub particle: [u8; 3],
9 pub event_colors: bool,
10 pub brightness: f64,
11 pub dot_scale: f64,
12 pub glow: f64,
13 pub environment: bool,
14 }
15 impl Default for Appearance {
16 fn default() -> Self {
17 Self {
18 background: [8, 15, 21],
19 background_top: [24, 45, 56],
20 particle: [135, 221, 219],
21 event_colors: true,
22 brightness: 1.25,
23 dot_scale: 1.0,
24 glow: 0.5,
25 environment: true,
26 }
27 }
28 }
29 impl Appearance {
30 pub fn valid(&self) -> bool {
31 self.brightness.is_finite()
32 && (0.25..=2.0).contains(&self.brightness)
33 && self.dot_scale.is_finite()
34 && (0.65..=1.8).contains(&self.dot_scale)
35 && self.glow.is_finite()
36 && (0.0..=1.0).contains(&self.glow)
37 }
38 }
39
39 lines RUST