aboutsummaryrefslogtreecommitdiff
path: root/src/render/processing.rs
diff options
context:
space:
mode:
Diffstat (limited to 'src/render/processing.rs')
-rw-r--r--src/render/processing.rs24
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(