sunset theme.xml in favor of globals
This commit is contained in:
@@ -125,6 +125,25 @@ impl Color {
|
||||
pub fn debug_ansi_block(&self) -> String {
|
||||
format!("{}███{}", self.debug_ansi_format(), ANSI_RESET_CODE)
|
||||
}
|
||||
|
||||
#[must_use]
|
||||
pub fn with_alpha(&self, n: f32) -> Self {
|
||||
Self {
|
||||
r: self.r,
|
||||
g: self.g,
|
||||
b: self.b,
|
||||
a: n,
|
||||
}
|
||||
}
|
||||
|
||||
#[must_use]
|
||||
pub fn to_hex(&self) -> String {
|
||||
let r = (self.r.clamp(0.0, 1.0) * 255.0).round() as u8;
|
||||
let g = (self.g.clamp(0.0, 1.0) * 255.0).round() as u8;
|
||||
let b = (self.b.clamp(0.0, 1.0) * 255.0).round() as u8;
|
||||
let a = (self.a.clamp(0.0, 1.0) * 255.0).round() as u8;
|
||||
format!("#{r:02X}{g:02X}{b:02X}{a:02X}")
|
||||
}
|
||||
}
|
||||
|
||||
impl Default for Color {
|
||||
|
||||
Reference in New Issue
Block a user