<?xml version="1.0" encoding="utf-8"?>
<rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:foaf="http://xmlns.com/foaf/0.1/" xmlns:og="http://ogp.me/ns#" xmlns:rdfs="http://www.w3.org/2000/01/rdf-schema#" xmlns:schema="http://schema.org/" xmlns:sioc="http://rdfs.org/sioc/ns#" xmlns:sioct="http://rdfs.org/sioc/types#" xmlns:skos="http://www.w3.org/2004/02/skos/core#" xmlns:xsd="http://www.w3.org/2001/XMLSchema#" version="2.0" xml:base="https://www.linuxjournal.com/">
  <channel>
    <title>color</title>
    <link>https://www.linuxjournal.com/</link>
    <description/>
    <language>en</language>
    
    <item>
  <title>About ncurses Colors</title>
  <link>https://www.linuxjournal.com/content/about-ncurses-colors-0</link>
  <description>  &lt;div data-history-node-id="1340201" class="layout layout--onecol"&gt;
    &lt;div class="layout__region layout__region--content"&gt;
      
            &lt;div class="field field--name-node-author field--type-ds field--label-hidden field--item"&gt;by &lt;a title="View user profile." href="https://www.linuxjournal.com/users/jim-hall" lang="" about="https://www.linuxjournal.com/users/jim-hall" typeof="schema:Person" property="schema:name" datatype="" xml:lang=""&gt;Jim Hall&lt;/a&gt;&lt;/div&gt;
      
            &lt;div class="field field--name-body field--type-text-with-summary field--label-hidden field--item"&gt;&lt;p&gt;&lt;em&gt;Why does ncurses support only eight colors?&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;
If you've looked into the color palette available in curses, you may
wonder why curses supports only eight colors. The curses.h include file
defines these color macros:

&lt;/p&gt;&lt;pre&gt;
&lt;code&gt;
COLOR_BLACK
COLOR_RED
COLOR_GREEN
COLOR_YELLOW
COLOR_BLUE
COLOR_MAGENTA
COLOR_CYAN
COLOR_WHITE
&lt;/code&gt;
&lt;/pre&gt;


&lt;p&gt;
But why only eight colors, and why these particular colors? At least with the Linux
console, if you're running on a PC, the color range's origins are
with the PC hardware.
&lt;/p&gt;

&lt;span class="h3-replacement"&gt;
A Brief History of Color&lt;/span&gt;

&lt;p&gt;
Linux started as a PC operating system, so the first Linux console was a PC
running in text mode. And to understand the color palette on the PC console,
you need to go all the way back to the old CGA days. In text mode, the PC
terminal had a color palette of 16 colors, enumerated 0 (black) to 15
(white). Backgrounds were limited to the first eight colors:
&lt;/p&gt;

&lt;ul&gt;&lt;li&gt;
0. Black
&lt;/li&gt;

&lt;li&gt;
1. Blue
&lt;/li&gt;

&lt;li&gt;
2. Green
&lt;/li&gt;

&lt;li&gt;
3. Cyan
&lt;/li&gt;

&lt;li&gt;
4. Red
&lt;/li&gt;

&lt;li&gt;
5. Magenta
&lt;/li&gt;

&lt;li&gt;
6. Brown
&lt;/li&gt;

&lt;li&gt;
7. White ("Light Gray")
&lt;/li&gt;

&lt;li&gt;
8. Bright Black ("Gray")
&lt;/li&gt;

&lt;li&gt;
9. Bright Blue
&lt;/li&gt;

&lt;li&gt;
10. Bright Green
&lt;/li&gt;

&lt;li&gt;
11. Bright Cyan
&lt;/li&gt;

&lt;li&gt;
12. Bright Red
&lt;/li&gt;

&lt;li&gt;
13. Bright Magenta
&lt;/li&gt;

&lt;li&gt;
14. Yellow
&lt;/li&gt;

&lt;li&gt;
15. Bright White
&lt;/li&gt;&lt;/ul&gt;&lt;p&gt;
These colors go back to CGA, IBM's Color/Graphics Adapter from the
earlier PC-compatible computers. This was a step up from the plain
monochrome displays; as the name implies, monochrome could display
only black or white. CGA could display a limited range of colors.
&lt;/p&gt;

&lt;p&gt;
CGA supports mixing red (R), green (G) and blue (B) colors. In its simplest
form, RGB is either "on" or "off". In this case, you can mix the RGB colors
in 2x2x2=8 ways. Table 1 shows the
binary and decimal representations of RGB.
&lt;/p&gt;

&lt;table&gt;&lt;span class="h3-replacement"&gt;Table 1. Binary and Decimal Representations of RGB&lt;/span&gt;


&lt;tbody&gt;&lt;tr&gt;&lt;td&gt;000&lt;/td&gt;
&lt;td&gt;(0)&lt;/td&gt;
&lt;td&gt;Black&lt;/td&gt;
&lt;/tr&gt;&lt;tr&gt;&lt;td&gt;001&lt;/td&gt;
&lt;td&gt;(1)&lt;/td&gt;
&lt;td&gt;Blue&lt;/td&gt;
&lt;/tr&gt;&lt;tr&gt;&lt;td&gt;010&lt;/td&gt;
&lt;td&gt;(2)&lt;/td&gt;
&lt;td&gt;Green&lt;/td&gt;
&lt;/tr&gt;&lt;tr&gt;&lt;td&gt;
011&lt;/td&gt;
&lt;td&gt;(3)&lt;/td&gt;
&lt;td&gt;Cyan&lt;/td&gt;
&lt;/tr&gt;&lt;tr&gt;&lt;td&gt;
100&lt;/td&gt;
&lt;td&gt;(4)&lt;/td&gt;
&lt;td&gt;Red&lt;/td&gt;
&lt;/tr&gt;&lt;tr&gt;&lt;td&gt;101&lt;/td&gt;
&lt;td&gt;(5)&lt;/td&gt;
&lt;td&gt;Magenta&lt;/td&gt;
&lt;/tr&gt;&lt;tr&gt;&lt;td&gt;
110&lt;/td&gt;
&lt;td&gt;(6)&lt;/td&gt;
&lt;td&gt;Yellow&lt;/td&gt;
&lt;/tr&gt;&lt;tr&gt;&lt;td&gt;111&lt;/td&gt;
&lt;td&gt;(7)&lt;/td&gt;
&lt;td&gt;White&lt;/td&gt;
&lt;/tr&gt;&lt;/tbody&gt;&lt;/table&gt;&lt;p&gt;
To double the number of colors, CGA added an extra bit called the
"intensifier" bit. With the intensifier bit set, the red, green and blue
colors would be set to their maximum values. Without the intensifier bit,
each RGB value would be set to a "midrange" intensity. Let's represent that
intensifier bit as an extra 1 or 0 in the binary color representation, as
iRGB (Table 2).

&lt;/p&gt;&lt;/div&gt;
      
            &lt;div class="field field--name-node-link field--type-ds field--label-hidden field--item"&gt;  &lt;a href="https://www.linuxjournal.com/content/about-ncurses-colors-0" hreflang="en"&gt;Go to Full Article&lt;/a&gt;
&lt;/div&gt;
      
    &lt;/div&gt;
  &lt;/div&gt;

</description>
  <pubDate>Thu, 13 Dec 2018 13:00:00 +0000</pubDate>
    <dc:creator>Jim Hall</dc:creator>
    <guid isPermaLink="false">1340201 at https://www.linuxjournal.com</guid>
    </item>

  </channel>
</rss>
