mirror of
https://github.com/neocturne/MinedMap.git
synced 2025-07-03 06:09:07 +02:00
minedmap: move some internal functions out of impl blocks
This commit is contained in:
parent
1a5e8894fe
commit
2dd9283d95
2 changed files with 30 additions and 28 deletions
|
@ -6,6 +6,19 @@ use minedmap::{io::storage, resource::Biome, types::*, world};
|
|||
|
||||
use super::common::*;
|
||||
|
||||
fn block_color(block: &world::layer::BlockInfo, _biome: &Biome) -> [u8; 4] {
|
||||
let h = block
|
||||
.depth
|
||||
.map(|depth| 0.5 + 0.005 * depth.0 as f32)
|
||||
.unwrap_or_default();
|
||||
let c = block
|
||||
.block_type
|
||||
.color
|
||||
.0
|
||||
.map(|v| (f32::from(v) * h).clamp(0.0, 255.0) as u8);
|
||||
[c[0], c[1], c[2], 255]
|
||||
}
|
||||
|
||||
pub struct TileRenderer<'a> {
|
||||
config: &'a Config,
|
||||
}
|
||||
|
@ -20,19 +33,6 @@ impl<'a> TileRenderer<'a> {
|
|||
storage::read(&processed_path).context("Failed to load processed region data")
|
||||
}
|
||||
|
||||
fn block_color(block: &world::layer::BlockInfo, _biome: &Biome) -> [u8; 4] {
|
||||
let h = block
|
||||
.depth
|
||||
.map(|depth| 0.5 + 0.005 * depth.0 as f32)
|
||||
.unwrap_or_default();
|
||||
let c = block
|
||||
.block_type
|
||||
.color
|
||||
.0
|
||||
.map(|v| (f32::from(v) * h).clamp(0.0, 255.0) as u8);
|
||||
[c[0], c[1], c[2], 255]
|
||||
}
|
||||
|
||||
fn render_chunk(
|
||||
image: &mut image::RgbaImage,
|
||||
coords: ChunkCoords,
|
||||
|
@ -47,7 +47,7 @@ impl<'a> TileRenderer<'a> {
|
|||
z: BlockZ(z as u8),
|
||||
};
|
||||
image::Rgba(match (&blocks[coords], &biomes[coords]) {
|
||||
(Some(block), Some(biome)) => Self::block_color(block, biome),
|
||||
(Some(block), Some(biome)) => block_color(block, biome),
|
||||
_ => [0, 0, 0, 0],
|
||||
})
|
||||
});
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue