I've been trying to do some complex animations on the console, seeing how far I can push the standard Windows console. I was able to get any color I wanted by following this post: Custom text color in C# console application?, using the second answer involving ENABLE_VIRTUAL_TERMINAL_PROCESSING
. However, due to how many characters I was trying to color at once (roughly 2 million), even a single Console.Write
was too slow. I then tried to use this process: How can I write fast colored output to Console? This gave me the speed that I was looking for, but I was limited to the 16 color palette that the Windows console uses. Is there anyway to get the exact RGB color specificity that the first post offered, while also still having the speed of writing directly to the console buffer like the second post?
I tried using Console.Write("\x1b[48;2;" + 255 + ";" + 0 + ";" + 0 + "m")
before writing directly to the buffer, just to see if the background color would be properly changed. I also made sure not to set the Attributes
property of any of the CharInfo
as each character was being written into the buf
array. Unfortunately, that did not work. All text that was written directly into the buffer still had a black background and black foreground color. I also tried to change the RGB value of one of the 16 standard colors between separate writes to the buffer, but that ended up being too slow.