24-bit ANSI Color Implementation

Posted by Mirai on Sat 24 Nov 2018 09:18 PM — 17 posts, 75,380 views.

#0
I haven't submitted a PR for it yet but was wondering if this is something that would be merged into the distribution (before I go and clean up my commit..)

The reference is here: https://en.wikipedia.org/wiki/ANSI_escape_code#24-bit

"[38;2;r;g;b" vs the supported "[38;5;code"

I have foreground colors working and am putting in the background colors next.

The diff for support is ~71 lines without bkg support.

What do you think?

Thanks!
Australia Forum Administrator #1
Would your intention here be to just support the syntax, or are you aiming for 24-bits for each of the colours? (R/G/B).

The internal implementation of colours is to store them in a long (ie. 8 bits for each of R/G/B) and it would take a major change to support more than 255 for any of those colours.

If the colours were constrained to 0 to 255 for each of R/G/B then I don't see a major issue. If not, then I do.
USA Global Moderator #2
Quote:
If the colours were constrained to 0 to 255 for each of R/G/B then I don't see a major issue.

This fits my understanding of 24 bit color.

Are there servers using this other notation, though? If so, why? My eyes can only barely differentiate neighboring shades on the 256 color chart. Subdividing the text colorspace further by a factor of over 65000 seems absurd to me.
Amended on Sun 25 Nov 2018 08:04 PM by Fiendish
#3
Thank you for your reply.

Yes, I just adding support for that syntax, preventing the escape code "ESC[38;2;201;192;0m" from rendering as "201;192;0m", and enabling the display of the text in the appropriate RGB color.

Correct, it'd be 8 bits per channel, 24-bits for the whole color (i.e. one byte per r/g/b, 0-255). Only RGB colorspace, not HSV/CMYK allowed by I.TEC. It works (tested) with the given COLORREF data structure/size. My branch will be ready soon.

Fiendish said:

Are there servers using this other notation, though? If so, why? My eyes can only barely differentiate neighboring shades on the 256 color chart.


I actually implemented this specifically for an in-development server, where the author seems to be doing so with good creative effect. Maps with subtle color variations, visual effects like a flickering flame. Currently they are having their users use beipmu but I prefer MUSHclient and implemented so that I could use it for this game.

I believe 8bitMUSH only uses 256-color mode. I assume there are some or more, though perhaps it'll open the door for more given expanded client support.
Australia Forum Administrator #4
Internally MUSHclient supports 24-bit colour. There are a few colour modes, one is indexed (ie. if it gets the code for ANSI green it looks that up in a table, which you can configure, so it doesn't necessarily look green).

Another mode is RGB colour where the colour is stored in a long (8 bits each for R/G/B). This was partly done to support MXP. Also functions like ColourNote (can) take a 24-bit colour as an argument.

The changes should be fairly straightforward. I expect most or all of them to be in:

https://github.com/nickgammon/mushclient/blob/master/ansi.cpp
#5
I've completed the implementation and submitted a PR. At your convenience, please inspect it for any issues. I hope you consider it for integration into the next release. Thank you!

https://github.com/nickgammon/mushclient/pull/45
USA Global Moderator #6
Quote:
I actually implemented this specifically for an in-development server, where the author seems to be doing so with good creative effect. Maps with subtle color variations, visual effects like a flickering flame.

I'd love to see this. Got a link?
#7
Fiendish said:

Quote:
I actually implemented this specifically for an in-development server, where the author seems to be doing so with good creative effect. Maps with subtle color variations, visual effects like a flickering flame.

I'd love to see this. Got a link?


hi, i'm the developer of the mentioned project. if you use discord you can add me (Janey#0136) and i can send screenshots and more information. for various reasons i don't want to post any links out in the open.
USA Global Moderator #8
Quote:
if you use discord

I don't.

Quote:
for various reasons i don't want to post any links out in the open.

???
#9
Fiendish said:

Quote:
if you use discord

I don't.

Quote:
for various reasons i don't want to post any links out in the open.

???


i'm secretive when it comes to the project for various reasons but in that case i'll just post the pictures here; anyone who recognizes it is already in

https://i.gyazo.com/d19087cbb6b6c6f07cf446e68dad8155.png
https://i.gyazo.com/caa5363b5922f34326e62e60bd039e7a.png
https://i.gyazo.com/bc280a353526c231e0a59e62eb014012.png
USA Global Moderator #10
Does this really benefit from having 16 million very close together colors, or do you just prefer the format vs the 256 color index?
Amended on Wed 28 Nov 2018 10:35 PM by Fiendish
#11
Fiendish said:

Does this really benefit from having 16 million very close together colors, or do you just prefer the format vs the 256 color index?


it does benefit. many times i've tried to look for a specific color and instead i could only find 8 bit stuff.
Australia Forum Administrator #12
I just want to point out that MUSHclient already supports 256-colour ANSI as discussed here:


http://www.gammon.com.au/forum/bbshowpost.php?id=7761

Also mentioned in the release notes for version 4.02 (point 4):

http://www.gammon.com.au/scripts/showrelnote.php?version=4.02&productid=0

The range of colours that you can show is as follows:



This is in addition to the standard 16 ANSI colours (red, green, blue, etc.).
Amended on Thu 29 Nov 2018 05:33 AM by Nick Gammon
#13
Nick Gammon said:

I just want to point out that MUSHclient already supports 256-colour ANSI as discussed here:


http://www.gammon.com.au/forum/bbshowpost.php?id=7761

Also mentioned in the release notes for version 4.02 (point 4):

http://www.gammon.com.au/scripts/showrelnote.php?version=4.02&productid=0

The range of colours that you can show is as follows:

(img=Forum_7761b.png)

This is in addition to the standard 16 ANSI colours (red, green, blue, etc.).


https://i.gyazo.com/f6650f6af985b012d59dc0bff7beb983.png
Australia Forum Administrator #14
I've merged that commit in, with a few amendments, thanks for doing it. :)

The recompiled version should be available for download as described here: http://www.gammon.com.au/forum/?id=13903
Australia Forum Administrator #15
I also added the code into the AnsiNote function for symmetry with the other functionality in it.
#16
Awesome, thank you! And, thank you taking the time to add the note functionality -- I saw it on first glance but forgot to revisit it. Looks good!