Colorful.Console icon indicating copy to clipboard operation
Colorful.Console copied to clipboard

Workaround for 16-Colors with Truecolor

Open Gammer0909 opened this issue 1 year ago • 0 comments

(If this has been brought up before and rejected, I apologize, but I could not find a similar issue)

Hi, I'm new to this project, and I noticed at the bottom of the README that it says

Colorful.Console can only write to the console in 16 different colors And I considered a workaround!

Basically, you can avoid using System.ConsoleColor, because not only do most macOS and linux terminals support this, but Windows does too!

And that thing is:

Truecolor/256 Color support

Truecolor is 24-bit colors, meaning you can convert from a System.Drawing.Color to a custom color.

Basically, a Truecolor query is just prepending an ANSI Color Code to the string you want.

For example, in your terminal, if you write

echo "\x1b[38;2;255;100;0mTRUECOLOR\x1b[0m\n"

It outputs:

Screen Shot 2024-01-05 at 7 40 36 PM

I think this is a versatile solution, as I've taken a swing at it, given that you can use string interpolation.

Hope this helps, Gammer0909

Gammer0909 avatar Jan 06 '24 01:01 Gammer0909