Wireshark 4.7.0
The Wireshark network protocol analyzer
Loading...
Searching...
No Matches
color_math.h
Go to the documentation of this file.
1
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 constrastRatio(const QColor &color1, const QColor &color2);
41
45 static bool isDark(const QColor &color);
46
47 // ---------------------------------------------------------------
48 // Mix / shade
49 // ---------------------------------------------------------------
50
53 static QColor mix(const QColor &a, const QColor &b, qreal ratio = 0.5);
54 static ThemeColorPair mix(const ThemeColorPair &a, const ThemeColorPair &b, qreal ratio = 0.5);
55
58 static QColor darken(const QColor &c, int percent);
59 static ThemeColorPair darken(const ThemeColorPair &p, int percent);
60
63 static QColor lighten(const QColor &c, int percent);
64 static ThemeColorPair lighten(const ThemeColorPair &p, int percent);
65
66 // ---------------------------------------------------------------
67 // Alpha
68 // ---------------------------------------------------------------
69
71 static QColor withAlpha(const QColor &c, int alpha);
72 static ThemeColorPair withAlpha(const ThemeColorPair &p, int alpha);
73
75 static QColor withAlphaF(const QColor &c, qreal alpha);
76 static ThemeColorPair withAlphaF(const ThemeColorPair &p, qreal alpha);
77
78 // ---------------------------------------------------------------
79 // Contrast & state
80 // ---------------------------------------------------------------
81
85 static QColor contrastingText(const QColor &surface);
87
92 static QColor contrastingTextOver(const QColor &surface, const QColor &backdrop);
93
95 static QColor disabled(const QColor &c, const QColor &background);
96 static ThemeColorPair disabled(const ThemeColorPair &p, const QColor &background);
97
99 static QColor hoverBg(const QColor &c, const QColor &background);
100 static ThemeColorPair hoverBg(const ThemeColorPair &p, const QColor &background);
101};
102
103#endif /* COLOR_MATH_H */
Definition color_math.h:29
static bool isDark(const QColor &color)
Definition color_math.cpp:51
static qreal constrastRatio(const QColor &color1, const QColor &color2)
Definition color_math.cpp:42
static QColor withAlpha(const QColor &c, int alpha)
Definition color_math.cpp:113
static QColor contrastingTextOver(const QColor &surface, const QColor &backdrop)
Definition color_math.cpp:164
static QColor lighten(const QColor &c, int percent)
Definition color_math.cpp:95
static QColor disabled(const QColor &c, const QColor &background)
Definition color_math.cpp:182
static QColor mix(const QColor &a, const QColor &b, qreal ratio=0.5)
Definition color_math.cpp:60
static QColor darken(const QColor &c, int percent)
Definition color_math.cpp:81
static QColor withAlphaF(const QColor &c, qreal alpha)
Definition color_math.cpp:125
static QColor contrastingText(const QColor &surface)
Definition color_math.cpp:141
static double relativeLuminance(const QColor &color)
Definition color_math.cpp:34
static QColor hoverBg(const QColor &c, const QColor &background)
Definition color_math.cpp:192
Definition theme_manager.h:39