32 static LDColor* g_LDColors[MAX_COLORS]; |
32 static LDColor* g_LDColors[MAX_COLORS]; |
33 |
33 |
34 // ============================================================================= |
34 // ============================================================================= |
35 // ----------------------------------------------------------------------------- |
35 // ----------------------------------------------------------------------------- |
36 void initColors() |
36 void initColors() |
37 { LDColor* col; |
37 { |
|
38 LDColor* col; |
38 log ("%1: initializing color information.\n", __func__); |
39 log ("%1: initializing color information.\n", __func__); |
39 |
40 |
40 // Always make sure there's 16 and 24 available. They're special like that. |
41 // Always make sure there's 16 and 24 available. They're special like that. |
41 col = new LDColor; |
42 col = new LDColor; |
42 col->faceColor = col->hexcode = "#AAAAAA"; |
43 col->faceColor = col->hexcode = "#AAAAAA"; |
51 } |
52 } |
52 |
53 |
53 // ============================================================================= |
54 // ============================================================================= |
54 // ----------------------------------------------------------------------------- |
55 // ----------------------------------------------------------------------------- |
55 LDColor* getColor (int colnum) |
56 LDColor* getColor (int colnum) |
56 { // Check bounds |
57 { |
|
58 // Check bounds |
57 if (colnum < 0 || colnum >= MAX_COLORS) |
59 if (colnum < 0 || colnum >= MAX_COLORS) |
58 return null; |
60 return null; |
59 |
61 |
60 return g_LDColors[colnum]; |
62 return g_LDColors[colnum]; |
61 } |
63 } |
62 |
64 |
63 // ============================================================================= |
65 // ============================================================================= |
64 // ----------------------------------------------------------------------------- |
66 // ----------------------------------------------------------------------------- |
65 void setColor (int colnum, LDColor* col) |
67 void setColor (int colnum, LDColor* col) |
66 { if (colnum < 0 || colnum >= MAX_COLORS) |
68 { |
|
69 if (colnum < 0 || colnum >= MAX_COLORS) |
67 return; |
70 return; |
68 |
71 |
69 g_LDColors[colnum] = col; |
72 g_LDColors[colnum] = col; |
70 } |
73 } |
71 |
74 |
72 // ============================================================================= |
75 // ============================================================================= |
73 // ----------------------------------------------------------------------------- |
76 // ----------------------------------------------------------------------------- |
74 int luma (QColor& col) |
77 int luma (QColor& col) |
75 { return (0.2126f * col.red()) + |
78 { |
|
79 return (0.2126f * col.red()) + |
76 (0.7152f * col.green()) + |
80 (0.7152f * col.green()) + |
77 (0.0722f * col.blue()); |
81 (0.0722f * col.blue()); |
78 } |
82 } |