ncurses 的 init_color 函数如何转换为传统的 rbg 颜色?
How does ncurses' init_color function translate to traditional rbg colors?
抱歉标题措辞奇怪。我想知道 ncurses init_color 函数如何将其输入映射到颜色。本质上,大多数开发人员习惯于在 0 - 255 范围内用红色、绿色和蓝色表示颜色,但 init_color 采用 0 - 1000 范围内的整数。
例如:
如果我想在 ncurses 中获得颜色 (75, 0, 130)
,我会调用 init_color(COLOR_NAME, 300, 0, 520)
吗?
短:
(n) * 1000 / 256
这与你的数字有点不同:
293 0 508
long:这当然假设终端描述是为了匹配 ncurses' documentation. But the assumption is from X/Open Curses:
The init_color()
function redefines colour number color, on terminals that support the redefinition of colours, to have the red, green, and blue intensity components specified by red, green, and blue, respectively. Calling init_color() also changes all occurrences of the specified colour on the screen to the new definition.
The color_content()
function identifies the intensity components of colour number color. It stores the red, green, and blue intensity components of this colour in the addresses pointed to by red, green, and blue, respectively.
For both functions, the color argument must be in the range from 0 to and including COLORS-1. Valid intensity values range from 0 (no intensity component) up to and including 1000 (maximum intensity in that component).
抱歉标题措辞奇怪。我想知道 ncurses init_color 函数如何将其输入映射到颜色。本质上,大多数开发人员习惯于在 0 - 255 范围内用红色、绿色和蓝色表示颜色,但 init_color 采用 0 - 1000 范围内的整数。
例如:
如果我想在 ncurses 中获得颜色 (75, 0, 130)
,我会调用 init_color(COLOR_NAME, 300, 0, 520)
吗?
短:
(n) * 1000 / 256
这与你的数字有点不同:
293 0 508
long:这当然假设终端描述是为了匹配 ncurses' documentation. But the assumption is from X/Open Curses:
The
init_color()
function redefines colour number color, on terminals that support the redefinition of colours, to have the red, green, and blue intensity components specified by red, green, and blue, respectively. Calling init_color() also changes all occurrences of the specified colour on the screen to the new definition.The
color_content()
function identifies the intensity components of colour number color. It stores the red, green, and blue intensity components of this colour in the addresses pointed to by red, green, and blue, respectively.For both functions, the color argument must be in the range from 0 to and including COLORS-1. Valid intensity values range from 0 (no intensity component) up to and including 1000 (maximum intensity in that component).