Feature: width
argument to calculate scale from number of available columns
#6
3 changed files with 3 additions and 5 deletions
|
@ -106,10 +106,7 @@ Options:
|
||||||
[default: 4]
|
[default: 4]
|
||||||
|
|
||||||
-w, --width <WIDTH>
|
-w, --width <WIDTH>
|
||||||
|
|||||||
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
|
||||||
|
|
|
@ -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
|
||||||
|
|
|
@ -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)
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue
Please copy this from the
aarty --help
output to save the consistency