Compare commits

...

56 commits

Author SHA1 Message Date
mergify[bot]
59ff61bcf1
Merge pull request #18 from anas-elgarhy/renovate/clap-4.x
fix(deps): update rust crate clap to 4.3.2
2023-06-08 13:44:08 +00:00
renovate[bot]
fd4efce251
fix(deps): update rust crate clap to 4.3.2 2023-06-05 22:37:29 +00:00
92351bfec8
[deploy] Bump the version 2023-06-03 18:15:55 +03:00
mergify[bot]
6110d36adc
Merge pull request #16 from anas-elgarhy/renovate/log-0.x
fix(deps): update rust crate log to 0.4.18
2023-06-03 15:07:39 +00:00
renovate[bot]
31c5dac6cb
fix(deps): update rust crate log to 0.4.18 2023-06-03 15:06:42 +00:00
mergify[bot]
e06ae70b20
Merge pull request #17 from anas-elgarhy/renovate/pretty_env_logger-0.x
fix(deps): update rust crate pretty_env_logger to 0.5.0
2023-06-03 15:06:28 +00:00
mergify[bot]
69b8f008a9
Merge pull request #15 from anas-elgarhy/renovate/clap-4.x
fix(deps): update rust crate clap to 4.3.1
2023-06-03 15:05:35 +00:00
renovate[bot]
30d4e3a037
fix(deps): update rust crate clap to 4.3.1 2023-06-02 17:41:56 +00:00
renovate[bot]
b25849c0bf
fix(deps): update rust crate pretty_env_logger to 0.5.0 2023-05-28 10:26:03 +00:00
mergify[bot]
6d19281100
Merge pull request #11 from anas-elgarhy/renovate/image-0.x
fix(deps): update rust crate image to 0.24.6
2023-03-31 21:49:21 +00:00
mergify[bot]
e4d0da778b
Merge pull request #12 from anas-elgarhy/renovate/clap-4.x
fix(deps): update rust crate clap to 4.2.1
2023-03-31 21:48:56 +00:00
renovate[bot]
1133be9a5a
fix(deps): update rust crate clap to 4.2.1 2023-03-29 19:27:28 +00:00
renovate[bot]
f6dc9a004a
fix(deps): update rust crate image to 0.24.6 2023-03-25 03:03:19 +00:00
mergify[bot]
8bbc1f7e1d
Merge pull request #14 from anas-elgarhy/renovate/actions-checkout-3.x
chore(deps): update actions/checkout action to v3
2023-01-29 11:35:47 +00:00
renovate[bot]
8e403c87bd
chore(deps): update actions/checkout action to v3 2023-01-28 23:35:09 +00:00
c0b2ff6074
Merge pull request #9 from anas-elgarhy/renovate/configure
Configure Renovate
2023-01-29 01:34:03 +02:00
884d8d504c
Merge pull request #10 from anas-elgarhy/mergify/anas-elgarhy/config-update
ci(Mergify): configuration update
2023-01-29 00:36:54 +02:00
1ad7f8bf03 ci(Mergify): configuration update
Signed-off-by: Anas Elgarhy <anas.elgarhy.dev@gmail.com>
2023-01-29 00:29:33 +02:00
renovate[bot]
9d76b9268d
Add renovate.json 2023-01-28 21:12:54 +00:00
7d84eaa186 Update 2022-11-14 21:28:42 +02:00
fe468ffde0 Update yooo [test workflow only] 2022-11-13 22:20:24 +02:00
ec206cb527 Update yooo [test workflow only] 2022-11-13 19:12:04 +02:00
4867f64768 Update yooo [test workflow only] 2022-11-13 19:02:50 +02:00
4d642d07d2 Update yooo [test workflow only] 2022-11-13 18:48:13 +02:00
9001aa5369 Update yooo [test workflow only] 2022-11-13 16:45:23 +02:00
25f2967493 Update yooo [test workflow only] 2022-11-13 15:43:14 +02:00
5a7c5e49fe Update yooo 2022-11-12 19:10:05 +02:00
997f9261aa Update yoo 2022-11-12 18:26:56 +02:00
06205bc608 Update 2022-11-12 17:30:41 +02:00
6baf34bb80 Update 2022-11-12 14:42:32 +02:00
595f353ff3 Up version 🥲 agein 2022-11-10 01:27:02 +02:00
99f73b443e Up version 🥲 agein 2022-11-10 00:47:31 +02:00
7699f6c0d9 Up version 🥲 agein 2022-11-10 00:02:15 +02:00
d9d1f7c846 Up version 🥲 agein 2022-11-09 21:33:09 +02:00
439f5eb880 Up version 🥲 2022-11-09 21:17:56 +02:00
74b530c3cf Up version 🥲 2022-11-09 20:52:56 +02:00
e58e2dc92c Up version 🥲 2022-11-09 20:31:53 +02:00
1e436bfe70 Up version 🥲 2022-11-09 20:02:15 +02:00
547997517b Up version 🥲 2022-11-09 19:26:33 +02:00
a57ad5a282 Up version 🥲 2022-11-09 19:22:24 +02:00
163305c42f :") 2022-11-09 18:44:52 +02:00
e9793665b4 Bumb :/ 2022-11-09 17:57:45 +02:00
dc41987da5 Fix action version 2022-11-09 17:42:42 +02:00
309449affe Update :) 2022-11-09 17:40:08 +02:00
1c79b8a848 Update 2022-11-09 15:25:46 +02:00
ee50135921 Bumb version agin 2022-11-09 13:37:14 +02:00
Anas Elgarhy
af667544d3
Merge pull request #8 from anas-elgarhy/fix-aur-packge
Fix action configration
2022-11-09 13:37:27 +02:00
6814f861eb Fix action configration 2022-11-09 13:33:57 +02:00
0231a5502b Bumb version -> 0.2.1 2022-11-09 13:27:07 +02:00
b8f95048e1
Merge pull request #7 from anas-elgarhy/add-aur-action
Create the aur-release action yoo ;D
2022-11-09 13:27:49 +02:00
5d89417aa1 Create the aur-release action yoo ;D 2022-11-09 13:17:45 +02:00
9a7730d2dd
Merge pull request #6 from giulio-Joshi/columns_arg
Feature: `width` argument to calculate scale from number of available columns
2022-10-26 21:36:20 +02:00
giulio-Joshi
e108a1875e Fixing requested changes
* Documentation consistency
* Method inlining
2022-10-26 19:52:58 +02:00
giulio-Joshi
0933e157d5 Typo fix 2022-10-25 21:11:53 +02:00
giulio-Joshi
7cc47d7284 Terminal interface: width parameter
Will calculate scaling based on parameter-specified columns number.
2022-10-25 21:07:22 +02:00
296235de7a Update the AUR package 😆 2022-10-11 12:52:23 +02:00
14 changed files with 113 additions and 1387 deletions

