Compare commits
56 commits
Author | SHA1 | Date | |
---|---|---|---|
|
59ff61bcf1 | ||
|
fd4efce251 | ||
92351bfec8 | |||
|
6110d36adc | ||
|
31c5dac6cb | ||
|
e06ae70b20 | ||
|
69b8f008a9 | ||
|
30d4e3a037 | ||
|
b25849c0bf | ||
|
6d19281100 | ||
|
e4d0da778b | ||
|
1133be9a5a | ||
|
f6dc9a004a | ||
|
8bbc1f7e1d | ||
|
8e403c87bd | ||
c0b2ff6074 | |||
884d8d504c | |||
1ad7f8bf03 | |||
|
9d76b9268d | ||
7d84eaa186 | |||
fe468ffde0 | |||
ec206cb527 | |||
4867f64768 | |||
4d642d07d2 | |||
9001aa5369 | |||
25f2967493 | |||
5a7c5e49fe | |||
997f9261aa | |||
06205bc608 | |||
6baf34bb80 | |||
595f353ff3 | |||
99f73b443e | |||
7699f6c0d9 | |||
d9d1f7c846 | |||
439f5eb880 | |||
74b530c3cf | |||
e58e2dc92c | |||
1e436bfe70 | |||
547997517b | |||
a57ad5a282 | |||
163305c42f | |||
e9793665b4 | |||
dc41987da5 | |||
309449affe | |||
1c79b8a848 | |||
ee50135921 | |||
|
af667544d3 | ||
6814f861eb | |||
0231a5502b | |||
b8f95048e1 | |||
5d89417aa1 | |||
9a7730d2dd | |||
|
e108a1875e | ||
|
0933e157d5 | ||
|
7cc47d7284 | ||
296235de7a |
14 changed files with 113 additions and 1387 deletions
24
.github/workflows/aur-release.yml
vendored
Normal file
24
.github/workflows/aur-release.yml
vendored
Normal 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
7
.mergify.yml
Normal file
|
@ -0,0 +1,7 @@
|
|||
pull_request_rules:
|
||||
- name: Automatic merge on approval
|
||||
conditions:
|
||||
- "#approved-reviews-by>=1"
|
||||
actions:
|
||||
merge:
|
||||
method: merge
|
10
Cargo.toml
10
Cargo.toml
|
@ -1,6 +1,6 @@
|
|||
[package]
|
||||
name = "aarty"
|
||||
version = "0.2.0"
|
||||
version = "0.4.8"
|
||||
edition = "2021"
|
||||
authors = ["Anas Elgarhy <anas.elgarhy.dev@gmail.com>"]
|
||||
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
|
||||
|
||||
[dependencies]
|
||||
clap = { version = "4.0.12-rc.3", features = ["derive"] }
|
||||
clap = { version = "4.3.2", features = ["derive"] }
|
||||
colored = "2.0.0"
|
||||
image = "0.24.4"
|
||||
log = "0.4.17"
|
||||
pretty_env_logger = "0.4.0"
|
||||
image = "0.24.6"
|
||||
log = "0.4.18"
|
||||
pretty_env_logger = "0.5.0"
|
||||
|
|
|
@ -105,6 +105,9 @@ Options:
|
|||
|
||||
[default: 4]
|
||||
|
||||
-w, --width <WIDTH>
|
||||
Enstablish how much wide is the output images, in columns. Overrides `scale`
|
||||
|
||||
-b, --background <BACKGROUND>
|
||||
The background color to use
|
||||
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
pkgbase = aarty
|
||||
pkgdesc = A simple CLI tool to convert the images to ASCII art 🦀💙
|
||||
pkgver = 0.1.0
|
||||
pkgver = 0.2.0
|
||||
pkgrel = 1
|
||||
url = https://github.com/anas-elgarhy/aarty
|
||||
arch = x86_64
|
||||
|
@ -8,7 +8,7 @@ pkgbase = aarty
|
|||
makedepends = cargo
|
||||
provides = aarty
|
||||
replaces = aarty
|
||||
source = aarty-0.1.0.tar.gz::https://static.crates.io/crates/aarty/aarty-0.1.0.crate
|
||||
sha256sums = 0bdf82de5b48760e9dcaee0f474ac8cdc333969c60734c4aaa79bc33930a755f
|
||||
source = aarty-0.2.0.tar.gz::https://static.crates.io/crates/aarty/aarty-0.2.0.crate
|
||||
sha256sums = aa8cdf26ac78adf035088d6e12730a593e17a040f54ebfe39f59fc9c438be1c4
|
||||
|
||||
pkgname = aarty
|
||||
|
|
2
archpackage/A
Normal file
2
archpackage/A
Normal file
|
@ -0,0 +1,2 @@
|
|||
nas
|
||||
nas
|
|
@ -38,4 +38,4 @@ package() {
|
|||
cd "$pkgname-$pkgver"
|
||||
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.
|
@ -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
6
renovate.json
Normal file
|
@ -0,0 +1,6 @@
|
|||
{
|
||||
"$schema": "https://docs.renovatebot.com/renovate-schema.json",
|
||||
"extends": [
|
||||
"config:base"
|
||||
]
|
||||
}
|
|
@ -19,6 +19,9 @@ pub mod args {
|
|||
/// The output scale (1 is the original size)
|
||||
#[arg(short, long, default_value = "4")]
|
||||
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
|
||||
#[arg(short, long, default_value = None)]
|
||||
pub background: Option<String>,
|
||||
|
|
|
@ -11,10 +11,11 @@ pub fn generate_ascii<W: Write>(
|
|||
) -> io::Result<()> {
|
||||
let characters = args.characters.chars().collect::<Vec<char>>();
|
||||
let (width, height) = image.dimensions();
|
||||
let actual_scale = calculate_scale(args, (width, height));
|
||||
|
||||
for y in 0..height {
|
||||
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(
|
||||
image.get_pixel(x, y),
|
||||
&characters,
|
||||
|
@ -26,7 +27,7 @@ pub fn generate_ascii<W: Write>(
|
|||
}
|
||||
}
|
||||
// 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())?;
|
||||
}
|
||||
}
|
||||
|
@ -60,3 +61,58 @@ fn get_character(
|
|||
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);
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue