diff options
author | metamuffin <metamuffin@disroot.org> | 2025-09-29 23:56:14 +0200 |
---|---|---|
committer | metamuffin <metamuffin@disroot.org> | 2025-09-30 01:19:09 +0200 |
commit | 727752b87bbe7146adb0f9e9e27d6e64b785ec2f (patch) | |
tree | ec51a98bb0f3334e66690484db497709d9d48eb4 /pixel-client/tools/src/bin/tex_pack.rs | |
parent | bd52f4617d04d9b3cda279d48fc75d5a067101fe (diff) | |
download | hurrycurry-727752b87bbe7146adb0f9e9e27d6e64b785ec2f.tar hurrycurry-727752b87bbe7146adb0f9e9e27d6e64b785ec2f.tar.bz2 hurrycurry-727752b87bbe7146adb0f9e9e27d6e64b785ec2f.tar.zst |
Remove pixel client
Diffstat (limited to 'pixel-client/tools/src/bin/tex_pack.rs')
-rw-r--r-- | pixel-client/tools/src/bin/tex_pack.rs | 95 |
1 files changed, 0 insertions, 95 deletions
diff --git a/pixel-client/tools/src/bin/tex_pack.rs b/pixel-client/tools/src/bin/tex_pack.rs deleted file mode 100644 index ccb8caee..00000000 --- a/pixel-client/tools/src/bin/tex_pack.rs +++ /dev/null @@ -1,95 +0,0 @@ -/* - Hurry Curry! - a game about cooking - Copyright (C) 2025 Hurry Curry! Contributors - - This program is free software: you can redistribute it and/or modify - it under the terms of the GNU Affero General Public License as published by - the Free Software Foundation, version 3 of the License only. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU Affero General Public License for more details. - - You should have received a copy of the GNU Affero General Public License - along with this program. If not, see <https://www.gnu.org/licenses/>. - -*/ -use clap::Parser; -use std::{ - fs::File, - io::{BufRead, BufReader, BufWriter, Write}, - path::PathBuf, -}; - -#[derive(Parser)] -struct Args { - atlas_out: PathBuf, - atlas_meta_out: PathBuf, - inputs: Vec<PathBuf>, -} - -fn main() { - let Args { - inputs, - atlas_meta_out, - atlas_out, - } = Args::parse(); - - let atlas_size = 1024; - - let mut cursor_x = 0; - let mut cursor_y = 0; - let mut row_height = 0; - - let mut texels = vec![vec![' '; atlas_size]; atlas_size]; - let mut metadata = Vec::new(); - - println!(" savepack {atlas_out:?}"); - for path in inputs { - let file = BufReader::new(File::open(&path).unwrap()); - let tex = file.lines().map(Result::unwrap).collect::<Vec<String>>(); - let name = path.file_stem().unwrap().to_str().unwrap().to_string(); - let (width, height) = (tex[0].chars().count(), tex.len()); - - println!(" + {width}x{height} {name}"); - - if cursor_x + width > atlas_size { - cursor_y += row_height; - row_height = 0; - cursor_x = 0; - } - if cursor_y + height > atlas_size { - panic!("texture too big or atlas full"); - } - row_height = row_height.max(height); - let texcoord = [cursor_x, cursor_y, width, height]; - - for (y, line) in tex.iter().enumerate() { - if line.is_empty() { - continue; - } - for (x, char) in line.chars().enumerate() { - texels[cursor_y + y][cursor_x + x] = char; - } - } - - metadata.push((texcoord, name)); - - cursor_x += width; - } - - let mut atlas_out = BufWriter::new(File::create(atlas_out).unwrap()); - let mut atlas_meta_out = BufWriter::new(File::create(atlas_meta_out).unwrap()); - - for line in texels { - for char in line { - write!(atlas_out, "{char}").unwrap() - } - writeln!(atlas_out).unwrap(); - } - - for ([x, y, w, h], name) in metadata { - writeln!(atlas_meta_out, "{x},{y},{w},{h},{name}").unwrap(); - } -} |