Feature: width argument to calculate scale from number of available columns #6

Merged
giulio-Joshi merged 3 commits from columns_arg into master 2022-10-26 19:36:21 +00:00
3 changed files with 3 additions and 5 deletions
Showing only changes of commit e108a1875e - Show all commits

View file

@ -106,10 +106,7 @@ Options:
[default: 4] [default: 4]
-w, --width <WIDTH> -w, --width <WIDTH>
anas-elgarhy commented 2022-10-26 16:25:48 +00:00 (Migrated from github.com)
Review

Please copy this from the aarty --help output to save the consistency

Please copy this from the `aarty --help` output to save the consistency
Width expressed as text-columns, this parameter will calculate the scale factor for you. Enstablish how much wide is the output images, in columns. Overrides `scale`
Overrides `scale` parameter even when specified.
[default: disabled]
-b, --background <BACKGROUND> -b, --background <BACKGROUND>
The background color to use The background color to use

View file

@ -19,7 +19,7 @@ pub mod args {
/// The output scale (1 is the original size) /// The output scale (1 is the original size)
#[arg(short, long, default_value = "4")] #[arg(short, long, default_value = "4")]
pub scale: u32, pub scale: u32,
// Enstablish how much wide is the output images, in columns. Overrides `scale` /// Enstablish how much wide is the output images, in columns. Overrides `scale`
#[arg(short, long, default_value= None )] #[arg(short, long, default_value= None )]
pub width: Option<u32>, pub width: Option<u32>,
/// The background color to use /// The background color to use

View file

@ -66,6 +66,7 @@ fn get_character(
/// Determine how much scale to use in presence of `width` parameters, /// Determine how much scale to use in presence of `width` parameters,
/// otherwise returns regular `scale` parameter per default behaviour /// otherwise returns regular `scale` parameter per default behaviour
/// ///
#[inline]
fn calculate_scale(args: &Arguments, dimensions: (u32, u32)) -> u32 { fn calculate_scale(args: &Arguments, dimensions: (u32, u32)) -> u32 {
args.width.map_or_else(|| args.scale, |v| dimensions.0 / v) args.width.map_or_else(|| args.scale, |v| dimensions.0 / v)
} }