简体   繁体   English

用于xterm-256的256位图像掩码

[英]256 bit image mask for xterm-256

I am using ncurses with c++ on a xterm-256 display and I would like to print my text in shades of red, but I'm having trouble finding a simple way to do this. 我在xterm-256显示器上将ncursesc++一起使用,我想以红色阴影打印文本,但是我很难找到一种简单的方法来做到这一点。

Using this chart I can see that 0x009 is red and that 0x255 - 0x232 will be various shades of black. 使用这个图表我可以看到, 0x009是红色和0x255 - 0x232将是黑色的色块。 How can I go about using this information to form a mast for my colors? 如何使用这些信息来形成我的颜色的桅杆?

I would basically like to form a map such that 10 means white and 20 means red, such that 15 would be pink and so on. 我基本上想构成一张地图,以10表示白色,以20表示红色,以15表示粉红色,依此类推。 I would then create color pairs with 然后,我将使用

init_pair(10, ???, COLOR_BLACK);
init_pair(11, ???, COLOR_BLACK);
...
init_pair(20, ???, COLOR_BLACK);

so that I could use these colors later to shade from white to red. 这样我以后就可以使用这些颜色从白色变为红色。

It depends on what assumptions you want to make. 这取决于您要做出的假设。 The layout of the xterm 256color feature is a given, with three parts: xterm 256color功能的布局是给定的,分为三个部分:

  1. colors 0-15 are ANSI colors and bright versions of those. 颜色0-15是ANSI颜色,是这些颜色的明亮版本。
  2. colors 16-231 are a 6x6x6 color cube 颜色16-231是6x6x6彩色立方体
  3. colors 232-255 are a grayscale ramp, intentionally leaving out black and white 颜色232-255是灰度渐变,有意省略了黑白

See for example 256color.pl (widely copied from xterm sources). 参见例如256color.pl (从xterm来源广泛复制)。 The numbers make more sense than the chart when you see the picture: 看到图片时,数字比图表更有意义:

在此处输入图片说明

You could simply refer to those color numbers in init_pair . 您可以简单地在init_pair引用这些颜色编号。 Bright red as you have noticed is 9 ( COLOR_RED + 8). 如您COLOR_RED鲜红色为9( COLOR_RED + 8)。

On the other hand, the color palette can be modified. 另一方面,可以修改调色板。 You could use init_color (giving your own red/green/blue triple) to define a color by number, and use that in init_pair . 您可以使用init_color (赋予您自己的红色/绿色/蓝色三色)按数字定义颜色,然后在init_pair使用 init_pair

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM