6
char* RGB(double R, double G, double B);
7
char* RGB(double R, double G, double B){
34
for (int i = 0; i < 6; i++){
42
float aci_to_rgb(int aci);
44
float aci_to_rgb(int aci)
46
aci = abs(aci); // hidden layers have negative color values
47
if (aci<10 || aci>249) // values of these ranges are special colors
51
case 1: return RGB(255,0,0); // basic colors
52
case 2: return RGB(255,255,0);
53
case 3: return RGB(0,255,0);
54
case 4: return RGB(0,255,255);
55
case 5: return RGB(0,0,255);
56
case 6: return RGB(255,0,255);
57
case 7: return RGB(255,255,255);
58
case 8: return RGB(128,128,128);
59
case 9: return RGB(192,192,192);
60
case 250: return RGB(51,51,51); // grey shades
61
case 251: return RGB(91,91,91);
62
case 252: return RGB(132,132,132);
63
case 253: return RGB(173,173,173);
64
case 254: return RGB(214,214,214);
65
case 255: return RGB(255,255,255);
66
case 256: // "by layer"
67
// Here you should decide how to handle "by layer" logical color.
68
// Maybe it is a good idea to return a value like -1.
69
// The outer code will find what is the color of the layer which
70
// this entity belongs to.
74
// for all the rest of ACI codes
76
int remainder = aci % 10;
77
H = 1.5f * (aci - remainder - 10); // hue in range 0-360
78
S = ((aci % 2) ? 0.5f : 1.0f); // odd colors have 50% of saturation, even - 100%
79
// set lighteness, the last digit of aci code stands for this
80
if (reminder == 0 || reminder == 1) L = 1.0f;
81
if (reminder == 2 || reminder == 3) L = 0.8f;
82
if (reminder == 4 || reminder == 5) L = 0.6f;
83
if (reminder == 6 || reminder == 7) L = 0.5f;
84
if (reminder == 8 || reminder == 9) L = 0.3f;
85
// here we have H,S,L set already
86
// let's convert it to RGB, first without consideration of S and L
108
// influence of S and L
109
float max_value = max(R,max(G,B));
110
R = (max_value-S*(max_value-R)) * L * 255;
111
G = (max_value-S*(max_value-G)) * L * 255;
112
B = (max_value-S*(max_value-B)) * L * 255;
b'\\ No newline at end of file'