cronvel / terminal-kit

Terminal utilities for node.js
MIT License
3.11k stars 201 forks source link

Issues with colors in TTY #183

Open lapsio opened 3 years ago

lapsio commented 3 years ago

When I'm trying to display image in TTY all colors are really wonky. I know it's tricky to display 256 color images in TTY but for example ponysay does manage to do that by swapping palette on the go. Would it be possible to achieve something similar with terminal-kit?

cronvel commented 3 years ago

@lapsio Post an example, please.

lapsio commented 2 years ago

So for Ponysay it doesn't do much difference whether you run it from TTY or graphical terminal. It emulates colors by swapping palette on the go, while terminal-kit doesn't work all that well with TTY:

photo1637875448

photo1637875448 (2)

photo1637875448 (1)

I assume ponysay does that by swapping palette because after displaying pony by ponysay in TTY shell colors (like red or green) are left altered and basically whole terminal palette is screwed and mimics ponysay graphic color shades. So for example if ponysay displays red pony then red displayed by red color code in shell (\u001b[31m) is different than default red and it changes after each ponysay execution.

lapsio commented 2 years ago

also sorry for extremely late response

cronvel commented 2 years ago

@lapsio Ok, but have you an example of actual code using Terminal-Kit that doesn't work? Also are you talking about you the Linux console? Last time I checked, it was not supporting 256 colors, only 16 colors.

If your last image was produced by the lib, it's clear that it was expecting 16 or even 8 colors.

lapsio commented 2 years ago

yeah all 3 images are produced in TTY with TERM env equal to "linux".

Code is fairly simple:

#!/usr/bin/node
term = require('/usr/lib/node_modules/terminal-kit');
process.argv.slice(2).forEach(i=>term.terminal.drawImage(i,{shrink:{ width: term.terminal.width, height: term.terminal.height * 2 }}))

first two photos were ponysay graphics, last one is terminal-kit.