atanunq / viu

Terminal image viewer with native support for iTerm and Kitty
MIT License
2.58k stars 58 forks source link

Implement truly transparent pixels #11

Closed L3viathan closed 5 years ago

L3viathan commented 5 years ago

This implements "truly" transparent pixels as described in #10, while throwing away the old way (the grid). I don't know if you want to keep it or not.

I'm using the color Color::Magenta as a placeholder for transparency, because the colorspec doesn't support it otherwise, and the rest of the code uses RGB colors exclusively. This shouldn't break displaying actually magenta pictures.

Code may or may not be terrible; I'm a Rust noob.

L3viathan commented 5 years ago

I just tried it out with animated gifs: It works, but transparent pixels that were not transparent in the previous frame keep their original color.

atanunq commented 5 years ago

Thank you very much for contributing! Sadly, at the moment I do not have the time to test it thoroughly.

As far as removing the grid is concerned, I would have preserved the old functionality as default behaviour and remove it with an explicit flag. A thing that bothers me is this placeholder value - there must be another way to do it, it just does not feel right.

Another thing to note is that I still have not figured out the correct way to display transparency in gifs. This one is still bugging me. I guess in the end it will be just a bunch of flags that make the transparency work in different way so that viu offers a suitable option for any kind of gif. I am leaving the PR open for now, but I will not be able to help with development in the next couple of weeks.

L3viathan commented 5 years ago

Thanks for your response. I changed some things: The option --transparent/-t now toggles my behaviour, the default being what was done before.

I also managed to find a way around using the Magenta placeholder — Options. I guess this is really what they're meant for.

atanunq commented 5 years ago

Awesome, great work! It looks much nicer now. Thanks for the feature!