24
.github/workflows/aur-release.yml vendored Normal file
View file

@ -0,0 +1,24 @@
name: aur-release
on:
push:
tags:
- "*" # Run on any tag
jobs:
aur-publish:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- name: Publish AUR package
uses: anas-elgarhy/aur-release-action@v4.1
with:
ssh_private_key: ${{ secrets.AUR_SSH_PRIVATE_KEY }}
github_token: ${{ secrets.GITHUB_TOKEN }}
pkgbuild_path: archpackage/PKGBUILD # Use this if the PKGBUILD file is not in the root directory
# aur_submodule_path: archpackage/aarty
git_username: Anas Elgarhy # Use this if you want to change the git username (recommended)
git_email: anas.elgarhy.dev@gmail.com # Use this if you want to change the git email (recommended)
commit_message: UpUp Update %FILENAME% to %VERSION% yoo # Use this if you want to change the commit message
try_build_and_install: false

7
.mergify.yml Normal file
View file

@ -0,0 +1,7 @@
pull_request_rules:
- name: Automatic merge on approval
conditions:
- "#approved-reviews-by>=1"
actions:
merge:
method: merge

View file

@ -1,6 +1,6 @@
[package] [package]
name = "aarty" name = "aarty"
version = "0.2.0" version = "0.4.8"
edition = "2021" edition = "2021"
authors = ["Anas Elgarhy <anas.elgarhy.dev@gmail.com>"] authors = ["Anas Elgarhy <anas.elgarhy.dev@gmail.com>"]
description = "A simple CLI tool to convert the images to ASCII art" description = "A simple CLI tool to convert the images to ASCII art"
@ -31,8 +31,8 @@ exclude = ["images/*"]
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html # See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
[dependencies] [dependencies]
clap = { version = "4.0.12-rc.3", features = ["derive"] } clap = { version = "4.3.2", features = ["derive"] }
colored = "2.0.0" colored = "2.0.0"
image = "0.24.4" image = "0.24.6"
log = "0.4.17" log = "0.4.18"
pretty_env_logger = "0.4.0" pretty_env_logger = "0.5.0"

View file

@ -105,6 +105,9 @@ Options:
[default: 4] [default: 4]
-w, --width <WIDTH>
Enstablish how much wide is the output images, in columns. Overrides `scale`
-b, --background <BACKGROUND> -b, --background <BACKGROUND>
The background color to use The background color to use

View file

@ -1,6 +1,6 @@
pkgbase = aarty pkgbase = aarty
pkgdesc = A simple CLI tool to convert the images to ASCII art 🦀💙 pkgdesc = A simple CLI tool to convert the images to ASCII art 🦀💙
pkgver = 0.1.0 pkgver = 0.2.0
pkgrel = 1 pkgrel = 1
url = https://github.com/anas-elgarhy/aarty url = https://github.com/anas-elgarhy/aarty
arch = x86_64 arch = x86_64
@ -8,7 +8,7 @@ pkgbase = aarty
makedepends = cargo makedepends = cargo
provides = aarty provides = aarty
replaces = aarty replaces = aarty
source = aarty-0.1.0.tar.gz::https://static.crates.io/crates/aarty/aarty-0.1.0.crate source = aarty-0.2.0.tar.gz::https://static.crates.io/crates/aarty/aarty-0.2.0.crate
sha256sums = 0bdf82de5b48760e9dcaee0f474ac8cdc333969c60734c4aaa79bc33930a755f sha256sums = aa8cdf26ac78adf035088d6e12730a593e17a040f54ebfe39f59fc9c438be1c4
pkgname = aarty pkgname = aarty

