4 ms·
This is a great hack, but it makes bad sparklines. It’s probably about as good as you can get with unicode, so props to Jon. Sparklines have a few important pr
by sonofhans 2y ago
This is a great hack, but it makes bad sparklines. It’s probably about as good as you can get with unicode, so props to Jon.
Sparklines have a few important properties which these do not exhibit. They’re typically higher resolution, with more data per inch. Also the slopes from point to point, and the whitespace under the typical graph/sparkline, help readability.
- layer8 2y agoMaybe we need terminal escape codes to temporarily switch to linked alternative fonts. ;)
- estebank 2y agoCongratulations on reinventing sixels. :)
- hnlmorg 2y agoSixel is different. It’s a way of drawing graphics rather than switching to alternative character sets. Sixels could be used here too, but native support for vector graphics would be nicer. I’m also of the opinion that sixel sucks as a modern option. It’s got a low DPI resolution, cannot be compressed, and is its own bespoke specification which means lots of additional work for terminal maintainers. Which is why most terms these days go with their own escape sequences for natively supporting common formats like PNG and JPEG. In my own terminal emulator, I’ve got support for several image formats but I doubt I’ll ever bother with sixel.
- hnlmorg 2y agoThere are already several escape sequences for doing just this. In fact the original way of drawing terminal graphics was using a 7bit escape sequence to switch to a terminal graphics font. Personally I’d rather see in-lined vector graphics become better supported. This was available on some of the Techtonix (iirc) hardware VTs and as far as I know, the only widespread terminal emulator to support that particular mode is xterm.
- layer8 2y agoIsn't that more like switching to a different character set, with supporting fonts having to be already present? Or what are you referring to? I was thinking along the lines of online (or inline) fonts, similar to web fonts in CSS, which would allow for arbitrary custom glyphs.
- LukeShu 2y agoSixel graphics on the vt220 (1983) worked by defining a custom font of 10x10 px characters (9x10 in high-resolution mode), which you could then switch to for any given character. As far as I know, there is no terminal emulator that supports this flavor if sixel graphics.
- FujiApple 2y agoI recently had to look at the implementation of the Sparkline [1] widget in Ratatui which uses a similar Unicode technique but scales nicely for sparklines with larger vertical size. [1] https://github.com/ratatui/ratatui/blob/20c88aaa5b9eb011a52240eab5edc1a8db23157a/src/widgets/sparkline.rs#L157 https://github.com/ratatui/ratatui/blob/20c88aaa5b9eb011a522...
- kqr 2y agoOne can use Braille characters to get slightly more negative space and horizontal resolution, at the cost of vertical resolution. (They are 2×4 blocks IIRC.)
- Am4TIfIsER0ppos 2y agoIf anyone want to see an example of graphing use the braille characters (I think) look at btop https://github.com/aristocratos/btop https://github.com/aristocratos/btop Speaking of misaligned characters: an upgrade a few months back in some thing (font, terminal, or renderer) caused the characters to be shifted up or down one pixel so the bottom and top now touch between lines