Show HN: RASCII, an advanced ASCII art generator made using Rust
github.com
github.com
I will work on this next.
I also managed to drop the size of colored images by a ton! Look at this difference:
### Before:
RASCII on master [$] is v0.3.0 via v1.71.0-nightly took 2s
> ./target/debug/rascii ~/Downloads/cuddlyferris.png --color | save -f ferris.ansi
RASCII on master [$] is v0.3.0 via v1.71.0-nightly
> ls | find ferris
╭───┬─────────────┬──────┬──────────┬──────────╮
│ # │ name │ type │ size │ modified │
├───┼─────────────┼──────┼──────────┼──────────┤
│ 0 │ ferris.ansi │ file │ 395.5 KB │ now │
╰───┴─────────────┴──────┴──────────┴──────────╯
### After: RASCII on master [+] is v0.3.1 via v1.71.0-nightly
> ./target/debug/rascii ~/Downloads/cuddlyferris.png --color | save -f ferris.ansi
RASCII on master [+] is v0.3.1 via v1.71.0-nightly
> ls | find ferris
╭───┬─────────────┬──────┬─────────┬──────────╮
│ # │ name │ type │ size │ modified │
├───┼─────────────┼──────┼─────────┼──────────┤
│ 0 │ ferris.ansi │ file │ 83.1 KB │ now │
╰───┴─────────────┴──────┴─────────┴──────────╯
Also newlines are clean now, so you can append text onto each lines end and have it not be colored.It chooses the character by converting the RGB to grayscale and mapping the 0-255 range to the given charsets length:
let as_grayscale = (pixel[0] as f64 * 0.299) + (pixel[1] as f64 * 0.587) + (pixel[2] as f64 * 0.114);
// TODO: Use alpha channel to determine if pixel is transparent?
let char_index =
((as_grayscale / 255.0) * (self.options.charset.len() as f64 - 1.0)) as usize;
if self.options.invert {
self.options.charset[self.options.charset.len() - 1 - char_index]
} else {
self.options.charset[char_index]
}Colored images still look good though.
Edit: Fixed in the latest commit