diff options
author | metamuffin <metamuffin@disroot.org> | 2022-10-17 19:48:45 +0200 |
---|---|---|
committer | metamuffin <metamuffin@disroot.org> | 2022-10-17 19:48:45 +0200 |
commit | d55dc04fd9f223ada252a6d9e71cabde5f6dd355 (patch) | |
tree | 5e9859d45e43567e373ac896657b89998b52160c /src/render/processing.rs | |
parent | b58c29c734978766db2c86acb436ca9425491b99 (diff) | |
download | trash-map-d55dc04fd9f223ada252a6d9e71cabde5f6dd355.tar trash-map-d55dc04fd9f223ada252a6d9e71cabde5f6dd355.tar.bz2 trash-map-d55dc04fd9f223ada252a6d9e71cabde5f6dd355.tar.zst |
works
Diffstat (limited to 'src/render/processing.rs')
-rw-r--r-- | src/render/processing.rs | 24 |
1 files changed, 21 insertions, 3 deletions
diff --git a/src/render/processing.rs b/src/render/processing.rs index 451fab3..7c35736 100644 --- a/src/render/processing.rs +++ b/src/render/processing.rs @@ -8,6 +8,20 @@ pub fn biome_tint(s: &Texture) -> Texture { tint(s, (100, 200, 50)) } +pub fn adjust_alpha(fac: u8, source: &Texture) -> Texture { + let mut t = ImageBuffer::new(16, 16); + for (x, y, p) in t.enumerate_pixels_mut() { + let sp = source.get_pixel(x, y); + *p = Rgba::from([ + sp.0[0], + sp.0[1], + sp.0[2], + ((sp.0[3] as u16 * fac as u16) / 255) as u8, + ]) + } + return t; +} + pub fn tint(source: &Texture, tint: (u16, u16, u16)) -> Texture { let mut t = ImageBuffer::new(16, 16); for (x, y, p) in t.enumerate_pixels_mut() { @@ -33,15 +47,19 @@ pub fn crop16(tex: &Texture) -> Texture { pub fn transparent() -> Texture { let mut t = ImageBuffer::new(16, 16); - for (_,_,p) in t.enumerate_pixels_mut() { - *p = Rgba::from([0,0,0,255]) + for (_, _, p) in t.enumerate_pixels_mut() { + *p = Rgba::from([0, 0, 0, 255]) } return t; } pub fn block_texture(block_name: &str) -> Texture { image::open(&Path::new( - format!("./assets/assets/minecraft/textures/block/{}.png", block_name).as_str(), + format!( + "./assets/assets/minecraft/textures/block/{}.png", + block_name + ) + .as_str(), )) .unwrap_or_else(|_err| { image::open(&Path::new( |