textual icon indicating copy to clipboard operation
textual copied to clipboard

Svg/img support?

Open torshepherd opened this issue 2 years ago • 1 comments

Textual seems like a promising framework for bringing web concepts/tech to terminals - in that spirit, has there been any thought of adding in vector graphics / img widget support?

img

There is precedent for rendering images in terminals, see (https://nick-black.com/dankwiki/index.php/Notcurses#Blitters). To that end, Textual could choose to either implement one or more of the blitting methods (entire spaces, half-blocks, quadrants, sextant blocks, braille, or terminal-specific (sixel/kitty)) from scratch, or simply add the notcurses python package (https://pypi.org/project/notcurses/) as a dependency and wrap their blitters.

svg

Svg could either be rasterized by the same blitting techniques, or custom blitters could be written. Since Textual already supports CSS animations, this could enable animated svg widgets or background images, which are quite popular at the moment in web design (https://codepen.io/tedmcdo/pen/PqxKXg, https://getwaves.io/, etc.)

Smooth mosaic characters

In addition to the blitting methods implemented by notcurses, one could develop an svg renderer that uses characters U+1FB3C - U+1FB67 to do better vector drawing (https://unicode-table.com/en/blocks/symbols-for-legacy-computing/). I think a vector renderer based on this technique combined with css animations presents an opportunity for Textual to further distinguish itself as the choice when it comes to TUI libraries!

caveat

Note that support for these characters/renderers varies greatly between terminals. Unfortunately, many of the current options (looking at you, Alacritty) don't properly render sixels or any of the Symbols For Legacy Computing :(

Therefore, this should be considered under worst case - I. e. using whole blocks, halfs, or quadrants at best.

I'd be happy to draw up a draft implementation of any of these proposals if there's interest.

torshepherd avatar Aug 26 '22 13:08 torshepherd

For an even simpler solution, there's https://pypi.org/project/climage/

torshepherd avatar Aug 26 '22 16:08 torshepherd

https://github.com/Textualize/textual/wiki/Sorry-we-closed-your-issue

willmcgugan avatar Oct 25 '22 09:10 willmcgugan

Did we solve your problem?

Glad we could help!

github-actions[bot] avatar Oct 25 '22 09:10 github-actions[bot]

Reopening as it's something critical to my adoption of Textual.

Headlock0408 avatar Oct 26 '22 20:10 Headlock0408