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

Fix arguments for some commands, fix output format

parent e49c3faf
No related branches found
No related tags found
No related merge requests found
Pipeline #334 waiting for manual action with stages
in 44 seconds
......@@ -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
......@@ -173,7 +173,7 @@ dependencies = [
]
[[package]]
name = "crunch"
name = "crunch-cli"
version = "0.5.0"
dependencies = [
"anyhow",
......
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 {
......
......@@ -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,
);
}
......
......@@ -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,
}
......
......@@ -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,
}
......
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