颜色编码机制
为解决驾驶台光线变化带来的显示效果总是,S-52制定了电子海图的颜色规范,能够通过航海人员的设置调节显示屏幕的背景和各种物标符号与线边界的颜色。S-52中规定了三种配色方案,分别是白天(Day)配色表、黄昏(Dusk)配色表和夜晚(Night)配色表。
ECDIS表示库的颜色以五个字符代码命名,反映其用法,例如颜色“CHMGD”表示“chart magenta,dominant”。 这缩写被称为“颜色标记 Colour Tokens”,其中颜色标识所代表的具体颜色由CIE参数决定。
国际照明委员会(CIE,Commission Internationale de L'Eclairage / International)的色度模型是最早使用的三维模型之一,其中,x和y两维定义颜色,第3维L定义亮度。该模型描述的颜色与设备无关,排除了色彩在复制传递过程中,由于使用不同的显示器而带来的差异。此外,使用该模型还有一个好处是,不同配色表下的相同标记的颜色只是亮度不同。但图形库不能直接使用CIE xyL的颜色系统,需要将其转换成日常使用的RGB颜色。
颜色标识 | 白天RGB | 黄昏RGB | 夜晚RGB |
---|---|---|---|
NODTA | grey (163,180,183) | grey (41,46,46) | black (7,7,7) |
CURSR | orange (235,125,54) | orange (75,38,19) | orange (52,28,12) |
CHBLK | black (7,7,7) | grey (54,60,61) | grey (31,34,35) |
CHGRD | grey (125,137,140) | grey (54,60,61) | grey (31,34,35) |
CHGRF | grey (163,180,183) | grey (41,46,46) | grey (16,18,18) |
CHRED | red (241,84,105) | red (80,28,35) | red (59,17,10) |
CHGRN | green (104,228,86) | green (35,76,29) | green (22,34,7) |
CHYLW | yellow (244,218,72) | yellow (81,73,24) | yellow (41,33,10) |
CHMGD | magenta (197,69,195) | magenta (74,58,81) | magenta (52,18,52) |
CHMGF | magenta (211,166,233) | magenta (58,20,57) | magenta (52,18,52) |
CHBRN | brown (177,145,57) | brown (54,44,17) | brown (15,13,5) |
CHWHT | white (212,234,238) | white (71,78,79) | white (37,41,41) |
SCLBR | orange (235,125,54) | orange (75,38,19) | orange (52,28,12) |
CHCOR | orange (235,125,54) | orange (75,38,19) | orange (52,28,12) |
LITRD | red (241,84,105) | red (80,28,35) | red (59,17,10) |
LITGN | green (104,228,86) | green (35,76,29) | green (22,34,7) |
LITYW | yellow (244,218,72) | yellow (81,73,24) | yellow (41,33,10) |
ISDNG | magenta (197,69,195) | magenta (74,58,81) | magenta (52,18,52) |
DNGHL | red (241,84,105) | red (80,28,35) | red (59,17,10) |
TRFCD | magenta (197,69,195) | magenta (74,58,81) | magenta (58,20,58) |
TRFCF | magenta (211,166,233) | magenta (58,20,57) | magenta (52,18,52) |
LANDA | brown (201,185,122) | brown (44,41,27) | brown (13,10,8) |
LANDF | brown (139,102,31) | brown (76,56,17) | brown (23,17,5) |
CSTLN | grey (82,90,92) | grey (54,60,61) | white (37,41,41) |
SNDG1 | grey (125,137,140) | grey (41,46,46) | grey (31,34,35) |
SNDG2 | black (7,7,7) | white (71,78,79) | white (43,48,48) |
DEPSC | grey (82,90,92) | grey (54,60,61) | white (37,41,41) |
DEPCN | grey (125,137,140) | grey (41,46,46) | grey (31,34,35) |
DEPDW | white (212,234,238) | black (7,7,7) | black (7,7,7) |
DEPMD | pale_blue (186,213,225) | dark_blue (12,14,15) | black (7,7,7) |
DEPMS | light_blue (152,197,242) | medium_blue (21,27,33) | dark-blue (3,4,19) |
DEPVS | medium_blue (115,182,239) | light_blue (22,35,47) | dark-blue (3,4,19) |
DEPIT | yellow-green (131,178,149) | yellow-green (21,37,31) | yellow-green (8,11,9) |
RADHI | green (104,228,86) | green (35,76,29) | green (22,34,7) |
RADLO | green (63,138,52) | green (21,46,17) | green (10,16,3) |
ARPAT | green (63,165,111) | green (26,69,47) | green (12,31,21) |
NINFO | orange (235,125,54) | orange (75,38,19) | orange (52,28,12) |
RESBL | blue (58,120,240) | blue (19,40,80) | blue (21,29,69) |
ADINF | yellow (178,159,52) | yellow (59,53,17) | yellow (41,33,10) |
RESGR | grey (125,137,140) | grey (41,46,46) | grey (16,18,18) |
SHIPS | black (7,7,7) | white (71,78,79) | white (37,41,41) |
PSTRK | black (7,7,7) | white (71,78,79) | white (37,41,41) |
SYTRK | grey (125,137,140) | grey (41,46,46) | grey (31,34,35) |
PLRTE | red (220,64,37) | red (73,21,12) | red (66,19,11) |
APLRT | orange (235,125,54) | orange (75,38,19) | orange (52,28,12) |
UIBCK | white (7,7,7) | black (71,78,79) | black (43,48,48) |
UIBDR | bottomshadow (125,137,140) | bottomshadow (41,46,46) | bottomshadow (31,34,35) |
UIAFD | background (212,234,238) | background (7,7,7) | background (7,7,7) |
UIAFF | arm (115,182,239) | arm (22,35,47) | arm (3,4,19) |
UINFD | black (241,84,105) | white (80,28,35) | white (59,17,10) |
UINFF | topshadow (104,228,86) | topshadow (35,76,29) | topshadow (22,34,7) |
UINFR | red (235,125,54) | red (75,38,19) | red (52,28,12) |
UINFG | green (58,120,240) | green (19,40,80) | green (21,29,69) |
UINFO | orangehighlight (197,69,195) | orange (58,20,57) | orange (52,18,52) |
UINFB | blue (125,137,140) | blue (54,60,61) | blue (31,34,35) |
UINFM | magenta (201,185,122) | magenta (44,41,27) | magenta (13,10,8) |
OUTLW | black (7,7,7) | black (7,7,7) | black (7,7,7) |
OUTLL | brown (201,185,122) | brown (44,41,27) | brown (13,10,8) |
RES01 | grey (163,180,183) | grey (41,46,46) | black (7,7,7) |
RES02 | grey (163,180,183) | grey (41,46,46) | black (7,7,7) |
RES03 | grey (163,180,183) | grey (41,46,46) | black (7,7,7) |
BKAJ1 | black (7,7,7) | black (7,7,7) | black (7,7,7) |
BKAJ2 | grey (35,39,40) | grey (11,13,13) | grey (7,8,8) |
在项目S57Viewer
新建配色表枚举类ColorScheme
:
public enum ColorScheme
{
Day,
Dusk,
NIght
}
在项目S57Viewer
新建静态类MySettings
,存储用户的全局设置。将之前是否显示经纬度网格的字段迁移过来,并添加新字段存储用户配色表
。
public static class MySettings
{
public static bool IsDisplayGraticule = true; //是否显示经纬度网格
public static ColorScheme ColorScheme = ColorScheme.Day; //用户显示
}
在项目S57Viewer
新建单例模式的类S52Colors
,对外提供颜色标记的索引器,而用户当前设置的显示被存在全局变量中。如:获取标记为"LANDA"的颜色S52Colors.Instance["LANDA"]
。
public sealed class S52Colors
{
private static readonly S52Colors instance = new S52Colors();
//显示的static 构造函数
static S52Colors() { }
private S52Colors() { }
public static S52Colors Instance => instance;
Dictionary<ColorScheme, Dictionary<string, SKColor>> colors =
new Dictionary<ColorScheme, Dictionary<string, SKColor>>()
{
{
ColorScheme.Day, new Dictionary<string, SKColor> //白天配色表
{
{ "NODTA", new SKColor(163, 180, 183) },
{ "CURSR", new SKColor(235, 125, 54) },
// ...
}
},
{
ColorScheme.Dusk, new Dictionary<string, SKColor> //黄昏配色表
{
{ "NODTA", new SKColor(41, 46, 46) },
{ "CURSR", new SKColor(75, 38, 19) },
// ...
}
},
{
ColorScheme.NIght, new Dictionary<string, SKColor> //夜晚配色表
{
{ "NODTA", new SKColor(7, 7, 7) },
{ "CURSR", new SKColor(52, 28, 12) },
// ...
}
}
};
public SKColor this[string acronym] => colors[MySettings.ColorScheme][acronym];
}