2
archpackage/A Normal file
View file

@ -0,0 +1,2 @@
nas
nas

View file

@ -38,4 +38,4 @@ package() {
cd "$pkgname-$pkgver" cd "$pkgname-$pkgver"
sudo install -Dm0755 -t "/usr/bin/" "target/release/$pkgname" sudo install -Dm0755 -t "/usr/bin/" "target/release/$pkgname"
} }
sha256sums=('0bdf82de5b48760e9dcaee0f474ac8cdc333969c60734c4aaa79bc33930a755f') sha256sums=('aa8cdf26ac78adf035088d6e12730a593e17a040f54ebfe39f59fc9c438be1c4')

@ -1 +1 @@
Subproject commit 1070f216ace48058c236dd3398cdf2ce60d52ac6 Subproject commit b32218c382efd1a956f5f9fcc151aec90862d6e5

File diff suppressed because it is too large Load diff

Binary file not shown.

View file

@ -1,15 +0,0 @@
# Generated by makepkg 6.0.1
# using fakeroot version 1.29
pkgname = aarty
pkgbase = aarty
pkgver = 0.1.0-1
pkgdesc = A simple CLI tool to convert the images to ASCII art 🦀💙
url = https://github.com/anas-elgarhy/aarty
builddate = 1664878775
packager = Unknown Packager
size = 0
arch = x86_64
license = MIT
replaces = aarty
provides = aarty
makedepend = cargo

6
renovate.json Normal file
View file

@ -0,0 +1,6 @@
{
"$schema": "https://docs.renovatebot.com/renovate-schema.json",
"extends": [
"config:base"
]
}

View file

@ -19,6 +19,9 @@ 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`
#[arg(short, long, default_value= None )]
pub width: Option<u32>,
/// The background color to use /// The background color to use
#[arg(short, long, default_value = None)] #[arg(short, long, default_value = None)]
pub background: Option<String>, pub background: Option<String>,

View file

@ -11,10 +11,11 @@ pub fn generate_ascii<W: Write>(
) -> io::Result<()> { ) -> io::Result<()> {
let characters = args.characters.chars().collect::<Vec<char>>(); let characters = args.characters.chars().collect::<Vec<char>>();
let (width, height) = image.dimensions(); let (width, height) = image.dimensions();
let actual_scale = calculate_scale(args, (width, height));
for y in 0..height { for y in 0..height {
for x in 0..width { for x in 0..width {
if y % (args.scale * 2) == 0 && x % args.scale == 0 { if y % (actual_scale * 2) == 0 && x % actual_scale == 0 {
let element = get_character( let element = get_character(
image.get_pixel(x, y), image.get_pixel(x, y),
&characters, &characters,
@ -26,7 +27,7 @@ pub fn generate_ascii<W: Write>(
} }
} }
// Add a new line at the end of each row // Add a new line at the end of each row
if y % (args.scale * 2) == 0 { if y % (actual_scale * 2) == 0 {
buffer.write_all("\n".as_bytes())?; buffer.write_all("\n".as_bytes())?;
} }
} }
@ -60,3 +61,58 @@ fn get_character(
None => ch, None => ch,
} }
} }
///
/// Determine how much scale to use in presence of `width` parameters,
/// otherwise returns regular `scale` parameter per default behaviour
///
#[inline]
fn calculate_scale(args: &Arguments, dimensions: (u32, u32)) -> u32 {
args.width.map_or_else(|| args.scale, |v| dimensions.0 / v)
}
#[cfg(test)]
mod test {
use crate::args::{
args::Arguments,
enums::{Mode, OutputMethod},
};
use super::calculate_scale;
const DIMENSIONS: (u32, u32) = (100, 100);
#[test]
fn test_scale() {
let args = Arguments {
mode: Mode::NormalAscii,
output_method: OutputMethod::Stdout,
image: "".into(),
characters: "".into(),
scale: 4,
width: Some(10),
background: None,
output: "".into(),
};
let scale = calculate_scale(&args, DIMENSIONS);
assert_eq!(scale, 10);
}
#[test]
fn test_default_scale() {
let args = Arguments {
mode: Mode::NormalAscii,
output_method: OutputMethod::Stdout,
image: "".into(),
characters: "".into(),
scale: 4,
width: None,
background: None,
output: "".into(),
};
let scale = calculate_scale(&args, DIMENSIONS);
assert_eq!(scale, 4);
}
}