67
This took me 4 months
(feddit.uk)
Post funny things about programming here! (Or just rant about your favourite programming language.)
i read through the code, and i have some tips, which you may find helpful (or not):
--color
is not the first argument, it will try to open a file named--color
, which i assume is unintended. i would suggest checking out theclap
crate to easily parse argsimage.resize()
is easier.len()
on a string returns length in bytes, not characters, so could break with non-ascii text. in the context of this program, the text will always be ascii, so it is of course not a problem, but it's worth to keep in mind. to get character length, use.chars().count()
get_brightness_of_cluster
, pushing to aVec
and then calling.sum()
can be replaced with a loop which increments a mutableu32
variable. this is a nitpick, but it can avoid unnecessary memory allocationcheck out this example. sorry if this comes off as rude or a nitpick, i'm just trying to provide some advice :)
Thank you for your help this is not rude at all and very helpfull! I know about argument parsing with clap, and started thinking about it as I started to add more functional to the program
Is resizing and image is more performant? I yes then i was wrong when coding with clusters, it's always good to have another viewpoint for tasks like this I didn't even think of resizing an image)
About .len i think it's fine as long as it works
The width of images should be resized depending on your terminal width and height, im still not sure how i can improve it, because every image is unique
get_brightness is a bit broken in performance right now, i will fix it later
Thanks you for your tips, really helpfull! Дякую!
:) no problem! i would assume resizing the image might be a little slower, because it creates a clone of the image, but if you use FilterType::NearestNeighbor, the speed is negligable in my opinion