src/colors.cpp

changeset 493
16766ac1bbd9
parent 471
fc58b67d445c
child 513
29eb671b34f6
equal deleted inserted replaced
492:e964085e6913 493:16766ac1bbd9
31 31
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 { LDColor* col;
38 print ("%1: initializing color information.\n", __func__); 38 print ("%1: initializing color information.\n", __func__);
39 39
40 // Always make sure there's 16 and 24 available. They're special like that. 40 // Always make sure there's 16 and 24 available. They're special like that.
41 col = new LDColor; 41 col = new LDColor;
42 col->faceColor = 42 col->faceColor =
43 col->hexcode = "#AAAAAA"; 43 col->hexcode = "#AAAAAA";
44 col->edgeColor = Qt::black; 44 col->edgeColor = Qt::black;
45 g_LDColors[maincolor] = col; 45 g_LDColors[maincolor] = col;
46 46
47 col = new LDColor; 47 col = new LDColor;
48 col->faceColor = 48 col->faceColor =
49 col->edgeColor = 49 col->edgeColor =
50 col->hexcode = "#000000"; 50 col->hexcode = "#000000";
51 g_LDColors[edgecolor] = col; 51 g_LDColors[edgecolor] = col;
52 52
53 parseLDConfig(); 53 parseLDConfig();
54 } 54 }
55 55
56 // ============================================================================= 56 // =============================================================================
57 // ----------------------------------------------------------------------------- 57 // -----------------------------------------------------------------------------
58 LDColor* getColor (short colnum) { 58 LDColor* getColor (short colnum)
59 // Check bounds 59 { // Check bounds
60 if (colnum < 0 || colnum >= MAX_COLORS) 60 if (colnum < 0 || colnum >= MAX_COLORS)
61 return null; 61 return null;
62 62
63 return g_LDColors[colnum]; 63 return g_LDColors[colnum];
64 } 64 }
65 65
66 // ============================================================================= 66 // =============================================================================
67 // ----------------------------------------------------------------------------- 67 // -----------------------------------------------------------------------------
68 void setColor (short colnum, LDColor* col) { 68 void setColor (short colnum, LDColor* col)
69 if (colnum < 0 || colnum >= MAX_COLORS) 69 { if (colnum < 0 || colnum >= MAX_COLORS)
70 return; 70 return;
71 71
72 g_LDColors[colnum] = col; 72 g_LDColors[colnum] = col;
73 } 73 }
74 74
75 // ============================================================================= 75 // =============================================================================
76 // ----------------------------------------------------------------------------- 76 // -----------------------------------------------------------------------------
77 int luma (QColor& col) { 77 int luma (QColor& col)
78 return (0.2126f * col.red()) + 78 { return (0.2126f * col.red()) +
79 (0.7152f * col.green()) + 79 (0.7152f * col.green()) +
80 (0.0722f * col.blue()); 80 (0.0722f * col.blue());
81 } 81 }

mercurial