-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
add: tiles atlas generation with cli
- Loading branch information
Showing
24 changed files
with
30 additions
and
3 deletions.
There are no files selected for viewing
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,5 @@ | ||
pub mod maps; | ||
pub mod common; | ||
pub mod property; | ||
pub mod environment; | ||
pub mod environment; | ||
pub mod utils; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
use image::{ImageBuffer, Luma}; | ||
|
||
pub fn generate_tiles_atlas(tiles: Vec<ImageBuffer<Luma<u8>, Vec<u8>>>) -> ImageBuffer<Luma<u8>, Vec<u8>> { | ||
const TILE_SIZE: u32 = 256; | ||
const ATLAS_SIZE: u32 = TILE_SIZE * 3; | ||
let mut atlas = ImageBuffer::new(ATLAS_SIZE, ATLAS_SIZE); | ||
let tile_size = 256; | ||
let tiles_per_row = ATLAS_SIZE / tile_size; | ||
for (index, tile) in tiles.iter().enumerate() { | ||
let x = (index as u32 % tiles_per_row) * tile_size; | ||
let y = (index as u32 / tiles_per_row) * tile_size; | ||
for (tile_x, tile_y, pixel) in tile.enumerate_pixels() { | ||
if x + tile_x < ATLAS_SIZE && y + tile_y < ATLAS_SIZE { | ||
atlas.put_pixel(x + tile_x, y + tile_y, *pixel); | ||
} | ||
} | ||
} | ||
atlas | ||
} |