forked from CobaltFusion/DebugViewPP
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathColors.cpp
More file actions
78 lines (66 loc) · 1.99 KB
/
Copy pathColors.cpp
File metadata and controls
78 lines (66 loc) · 1.99 KB
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
// (C) Copyright Gert-Jan de Vos and Jan Wilmans 2013.
// Distributed under the Boost Software License, Version 1.0.
// (See accompanying file LICENSE_1_0.txt or copy at
// http://www.boost.org/LICENSE_1_0.txt)
// #include "stdafx.h"
#include <cstdlib>
#include "DebugViewppLib/Colors.h"
#include "CobaltFusion/Math.h"
namespace fusion {
namespace debugviewpp {
namespace Colors {
extern const COLORREF Auto = 0x80808080;
extern const COLORREF BackGround = GetSysColor(COLOR_WINDOW);
extern const COLORREF Text = GetSysColor(COLOR_WINDOWTEXT);
extern const COLORREF Highlight = RGB(255, 255, 55);
extern const COLORREF Selection = RGB(128, 255, 255);
extern const COLORREF ItemHighlight = GetSysColor(COLOR_HIGHLIGHT);
extern const COLORREF ItemHighlightText = GetSysColor(COLOR_HIGHLIGHTTEXT);
} // namespace Colors
COLORREF HsvToRgb(double h, double s, double v)
{
int hi = FloorTo<int>(h * 6);
double f = h * 6 - hi;
int vi = FloorTo<int>(256 * v);
int pi = FloorTo<int>(256 * v * (1 - s));
int qi = FloorTo<int>(256 * v * (1 - f * s));
int ti = FloorTo<int>(256 * v * (1 - (1 - f) * s));
switch (hi)
{
case 0: return RGB(vi, ti, pi);
case 1: return RGB(qi, vi, pi);
case 2: return RGB(pi, vi, ti);
case 3: return RGB(pi, qi, vi);
case 4: return RGB(ti, pi, vi);
case 5: return RGB(vi, pi, qi);
default: break;
}
return 0;
}
COLORREF GetRandomColor(double s, double v)
{
static bool randomize = (std::srand(GetTickCount()), true);
static const double ratio = (1 + std::sqrt(5.)) / 2 - 1;
// use golden ratio
static double h = static_cast<double>(std::rand()) / (RAND_MAX + 1);
h += ratio;
if (h >= 1)
{
h = h - 1;
}
return HsvToRgb(h, s, v);
}
COLORREF GetRandomBackColor()
{
return GetRandomColor(0.5, 0.95);
}
COLORREF GetRandomTextColor()
{
return GetRandomColor(0.9, 0.7);
}
COLORREF GetRandomProcessColor()
{
return GetRandomColor(0.20, 0.95);
}
} // namespace debugviewpp
} // namespace fusion