diff options
author | Rosyid Haryadi <rosyid_haryadi@protonmail.com> | 2025-02-26 14:44:11 +0700 |
---|---|---|
committer | Rosyid Haryadi <rosyid_haryadi@protonmail.com> | 2025-02-26 14:44:11 +0700 |
commit | 7b0375eee4a945cc8fbb3c03cfc0657e0f1ee443 (patch) | |
tree | 6dd01fb883b806ef540a40b1c8ae26a0b81f967f /src/global.rs | |
parent | 20be72c501397a45e3c8f4bc95a3451f103e3a28 (diff) |
upd: mapping 0-1 to byte
Diffstat (limited to 'src/global.rs')
-rw-r--r-- | src/global.rs | 10 |
1 files changed, 10 insertions, 0 deletions
diff --git a/src/global.rs b/src/global.rs index cb616b1..3a1e329 100644 --- a/src/global.rs +++ b/src/global.rs @@ -8,6 +8,16 @@ pub struct Pixel { pub b: u8, } +impl Pixel { + pub fn from_frac(r: f32, g: f32, b: f32) -> Self { + Self { + r: (255.999 * r) as u8, + g: (255.999 * g) as u8, + b: (255.999 * b) as u8, + } + } +} + impl Default for Pixel { fn default() -> Self { Pixel { r:0, g:0, b:0 } |