Wireshark 4.7.2
The Wireshark network protocol analyzer
Loading...
Searching...
No Matches
color_math.h
Go to the documentation of this file.
1
9
10#ifndef COLOR_MATH_H
11#define COLOR_MATH_H
12
14
15#include <QColor>
16
29{
30public:
31 // ---------------------------------------------------------------
32 // Luminance & contrast
33 // ---------------------------------------------------------------
34
36 static double relativeLuminance(const QColor &color);
37
40 static qreal contrastRatio(const QColor &color1, const QColor &color2);
41
52 static QColor ensureContrast(const QColor &c, const QColor &bg, qreal minRatio);
53
57 static bool isDark(const QColor &color);
58
59 // ---------------------------------------------------------------
60 // Mix / shade
61 // ---------------------------------------------------------------
62
65 static QColor mix(const QColor &a, const QColor &b, qreal ratio = 0.5);
66 static ThemeColorPair mix(const ThemeColorPair &a, const ThemeColorPair &b, qreal ratio = 0.5);
67
70 static QColor darken(const QColor &c, int percent);
71 static ThemeColorPair darken(const ThemeColorPair &p, int percent);
72
75 static QColor lighten(const QColor &c, int percent);
76 static ThemeColorPair lighten(const ThemeColorPair &p, int percent);
77
78 // ---------------------------------------------------------------
79 // Alpha
80 // ---------------------------------------------------------------
81
83 static QColor withAlpha(const QColor &c, int alpha);
84 static ThemeColorPair withAlpha(const ThemeColorPair &p, int alpha);
85
87 static QColor withAlphaF(const QColor &c, qreal alpha);
88 static ThemeColorPair withAlphaF(const ThemeColorPair &p, qreal alpha);
89
90 // ---------------------------------------------------------------
91 // Contrast & state
92 // ---------------------------------------------------------------
93
97 static QColor contrastingText(const QColor &surface);
99
104 static QColor contrastingTextOver(const QColor &surface, const QColor &backdrop);
105
107 static QColor disabled(const QColor &c, const QColor &background);
108 static ThemeColorPair disabled(const ThemeColorPair &p, const QColor &background);
109
111 static QColor hoverBg(const QColor &c, const QColor &background);
112 static ThemeColorPair hoverBg(const ThemeColorPair &p, const QColor &background);
113};
114
115#endif /* COLOR_MATH_H */
Definition color_math.h:29
static bool isDark(const QColor &color)
Definition color_math.cpp:71
static QColor withAlpha(const QColor &c, int alpha)
Definition color_math.cpp:133
static QColor contrastingTextOver(const QColor &surface, const QColor &backdrop)
Definition color_math.cpp:184
static QColor ensureContrast(const QColor &c, const QColor &bg, qreal minRatio)
Definition color_math.cpp:51
static QColor lighten(const QColor &c, int percent)
Definition color_math.cpp:115
static QColor disabled(const QColor &c, const QColor &background)
Definition color_math.cpp:202
static QColor mix(const QColor &a, const QColor &b, qreal ratio=0.5)
Definition color_math.cpp:80
static QColor darken(const QColor &c, int percent)
Definition color_math.cpp:101
static qreal contrastRatio(const QColor &color1, const QColor &color2)
Definition color_math.cpp:42
static QColor withAlphaF(const QColor &c, qreal alpha)
Definition color_math.cpp:145
static QColor contrastingText(const QColor &surface)
Definition color_math.cpp:161
static double relativeLuminance(const QColor &color)
Definition color_math.cpp:34
static QColor hoverBg(const QColor &c, const QColor &background)
Definition color_math.cpp:212
Definition theme_manager.h:39