mindustry logic execution, map- and schematic- parsing and rendering
Diffstat (limited to 'src/utils/image.rs')
| -rw-r--r-- | src/utils/image.rs | 14 |
1 files changed, 14 insertions, 0 deletions
diff --git a/src/utils/image.rs b/src/utils/image.rs new file mode 100644 index 0000000..50a4cf7 --- /dev/null +++ b/src/utils/image.rs @@ -0,0 +1,14 @@ +use image::{Rgb, Rgba, RgbaImage}; + +pub fn tint(image: &mut RgbaImage, color: Rgb<u8>) { + let [tr, tg, tb] = [ + color[0] as f32 / 255.0, + color[1] as f32 / 255.0, + color[2] as f32 / 255.0, + ]; + for Rgba([r, g, b, _]) in image.pixels_mut() { + *r = (*r as f32 * tr) as u8; + *g = (*g as f32 * tg) as u8; + *b = (*b as f32 * tb) as u8; + } +} |