Jump to content
Main menu
Main menu
move to sidebar
hide
Navigation
Main page
Recent changes
Random page
Help about MediaWiki
Special pages
Niidae Wiki
Search
Search
Appearance
Create account
Log in
Personal tools
Create account
Log in
Pages for logged out editors
learn more
Contributions
Talk
Editing
ANSI escape code
(section)
Page
Discussion
English
Read
Edit
View history
Tools
Tools
move to sidebar
hide
Actions
Read
Edit
View history
General
What links here
Related changes
Page information
Appearance
move to sidebar
hide
Warning:
You are not logged in. Your IP address will be publicly visible if you make any edits. If you
log in
or
create an account
, your edits will be attributed to your username, along with other benefits.
Anti-spam check. Do
not
fill this in!
==== 8-bit ==== {{seealso|Web colors#Web-safe colors}} As [[8-bit color|256-color]] lookup tables became common on graphic cards, escape sequences were added to select from a pre-defined set of 256 colors:<ref>{{cite web |url=https://invisible-island.net/xterm/xterm.faq.html#color_by_number |title=XTerm FAQ: Can I set a color by its number? |author-first=Thomas E. |author-last=Dickey |accessdate=March 28, 2025}}</ref> ESC[38;5;{{angbr|n}}m Select foreground color where n is a number from the table below ESC[48;5;{{angbr|n}}m Select background color 0- 7: standard colors (as in ESC [ 30β37 m) 8- 15: high intensity colors (as in ESC [ 90β97 m) 16-231: 6 Γ 6 Γ 6 cube (216 colors): 16 + 36 Γ r + 6 Γ g + b (0 β€ r, g, b β€ 5) 232-255: grayscale from dark to light in 24 steps The colors displayed by these values vary across terminal/emulator implementations as the recognized ECMA-48 and ITU's T.416 specifications do not define a specific color palette for this lookup table. While it is common to use the above formula for the color palette, in particular the algorithm and choice of colors for the 16-231 cube values differs between implementations. The color palette and algorithm used by XTerm is specified below as a sample.<ref name="ECMA-48" /><ref name="T.416" /> The [[ITU]]'s T.416 Information technology - Open Document Architecture (ODA) and interchange format: Character content architectures<ref name="T.416">{{cite web |url=https://www.itu.int/rec/dologin_pub.asp?lang=e&id=T-REC-T.416-199303-I!!PDF-E&type=items |title=T.416 Information technology - Open Document Architecture (ODA) and interchange format: Character content architectures}}</ref> uses ":" as separator characters instead: ESC[38:5:{{angbr|n}}m Select foreground color where n is a number from the table below ESC[48:5:{{angbr|n}}m Select background color<!-- def fg(triad): return 'ffffff' if (triad[2:4] < 'a0') else '000000' standards = ('000000 800000 008000 808000 000080 800080 008080 c0c0c0 ' + '808080 ff0000 00ff00 ffff00 0000ff ff00ff 00ffff ffffff').split(' ') rgbs = '00 5f 87 af d7 ff'.split(' ') greys = '08 12 1c 26 30 3a 44 4e 58 62 6c 76 80 8a 94 9e a8 b2 bc c6 d0 da e4 ee'.split(' ') fgs = '000000 ffffff'.split(' ') code = 0 outs = [[] for i in range(3)] out = '\n| style="color:#%s;background:#%s;" title="#%s" |%s' for i in range(len(standards)): if (i == len(standards) / 2.0): outs[0].append('\n| style="width:1em;"| ') triad = standards[i] outs[0].append(out % (fgs[i < len(standards) / 2], triad, triad, code if (code > 9) else ' %d ' % code)) code += 1 for r in range(len(rgbs)): for g in range(len(rgbs)): for b in range(len(rgbs)): triad = rgbs[r] + rgbs[g] + rgbs[b] outs[1].append(out % (fgs[g < len(rgbs) / 2], triad, triad, code)) code += 1 outs[1].append('\n|-\n') for i in range(len(greys)): triad = greys[i] * 3 outs[2].append(out % (fgs[i < len(greys) / 2], triad, triad, code)) code += 1 file_out = open(__file__[:__file__.rfind('.')] + '.htm', 'w') file_out.write('''\ {| table class="collapsible" style="text-align:center;font-size:80%%;width:100%%;background:#f6f6f6;cursor:default;" cellpadding="0" cellspacing="1" |- ! colspan="36" | 256-color mode β foreground: ESC[38;5;#m background: ESC[48;5;#m |- | colspan="18" | Standard colors | colspan="18" | High-intensity colors |- | colspan="36" | {| style="width:100%%;text-align:center;font-weight:bold;" |- %s |- |} |- | colspan="36" | 216 colors |- %s |- | colspan="36" | Grayscale colors |- | colspan="36" | {| style="width:100%%;text-align:center;font-weight:bold;" |- %s |- |} |}''' % (''.join(outs[0]), ''.join(outs[1]), ''.join(outs[2]))) file_out.close() --> {{anchor|256_color_table}} {| class="collapsible" style="text-align:center;font-size:80%;width:100%;background:#f6f6f6;cursor:default;" cellpadding="0" cellspacing="1" |- ! colspan="36" | 256-color mode β foreground: ESC[38;5;#m background: ESC[48;5;#m |- | colspan="18" | Standard colors | colspan="18" | High-intensity colors |- | colspan="36" | {| style="width:100%;text-align:center;font-weight:bold;" |- | style="color:#ffffff;background:#000000;" title="#000000" | 0 | style="color:#ffffff;background:#800000;" title="#800000" | 1 | style="color:#ffffff;background:#008000;" title="#008000" | 2 | style="color:#ffffff;background:#808000;" title="#808000" | 3 | style="color:#ffffff;background:#000080;" title="#000080" | 4 | style="color:#ffffff;background:#800080;" title="#800080" | 5 | style="color:#ffffff;background:#008080;" title="#008080" | 6 | style="color:#ffffff;background:#c0c0c0;" title="#c0c0c0" | 7 | style="width:1em;" | | style="color:#000000;background:#808080;" title="#808080" | 8 | style="color:#000000;background:#ff0000;" title="#ff0000" | 9 | style="color:#000000;background:#00ff00;" title="#00ff00" |10 | style="color:#000000;background:#ffff00;" title="#ffff00" |11 | style="color:#000000;background:#0000ff;" title="#0000ff" |12 | style="color:#000000;background:#ff00ff;" title="#ff00ff" |13 | style="color:#000000;background:#00ffff;" title="#00ffff" |14 | style="color:#000000;background:#ffffff;" title="#ffffff" |15 |} |- | colspan="36" |216 colors |- | style="color:#ffffff;background:#000000;" title="#000000" |16 | style="color:#ffffff;background:#00005f;" title="#00005f" |17 | style="color:#ffffff;background:#000087;" title="#000087" |18 | style="color:#ffffff;background:#0000af;" title="#0000af" |19 | style="color:#ffffff;background:#0000d7;" title="#0000d7" |20 | style="color:#ffffff;background:#0000ff;" title="#0000ff" |21 | style="color:#ffffff;background:#005f00;" title="#005f00" |22 | style="color:#ffffff;background:#005f5f;" title="#005f5f" |23 | style="color:#ffffff;background:#005f87;" title="#005f87" |24 | style="color:#ffffff;background:#005faf;" title="#005faf" |25 | style="color:#ffffff;background:#005fd7;" title="#005fd7" |26 | style="color:#ffffff;background:#005fff;" title="#005fff" |27 | style="color:#ffffff;background:#008700;" title="#008700" |28 | style="color:#ffffff;background:#00875f;" title="#00875f" |29 | style="color:#ffffff;background:#008787;" title="#008787" |30 | style="color:#ffffff;background:#0087af;" title="#0087af" |31 | style="color:#ffffff;background:#0087d7;" title="#0087d7" |32 | style="color:#ffffff;background:#0087ff;" title="#0087ff" |33 | style="color:#000000;background:#00af00;" title="#00af00" |34 | style="color:#000000;background:#00af5f;" title="#00af5f" |35 | style="color:#000000;background:#00af87;" title="#00af87" |36 | style="color:#000000;background:#00afaf;" title="#00afaf" |37 | style="color:#000000;background:#00afd7;" title="#00afd7" |38 | style="color:#000000;background:#00afff;" title="#00afff" |39 | style="color:#000000;background:#00d700;" title="#00d700" |40 | style="color:#000000;background:#00d75f;" title="#00d75f" |41 | style="color:#000000;background:#00d787;" title="#00d787" |42 | style="color:#000000;background:#00d7af;" title="#00d7af" |43 | style="color:#000000;background:#00d7d7;" title="#00d7d7" |44 | style="color:#000000;background:#00d7ff;" title="#00d7ff" |45 | style="color:#000000;background:#00ff00;" title="#00ff00" |46 | style="color:#000000;background:#00ff5f;" title="#00ff5f" |47 | style="color:#000000;background:#00ff87;" title="#00ff87" |48 | style="color:#000000;background:#00ffaf;" title="#00ffaf" |49 | style="color:#000000;background:#00ffd7;" title="#00ffd7" |50 | style="color:#000000;background:#00ffff;" title="#00ffff" |51 |- | style="color:#ffffff;background:#5f0000;" title="#5f0000" |52 | style="color:#ffffff;background:#5f005f;" title="#5f005f" |53 | style="color:#ffffff;background:#5f0087;" title="#5f0087" |54 | style="color:#ffffff;background:#5f00af;" title="#5f00af" |55 | style="color:#ffffff;background:#5f00d7;" title="#5f00d7" |56 | style="color:#ffffff;background:#5f00ff;" title="#5f00ff" |57 | style="color:#ffffff;background:#5f5f00;" title="#5f5f00" |58 | style="color:#ffffff;background:#5f5f5f;" title="#5f5f5f" |59 | style="color:#ffffff;background:#5f5f87;" title="#5f5f87" |60 | style="color:#ffffff;background:#5f5faf;" title="#5f5faf" |61 | style="color:#ffffff;background:#5f5fd7;" title="#5f5fd7" |62 | style="color:#ffffff;background:#5f5fff;" title="#5f5fff" |63 | style="color:#ffffff;background:#5f8700;" title="#5f8700" |64 | style="color:#ffffff;background:#5f875f;" title="#5f875f" |65 | style="color:#ffffff;background:#5f8787;" title="#5f8787" |66 | style="color:#ffffff;background:#5f87af;" title="#5f87af" |67 | style="color:#ffffff;background:#5f87d7;" title="#5f87d7" |68 | style="color:#ffffff;background:#5f87ff;" title="#5f87ff" |69 | style="color:#000000;background:#5faf00;" title="#5faf00" |70 | style="color:#000000;background:#5faf5f;" title="#5faf5f" |71 | style="color:#000000;background:#5faf87;" title="#5faf87" |72 | style="color:#000000;background:#5fafaf;" title="#5fafaf" |73 | style="color:#000000;background:#5fafd7;" title="#5fafd7" |74 | style="color:#000000;background:#5fafff;" title="#5fafff" |75 | style="color:#000000;background:#5fd700;" title="#5fd700" |76 | style="color:#000000;background:#5fd75f;" title="#5fd75f" |77 | style="color:#000000;background:#5fd787;" title="#5fd787" |78 | style="color:#000000;background:#5fd7af;" title="#5fd7af" |79 | style="color:#000000;background:#5fd7d7;" title="#5fd7d7" |80 | style="color:#000000;background:#5fd7ff;" title="#5fd7ff" |81 | style="color:#000000;background:#5fff00;" title="#5fff00" |82 | style="color:#000000;background:#5fff5f;" title="#5fff5f" |83 | style="color:#000000;background:#5fff87;" title="#5fff87" |84 | style="color:#000000;background:#5fffaf;" title="#5fffaf" |85 | style="color:#000000;background:#5fffd7;" title="#5fffd7" |86 | style="color:#000000;background:#5fffff;" title="#5fffff" |87 |- | style="color:#ffffff;background:#870000;" title="#870000" |88 | style="color:#ffffff;background:#87005f;" title="#87005f" |89 | style="color:#ffffff;background:#870087;" title="#870087" |90 | style="color:#ffffff;background:#8700af;" title="#8700af" |91 | style="color:#ffffff;background:#8700d7;" title="#8700d7" |92 | style="color:#ffffff;background:#8700ff;" title="#8700ff" |93 | style="color:#ffffff;background:#875f00;" title="#875f00" |94 | style="color:#ffffff;background:#875f5f;" title="#875f5f" |95 | style="color:#ffffff;background:#875f87;" title="#875f87" |96 | style="color:#ffffff;background:#875faf;" title="#875faf" |97 | style="color:#ffffff;background:#875fd7;" title="#875fd7" |98 | style="color:#ffffff;background:#875fff;" title="#875fff" |99 | style="color:#ffffff;background:#878700;" title="#878700" |100 | style="color:#ffffff;background:#87875f;" title="#87875f" |101 | style="color:#ffffff;background:#878787;" title="#878787" |102 | style="color:#ffffff;background:#8787af;" title="#8787af" |103 | style="color:#ffffff;background:#8787d7;" title="#8787d7" |104 | style="color:#ffffff;background:#8787ff;" title="#8787ff" |105 | style="color:#000000;background:#87af00;" title="#87af00" |106 | style="color:#000000;background:#87af5f;" title="#87af5f" |107 | style="color:#000000;background:#87af87;" title="#87af87" |108 | style="color:#000000;background:#87afaf;" title="#87afaf" |109 | style="color:#000000;background:#87afd7;" title="#87afd7" |110 | style="color:#000000;background:#87afff;" title="#87afff" |111 | style="color:#000000;background:#87d700;" title="#87d700" |112 | style="color:#000000;background:#87d75f;" title="#87d75f" |113 | style="color:#000000;background:#87d787;" title="#87d787" |114 | style="color:#000000;background:#87d7af;" title="#87d7af" |115 | style="color:#000000;background:#87d7d7;" title="#87d7d7" |116 | style="color:#000000;background:#87d7ff;" title="#87d7ff" |117 | style="color:#000000;background:#87ff00;" title="#87ff00" |118 | style="color:#000000;background:#87ff5f;" title="#87ff5f" |119 | style="color:#000000;background:#87ff87;" title="#87ff87" |120 | style="color:#000000;background:#87ffaf;" title="#87ffaf" |121 | style="color:#000000;background:#87ffd7;" title="#87ffd7" |122 | style="color:#000000;background:#87ffff;" title="#87ffff" |123 |- | style="color:#ffffff;background:#af0000;" title="#af0000" |124 | style="color:#ffffff;background:#af005f;" title="#af005f" |125 | style="color:#ffffff;background:#af0087;" title="#af0087" |126 | style="color:#ffffff;background:#af00af;" title="#af00af" |127 | style="color:#ffffff;background:#af00d7;" title="#af00d7" |128 | style="color:#ffffff;background:#af00ff;" title="#af00ff" |129 | style="color:#ffffff;background:#af5f00;" title="#af5f00" |130 | style="color:#ffffff;background:#af5f5f;" title="#af5f5f" |131 | style="color:#ffffff;background:#af5f87;" title="#af5f87" |132 | style="color:#ffffff;background:#af5faf;" title="#af5faf" |133 | style="color:#ffffff;background:#af5fd7;" title="#af5fd7" |134 | style="color:#ffffff;background:#af5fff;" title="#af5fff" |135 | style="color:#ffffff;background:#af8700;" title="#af8700" |136 | style="color:#ffffff;background:#af875f;" title="#af875f" |137 | style="color:#ffffff;background:#af8787;" title="#af8787" |138 | style="color:#ffffff;background:#af87af;" title="#af87af" |139 | style="color:#ffffff;background:#af87d7;" title="#af87d7" |140 | style="color:#ffffff;background:#af87ff;" title="#af87ff" |141 | style="color:#000000;background:#afaf00;" title="#afaf00" |142 | style="color:#000000;background:#afaf5f;" title="#afaf5f" |143 | style="color:#000000;background:#afaf87;" title="#afaf87" |144 | style="color:#000000;background:#afafaf;" title="#afafaf" |145 | style="color:#000000;background:#afafd7;" title="#afafd7" |146 | style="color:#000000;background:#afafff;" title="#afafff" |147 | style="color:#000000;background:#afd700;" title="#afd700" |148 | style="color:#000000;background:#afd75f;" title="#afd75f" |149 | style="color:#000000;background:#afd787;" title="#afd787" |150 | style="color:#000000;background:#afd7af;" title="#afd7af" |151 | style="color:#000000;background:#afd7d7;" title="#afd7d7" |152 | style="color:#000000;background:#afd7ff;" title="#afd7ff" |153 | style="color:#000000;background:#afff00;" title="#afff00" |154 | style="color:#000000;background:#afff5f;" title="#afff5f" |155 | style="color:#000000;background:#afff87;" title="#afff87" |156 | style="color:#000000;background:#afffaf;" title="#afffaf" |157 | style="color:#000000;background:#afffd7;" title="#afffd7" |158 | style="color:#000000;background:#afffff;" title="#afffff" |159 |- | style="color:#ffffff;background:#d70000;" title="#d70000" |160 | style="color:#ffffff;background:#d7005f;" title="#d7005f" |161 | style="color:#ffffff;background:#d70087;" title="#d70087" |162 | style="color:#ffffff;background:#d700af;" title="#d700af" |163 | style="color:#ffffff;background:#d700d7;" title="#d700d7" |164 | style="color:#ffffff;background:#d700ff;" title="#d700ff" |165 | style="color:#ffffff;background:#d75f00;" title="#d75f00" |166 | style="color:#ffffff;background:#d75f5f;" title="#d75f5f" |167 | style="color:#ffffff;background:#d75f87;" title="#d75f87" |168 | style="color:#ffffff;background:#d75faf;" title="#d75faf" |169 | style="color:#ffffff;background:#d75fd7;" title="#d75fd7" |170 | style="color:#ffffff;background:#d75fff;" title="#d75fff" |171 | style="color:#ffffff;background:#d78700;" title="#d78700" |172 | style="color:#ffffff;background:#d7875f;" title="#d7875f" |173 | style="color:#ffffff;background:#d78787;" title="#d78787" |174 | style="color:#ffffff;background:#d787af;" title="#d787af" |175 | style="color:#ffffff;background:#d787d7;" title="#d787d7" |176 | style="color:#ffffff;background:#d787ff;" title="#d787ff" |177 | style="color:#000000;background:#d7af00;" title="#d7af00" |178 | style="color:#000000;background:#d7af5f;" title="#d7af5f" |179 | style="color:#000000;background:#d7af87;" title="#d7af87" |180 | style="color:#000000;background:#d7afaf;" title="#d7afaf" |181 | style="color:#000000;background:#d7afd7;" title="#d7afd7" |182 | style="color:#000000;background:#d7afff;" title="#d7afff" |183 | style="color:#000000;background:#d7d700;" title="#d7d700" |184 | style="color:#000000;background:#d7d75f;" title="#d7d75f" |185 | style="color:#000000;background:#d7d787;" title="#d7d787" |186 | style="color:#000000;background:#d7d7af;" title="#d7d7af" |187 | style="color:#000000;background:#d7d7d7;" title="#d7d7d7" |188 | style="color:#000000;background:#d7d7ff;" title="#d7d7ff" |189 | style="color:#000000;background:#d7ff00;" title="#d7ff00" |190 | style="color:#000000;background:#d7ff5f;" title="#d7ff5f" |191 | style="color:#000000;background:#d7ff87;" title="#d7ff87" |192 | style="color:#000000;background:#d7ffaf;" title="#d7ffaf" |193 | style="color:#000000;background:#d7ffd7;" title="#d7ffd7" |194 | style="color:#000000;background:#d7ffff;" title="#d7ffff" |195 |- | style="color:#ffffff;background:#ff0000;" title="#ff0000" |196 | style="color:#ffffff;background:#ff005f;" title="#ff005f" |197 | style="color:#ffffff;background:#ff0087;" title="#ff0087" |198 | style="color:#ffffff;background:#ff00af;" title="#ff00af" |199 | style="color:#ffffff;background:#ff00d7;" title="#ff00d7" |200 | style="color:#ffffff;background:#ff00ff;" title="#ff00ff" |201 | style="color:#ffffff;background:#ff5f00;" title="#ff5f00" |202 | style="color:#ffffff;background:#ff5f5f;" title="#ff5f5f" |203 | style="color:#ffffff;background:#ff5f87;" title="#ff5f87" |204 | style="color:#ffffff;background:#ff5faf;" title="#ff5faf" |205 | style="color:#ffffff;background:#ff5fd7;" title="#ff5fd7" |206 | style="color:#ffffff;background:#ff5fff;" title="#ff5fff" |207 | style="color:#ffffff;background:#ff8700;" title="#ff8700" |208 | style="color:#ffffff;background:#ff875f;" title="#ff875f" |209 | style="color:#ffffff;background:#ff8787;" title="#ff8787" |210 | style="color:#ffffff;background:#ff87af;" title="#ff87af" |211 | style="color:#ffffff;background:#ff87d7;" title="#ff87d7" |212 | style="color:#ffffff;background:#ff87ff;" title="#ff87ff" |213 | style="color:#000000;background:#ffaf00;" title="#ffaf00" |214 | style="color:#000000;background:#ffaf5f;" title="#ffaf5f" |215 | style="color:#000000;background:#ffaf87;" title="#ffaf87" |216 | style="color:#000000;background:#ffafaf;" title="#ffafaf" |217 | style="color:#000000;background:#ffafd7;" title="#ffafd7" |218 | style="color:#000000;background:#ffafff;" title="#ffafff" |219 | style="color:#000000;background:#ffd700;" title="#ffd700" |220 | style="color:#000000;background:#ffd75f;" title="#ffd75f" |221 | style="color:#000000;background:#ffd787;" title="#ffd787" |222 | style="color:#000000;background:#ffd7af;" title="#ffd7af" |223 | style="color:#000000;background:#ffd7d7;" title="#ffd7d7" |224 | style="color:#000000;background:#ffd7ff;" title="#ffd7ff" |225 | style="color:#000000;background:#ffff00;" title="#ffff00" |226 | style="color:#000000;background:#ffff5f;" title="#ffff5f" |227 | style="color:#000000;background:#ffff87;" title="#ffff87" |228 | style="color:#000000;background:#ffffaf;" title="#ffffaf" |229 | style="color:#000000;background:#ffffd7;" title="#ffffd7" |230 | style="color:#000000;background:#ffffff;" title="#ffffff" |231 |- |- | colspan="36" |Grayscale colors |- | colspan="36" | {| style="width:100%;text-align:center;font-weight:bold;" |- | style="color:#ffffff;background:#080808;" title="#080808" |232 | style="color:#ffffff;background:#121212;" title="#121212" |233 | style="color:#ffffff;background:#1c1c1c;" title="#1c1c1c" |234 | style="color:#ffffff;background:#262626;" title="#262626" |235 | style="color:#ffffff;background:#303030;" title="#303030" |236 | style="color:#ffffff;background:#3a3a3a;" title="#3a3a3a" |237 | style="color:#ffffff;background:#444444;" title="#444444" |238 | style="color:#ffffff;background:#4e4e4e;" title="#4e4e4e" |239 | style="color:#ffffff;background:#585858;" title="#585858" |240 | style="color:#ffffff;background:#626262;" title="#626262" |241 | style="color:#ffffff;background:#6c6c6c;" title="#6c6c6c" |242 | style="color:#ffffff;background:#767676;" title="#767676" |243 | style="color:#000000;background:#808080;" title="#808080" |244 | style="color:#000000;background:#8a8a8a;" title="#8a8a8a" |245 | style="color:#000000;background:#949494;" title="#949494" |246 | style="color:#000000;background:#9e9e9e;" title="#9e9e9e" |247 | style="color:#000000;background:#a8a8a8;" title="#a8a8a8" |248 | style="color:#000000;background:#b2b2b2;" title="#b2b2b2" |249 | style="color:#000000;background:#bcbcbc;" title="#bcbcbc" |250 | style="color:#000000;background:#c6c6c6;" title="#c6c6c6" |251 | style="color:#000000;background:#d0d0d0;" title="#d0d0d0" |252 | style="color:#000000;background:#dadada;" title="#dadada" |253 | style="color:#000000;background:#e4e4e4;" title="#e4e4e4" |254 | style="color:#000000;background:#eeeeee;" title="#eeeeee" |255 |} |} To calculate the RGB Value of a code in the 6 x 6 x 6 color cube, the following code can be used: <syntaxhighlight lang="python" line> # print a list of the 256-color red/green/blue values used by xterm. # # reference: # https://github.com/ThomasDickey/ncurses-snapshots/blob/master/test/xterm-16color.dat # https://github.com/ThomasDickey/xterm-snapshots/blob/master/XTerm-col.ad # https://github.com/ThomasDickey/xterm-snapshots/blob/master/256colres.pl print("colors 0-16 correspond to the ANSI and aixterm naming") for code in range(0, 16): if code > 8: level = 255 elif code == 7: level = 229 else: level = 205 r = 127 if code == 8 else level if (code & 1) != 0 else 92 if code == 12 else 0 g = 127 if code == 8 else level if (code & 2) != 0 else 92 if code == 12 else 0 b = 127 if code == 8 else 238 if code == 4 else level if (code & 4) != 0 else 0 print(f"{code:3d}: {r:02X} {g:02X} {b:02X}") print("colors 16-231 are a 6x6x6 color cube") for red in range(0, 6): for green in range(0, 6): for blue in range(0, 6): code = 16 + (red * 36) + (green * 6) + blue r = red * 40 + 55 if red != 0 else 0 g = green * 40 + 55 if green != 0 else 0 b = blue * 40 + 55 if blue != 0 else 0 print(f"{code:3d}: {r:02X} {g:02X} {b:02X}") print("colors 232-255 are a grayscale ramp, intentionally leaving out black and white") code = 232 for gray in range(0, 24): level = gray * 10 + 8 code = 232 + gray print(f"{code:3d}: {level:02X} {level:02X} {level:02X}") </syntaxhighlight> There has also been a similar but incompatible 88-color encoding using the same escape sequence, seen in {{code|rxvt}} and {{code|xterm-88color}}.<ref>{{cite web |url=https://invisible-island.net/ncurses/ncurses.faq.html#xterm_256color |title=Ncurses FAQ: Why not make "xterm" equated to "xterm-256color"? |author-first=Thomas E. |author-last=Dickey |accessdate=March 28, 2025}}</ref> It uses a 4Γ4Γ4 color cube.
Summary:
Please note that all contributions to Niidae Wiki may be edited, altered, or removed by other contributors. If you do not want your writing to be edited mercilessly, then do not submit it here.
You are also promising us that you wrote this yourself, or copied it from a public domain or similar free resource (see
Encyclopedia:Copyrights
for details).
Do not submit copyrighted work without permission!
Cancel
Editing help
(opens in new window)
Search
Search
Editing
ANSI escape code
(section)
Add topic