diff options
Diffstat (limited to 'src/lib.rs')
-rw-r--r-- | src/lib.rs | 20 |
1 files changed, 20 insertions, 0 deletions
@@ -71,6 +71,8 @@ pub mod tty; pub mod util; pub mod window; +use std::ops::Mul; + pub use grid::Grid; pub use term::Term; @@ -81,6 +83,24 @@ pub struct Rgb { pub b: u8, } +// a multiply function for Rgb, as the default dim is just *2/3 +impl Mul<f32> for Rgb { + type Output = Rgb; + + fn mul(self, rhs: f32) -> Rgb { + let result = Rgb { + r: (self.r as f32 * rhs).max(0.0).min(255.0) as u8, + g: (self.g as f32 * rhs).max(0.0).min(255.0) as u8, + b: (self.b as f32 * rhs).max(0.0).min(255.0) as u8 + }; + + trace!("Scaling RGB by {} from {:?} to {:?}", rhs, self, result); + + result + } +} + + #[cfg_attr(feature = "clippy", allow(too_many_arguments))] #[cfg_attr(feature = "clippy", allow(doc_markdown))] pub mod gl { |