6 ms·
Show HN: RASCII, an advanced ASCII art generator made using Rust
- throwbadubadu 3y agoLove it, one of my first programming things was something like this (much uglier and simpler though), in a scripting language for a terminal program on the Amiga, it's name forgotten... to let me shout messages in ASCII art into some mailbox's chat program.
- fnordpiglet 3y agoCute. Would be nice as a crate but the impl is small enough to copy with attribution
- RGBCube 3y agoIt is available on crates.io [0], but I forgot to make the API customizable, it directly prints to stdout at the moment. I will work on this next. [0] - https://lib.rs/crates/rascii_art https://lib.rs/crates/rascii_art
- fnordpiglet 3y agoSweet! I need a startup for my repl and have a neat logo I generated with Midjourney for my side project. Will be used!
- fnordpiglet 3y agoI'd note it would be helpful if the image crate weren't necessary as a direct dependency - the ability to render the image by Path would be helpful. Additionally, the charsets are all in main.rs, would be helpful to be factored into the library. Also termcolor as a dependency could be masked. I did however get my logo rendering and it looks sweet! How does it choose the characters?
- RGBCube 3y agoNoted, I'll do all of these today - but it may require a breaking version update to 0.3.0. 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] }
- fnordpiglet 3y agoI see so the further into the chat set the darker… thanks!!! It looks really great as a logo when my side project starts up!
- deleted 3y ago[deleted]
- RGBCube 3y agoAll of these are done, just need to get my friend to add me to the crate and publish on crates.io. 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.
- deleted 3y ago[deleted]
- RGBCube 3y agoNote: The character picker algorithm is currently pretty broken as it only uses the alpha, this will be fixed soon. Colored images still look good though. Edit: Fixed in the latest commit