diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 0408761d80f4f4cd8e89400a9b843019fe8c9be9..ae643935d064c8c6180644259d97d629dc5e14d7 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -68,3 +68,17 @@ build-windows: rules: - if: $CI_COMMIT_BRANCH == $CI_DEFAULT_BRANCH - when: manual + +pages: + image: node:18-alpine + script: + - cd docs + - npm ci + - npm run build + artifacts: + paths: + - docs/_book + expire_in: 4 days + rules: + - if: $CI_COMMIT_BRANCH == $CI_DEFAULT_BRANCH + - when: manual \ No newline at end of file diff --git a/Cargo.lock b/Cargo.lock index 8aa84c630e4df8adfe37235de85712ef3143fd2d..7e53c655d9a03ace3fe59cdb7091b8103e5d6e4a 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -173,7 +173,7 @@ dependencies = [ ] [[package]] -name = "crunch" +name = "crunch-cli" version = "0.5.0" dependencies = [ "anyhow", diff --git a/src/cli_args.rs b/src/cli_args.rs index 2b9de39afc9b6450514f109e40c38cf2f4add2ee..5d0df2cf943f62f14ecae56ac68fab01bbf9ef57 100644 --- a/src/cli_args.rs +++ b/src/cli_args.rs @@ -1,4 +1,5 @@ use clap::Parser; +use image::ImageFormat; use serde::{Deserialize, Serialize}; // use crate::commands::{calculate_mapping, execute_pipeline, extrude, flip, palette, remap_image, rescale, rotate, write_palette, FlipDirection, RotateDegree, Rotate}; @@ -51,14 +52,14 @@ impl Args { let image = load_image(&rotate.input, None)?; let output = rotate.run(&image)?; output - .save(rotate.output.as_str()) + .save_with_format(&rotate.output, ImageFormat::Png) .map_err(anyhow::Error::from) } Args::Extrude(extrude) => { let image = load_image(&extrude.input, None)?; let output = extrude.run(&image)?; output - .save(extrude.output.as_str()) + .save_with_format(&extrude.output, ImageFormat::Png) .map_err(anyhow::Error::from) } Args::Palette(palette) => { @@ -69,14 +70,14 @@ impl Args { let image = load_image(&scale.input, None)?; let output = scale.run(&image)?; output - .save(scale.output.as_str()) + .save_with_format(&scale.output, ImageFormat::Png) .map_err(anyhow::Error::from) } Args::Flip(flip) => { let image = load_image(&flip.input, None)?; let output = flip.run(&image)?; output - .save(flip.output.as_str()) + .save_with_format(&flip.output, ImageFormat::Png) .map_err(anyhow::Error::from) } Args::Remap(remap) => { @@ -89,7 +90,9 @@ impl Args { let mappings = Palette::calculate_mapping(&image_palette, &target_palette); let output = Remap::remap_image(image_data, mappings)?; - output.save(&remap.output).map_err(anyhow::Error::from) + output + .save_with_format(&remap.output, ImageFormat::Png) + .map_err(anyhow::Error::from) } Args::Reduce(reduce) => { if let Some(amount) = reduce.colours { diff --git a/src/commands/extrude.rs b/src/commands/extrude.rs index 6559cea8667aaa1b5b49176a565b111ab5b3c528..fdff8c9969d9c6d38cd1d263de04b11e08a746e4 100644 --- a/src/commands/extrude.rs +++ b/src/commands/extrude.rs @@ -21,27 +21,23 @@ pub struct Extrude { #[serde(default)] pub output: String, - /// The amount of horizontal padding to add between each sprite in the image - #[clap(long, default_value_t = 0)] + /// The amount of horizontal space to add between each sprite in the image + #[clap(short = 'x', long, default_value_t = 0)] #[serde(default)] space_x: u32, - /// The amount of vertical padding to add between each sprite in the image - #[clap(long, default_value_t = 0)] + /// The amount of vertical space to add between each sprite in the image + #[clap(short = 'y', long, default_value_t = 0)] #[serde(default)] space_y: u32, - /// The amount of horizontal padding to add between each sprite in the image - #[clap(long, default_value_t = 0)] + /// The amount of padding to add around the edge of the spritesheet + #[clap(short, long, default_value_t = 0)] #[serde(default)] - pad_x: u32, - /// The amount of vertical padding to add between each sprite in the image - #[clap(long, default_value_t = 0)] - #[serde(default)] - pad_y: u32, + padding: u32, /// The size of each tile in the spritesheet. Assumed to be square tiles #[clap(short, long, default_value_t = 32)] #[serde(default = "tile_size")] tile_size: u32, - /// Use nearby pixels for padding + /// Use nearby pixels for spacing #[clap(short, long)] #[serde(default)] extrude: bool, @@ -80,8 +76,8 @@ impl Extrude { } } - let new_width = (self.pad_x * 2 + self.space_x * columns) + image.width(); - let new_height = (self.pad_y * 2 + self.space_y * rows) + image.height(); + let new_width = (self.padding * 2 + self.space_x * columns) + image.width(); + let new_height = (self.padding * 2 + self.space_y * rows) + image.height(); log::info!( "Using new image width {} / height {}", @@ -109,8 +105,8 @@ impl Extrude { ]); new_image.put_pixel( - self.pad_x + (sprite.tx * self.space_x) + img_x + x, - self.pad_y + (sprite.ty * self.space_y) + img_y + y, + self.padding + (sprite.tx * self.space_x) + img_x + x, + self.padding + (sprite.ty * self.space_y) + img_y + y, p, ); } diff --git a/src/commands/flip.rs b/src/commands/flip.rs index 19ac07367c67a0eeb02fc2c146a52c7bb54ac9a9..98b5375b230ddf59f3d5b3c47340b296c0a208d0 100644 --- a/src/commands/flip.rs +++ b/src/commands/flip.rs @@ -25,7 +25,7 @@ pub struct Flip { pub output: String, /// The axis along which the image should be flipped - #[clap(long, value_enum)] + #[clap(short, long, value_enum)] direction: FlipDirection, } diff --git a/src/commands/scale.rs b/src/commands/scale.rs index 5f3b2c8fd18c42b5a9f02da5c47268fe8b4807f5..256be4754bc42f2d5cc91bb13e56f788aed8e42a 100644 --- a/src/commands/scale.rs +++ b/src/commands/scale.rs @@ -21,7 +21,7 @@ pub struct Scale { pub output: String, /// The scale factor to use; numbers between 0-1 shrink the image; numbers > 1 enlarge - #[clap(long, default_value_t = 1.0)] + #[clap(short, long, default_value_t = 1.0)] #[serde(default = "one")] factor: f32, }