aboutsummaryrefslogtreecommitdiff
path: root/src/lib.rs
diff options
context:
space:
mode:
Diffstat (limited to 'src/lib.rs')
-rw-r--r--src/lib.rs20
1 files changed, 20 insertions, 0 deletions
diff --git a/src/lib.rs b/src/lib.rs
index 2ee23d7b..684e89af 100644
--- a/src/lib.rs
+++ b/src/lib.rs
@@ -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 {