src/colors.cc

changeset 861
83426c5fa732
parent 849
4af6f977d04b
child 927
409b82a4765e
child 946
9cbd658b63f9
equal deleted inserted replaced
860:a496e72af069 861:83426c5fa732
24 #include "ldConfig.h" 24 #include "ldConfig.h"
25 #include <QColor> 25 #include <QColor>
26 26
27 static LDColor g_LDConfigColors[512]; 27 static LDColor g_LDConfigColors[512];
28 28
29 void initColors() 29 void InitColors()
30 { 30 {
31 LDColorData* col; 31 LDColorData* col;
32 print ("Initializing color information.\n"); 32 print ("Initializing color information.\n");
33 33
34 // Always make sure there's 16 and 24 available. They're special like that. 34 // Always make sure there's 16 and 24 available. They're special like that.
35 col = new LDColorData; 35 col = new LDColorData;
36 col->_faceColor = 36 col->m_faceColor =
37 col->_hexcode = "#AAAAAA"; 37 col->m_hexcode = "#AAAAAA";
38 col->_edgeColor = Qt::black; 38 col->m_edgeColor = Qt::black;
39 g_LDConfigColors[16] = col; 39 g_LDConfigColors[16] = col;
40 40
41 col = new LDColorData; 41 col = new LDColorData;
42 col->_faceColor = 42 col->m_faceColor =
43 col->_edgeColor = 43 col->m_edgeColor =
44 col->_hexcode = "#000000"; 44 col->m_hexcode = "#000000";
45 g_LDConfigColors[24] = col; 45 g_LDConfigColors[24] = col;
46 46
47 LDConfigParser::parseLDConfig(); 47 LDConfigParser::parseLDConfig();
48 } 48 }
49 49
50 LDColor maincolor() 50 LDColor MainColor()
51 { 51 {
52 return g_LDConfigColors[16]; 52 return g_LDConfigColors[MainColorIndex];
53 } 53 }
54 54
55 LDColor edgecolor() 55 LDColor EdgeColor()
56 { 56 {
57 return g_LDConfigColors[24]; 57 return g_LDConfigColors[EdgeColorIndex];
58 } 58 }
59 59
60 void LDColor::addLDConfigColor (qint32 index, LDColor color) 60 void LDColor::addLDConfigColor (qint32 index, LDColor color)
61 { 61 {
62 assert (index >= 0 and index < countof (g_LDConfigColors)); 62 assert (index >= 0 and index < countof (g_LDConfigColors));
78 78
79 if (index >= 0x3000000) 79 if (index >= 0x3000000)
80 col.setAlpha (128); 80 col.setAlpha (128);
81 81
82 LDColorData* color = new LDColorData; 82 LDColorData* color = new LDColorData;
83 color->_name = "0x" + QString::number (index, 16).toUpper(); 83 color->m_name = "0x" + QString::number (index, 16).toUpper();
84 color->_faceColor = col; 84 color->m_faceColor = col;
85 color->_edgeColor = luma(col) < 48 ? Qt::white : Qt::black; 85 color->m_edgeColor = Luma (col) < 48 ? Qt::white : Qt::black;
86 color->_hexcode = col.name(); 86 color->m_hexcode = col.name();
87 color->_index = index; 87 color->m_index = index;
88 return LDColor (color); 88 return LDColor (color);
89 } 89 }
90 90
91 return null; 91 return null;
92 } 92 }
114 114
115 // both are null 115 // both are null
116 return true; 116 return true;
117 } 117 }
118 118
119 int luma (const QColor& col) 119 int Luma (const QColor& col)
120 { 120 {
121 return (0.2126f * col.red()) + 121 return (0.2126f * col.red()) +
122 (0.7152f * col.green()) + 122 (0.7152f * col.green()) +
123 (0.0722f * col.blue()); 123 (0.0722f * col.blue());
124 } 124 }
125 125
126 int numLDConfigColors() 126 int CountLDConfigColors()
127 { 127 {
128 return countof (g_LDConfigColors); 128 return countof (g_LDConfigColors);
129 } 129 }

mercurial