Skip to content
Snippets Groups Projects
Verified Commit f5ca59c7 authored by Louis's avatar Louis :fire:
Browse files

Add area flag to atlas command

parent 6b36f46f
No related branches found
No related tags found
No related merge requests found
Pipeline #603 passed with stages
in 3 minutes
# Changelog
All notable changes to this project will be documented in this file.
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
## [0.8.0]
## [0.8.1] - 2024-04-28
### Added
- Support spritesheet generation in `atlas` command by specifying sprite `--area`
### Changed
- `atlas` args short form changed from `w` and `h` to `x` and `y` to specify max output width, to
prevent collision with built in help command
## [0.8.0]
### Added
- Support non-square tiles in `split` command with `-w` and `-h` flags
## [0.7.0]
### Added
- Support for `--extrude` param in `extrude` command
## [0.5.0] - 2023-02-22
### Added
- `split` command for taking a sprite sheet and converting it into individual tiles
### Changed
- Moved all arguments into subcommands, for a less confusing end user experience
## [0.4.0] - 2022-08-08
### Added
- Support for GlobRef definitions in a `pipeline.toml` file
- Takes a `pattern` glob expression instead of an `input_path`
- Takes a directory path as `output_dir` instead of a file path as `output_file`, and will construct the an `output_file` by appending the file name of a matched file to the output directory
- Takes a `pattern` glob expression instead of an `input_path`
- Takes a directory path as `output_dir` instead of a file path as `output_file`, and will construct the
an `output_file` by appending the file name of a matched file to the output directory
### Changed
- All paths in pipelines are now relative to the pipeline configuration file, instead of the current directory
## [0.3.0] - 2022-07-08
### Added
- Added `flip` command, for flipping an image along one or both axes.
- Added `rotate` command to apply a rotation to an image, in steps of 90 degrees.
## [0.2.0]
### Added
- Added `pipeline` command, for applying a series of transformations to an image.
\ No newline at end of file
......@@ -233,7 +233,7 @@ dependencies = [
[[package]]
name = "crunch-cli"
version = "0.8.0"
version = "0.8.1"
dependencies = [
"anyhow",
"clap",
......
[package]
name = "crunch-cli"
version = "0.8.0"
version = "0.8.1"
edition = "2021"
homepage = "https://microhacks.lcr.app/crunch/"
......@@ -9,7 +9,7 @@ repository = "https://lab.lcr.gr/microhacks/crunch"
license = "GPL-3.0"
description = "Command line asset manipulation, set up a pipeline once and run it against all of your files"
authors = [
"Louis Capitanchik <louis@microhacks.co.uk>"
"Louis Capitanchik <louis@microhacks.co.uk>"
]
[[bin]]
......
......@@ -16,7 +16,7 @@ fn default_max_size() -> usize {
/// Given a set of images, create a single atlas image and metadata file containing all of the original
/// set
#[derive(Parser, Serialize, Deserialize, Clone, Debug)]
#[clap(author, version = "0.7.0")]
#[clap(author, version = "0.8.1")]
pub struct Atlas {
/// A pattern evaluating to one or more image files
#[serde(default)]
......@@ -26,12 +26,16 @@ pub struct Atlas {
pub output: String,
/// The maximum width of the output texture
#[serde(default = "default_max_size")]
#[clap(short = 'w', long = "max_width")]
#[clap(short = 'x', long = "max_width")]
pub max_frame_width: usize,
/// The maximum height of the output texture
#[serde(default = "default_max_size")]
#[clap(short = 'h', long = "max_height")]
#[clap(short = 'y', long = "max_height")]
pub max_frame_height: usize,
/// Set a fixed size for each sprite to occupy, creating a fixed grid spritesheet. Sprites must
/// be padded to the correct size before specifying an area
#[clap(short = 'a', long = "area")]
pub area: Option<usize>,
}
#[derive(Copy, Clone, Hash, Eq, PartialEq)]
......@@ -107,7 +111,13 @@ impl Atlas {
let page_content_map: HashMap<usize, Vec<(PathBuf, Rectangle)>> = pattern
.into_iter()
.filter_map(Result::ok)
.flat_map(|path| image_dimensions(&path).map(|(w, h)| (w, h, path)))
.flat_map(|path| {
if let Some(fixed) = &self.area {
Ok((*fixed as u32, *fixed as u32, path))
} else {
image_dimensions(&path).map(|(w, h)| (w, h, path))
}
})
.flat_map(|(w, h, path)| builder.insert(w, h, path))
.collect::<Vec<(AtlasIdent, SliceData)>>()
.into_iter()
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment