-
Notifications
You must be signed in to change notification settings - Fork 32
/
Copy pathColorSchemes.h
122 lines (101 loc) · 3.25 KB
/
ColorSchemes.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
#pragma once
#include <QColor>
#include <vector>
class ColorScheme {
public:
struct rgb {
rgb() : r(1.0), g(1.0), b(1.0) {}
rgb(float l, float m, float n) {
float q = 255.0; // sqrt(l*l + m*m + n*n) + 1.0e-6;
r = l / q;
g = m / q;
b = n / q;
}
float r;
float g;
float b;
};
rgb foreground;
rgb background;
rgb alt;
//-----------------------------------------------------------------------------
QColor background_qcolor(int alpha) { return QColor(background.r * 255, background.g * 255, background.b * 255, alpha); }
//-----------------------------------------------------------------------------
QColor foreground_qcolor() { return QColor(foreground.r * 255, foreground.g * 255, foreground.b * 255, 255); }
//-----------------------------------------------------------------------------
QColor get_text_color() {
double average = (background.r + background.g + background.b) / 3.0;
double color = 255;
if (average > 0.5) {
color = 0;
}
return QColor(color, color, color);
}
double get_text_intensity() {
auto color = get_text_color();
if (color.red() == 0) {
return 0;
}
return 1;
}
ColorScheme() {}
~ColorScheme() {}
};
class ColorSchemes : public std::vector<ColorScheme> {
public:
ColorSchemes() {
ColorScheme a;
// orange on grey
a.foreground = ColorScheme::rgb(255, 191, 0);
a.background = ColorScheme::rgb(25, 25, 25);
a.alt = ColorScheme::rgb(245, 245, 220);
this->push_back(a);
// purple on grey
a.foreground = ColorScheme::rgb(128, 0, 32.0);
a.background = ColorScheme::rgb(25, 25, 25);
a.alt = ColorScheme::rgb(245, 245, 220);
this->push_back(a);
// blue on white
a.foreground = ColorScheme::rgb(0, 71, 171);
a.background = ColorScheme::rgb(245, 245, 245);
a.alt = ColorScheme::rgb(175, 64, 53);
this->push_back(a);
// orange on white
a.foreground = ColorScheme::rgb(255, 191, 0);
a.background = ColorScheme::rgb(255, 255, 255);
a.alt = ColorScheme::rgb(0, 223, 22);
this->push_back(a);
// grey on white
// For Black and White figures
a.foreground = ColorScheme::rgb(200, 200, 200);
a.background = ColorScheme::rgb(255, 255, 255);
a.alt = ColorScheme::rgb(80, 80, 80);
this->push_back(a);
// orange on blue
a.foreground = ColorScheme::rgb(255, 219, 88);
a.background = ColorScheme::rgb(0, 0, 128);
a.alt = ColorScheme::rgb(173, 255, 47);
this->push_back(a);
// yellow on grey
a.foreground = ColorScheme::rgb(240, 220, 130);
a.background = ColorScheme::rgb(25, 25, 25);
a.alt = ColorScheme::rgb(0, 223, 22);
this->push_back(a);
// grey on black
a.foreground = ColorScheme::rgb(200, 200, 200);
a.background = ColorScheme::rgb(0, 0, 0);
a.alt = ColorScheme::rgb(100, 100, 100);
this->push_back(a);
// blue on black
a.foreground = ColorScheme::rgb(0, 191, 255);
a.background = ColorScheme::rgb(0, 0, 0);
a.alt = ColorScheme::rgb(175, 64, 53);
this->push_back(a);
// green on black
a.foreground = ColorScheme::rgb(137, 232, 148);
a.background = ColorScheme::rgb(0, 0, 0);
a.alt = ColorScheme::rgb(175, 64, 53);
this->push_back(a);
}
~ColorSchemes() {}
};