-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy patholcPGEX_AdditionalColours.h
128 lines (110 loc) · 3.02 KB
/
olcPGEX_AdditionalColours.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
123
124
125
126
127
128
#pragma once
#include "olcPixelGameEngine.h"
namespace olc
{
namespace Colours
{
//ALL THE COLORS OF THE WIND!
static const Pixel
OFF_BLACK(24, 24, 26),
OFF_WHITE(239, 248, 254),
ORANGE(255, 140, 0),
DARK_ORANGE(255, 127, 0),
VERY_DARK_ORANGE(255, 114, 0),
APPLE_GREEN(206, 255, 89),
DARK_APPLE_GREEN(174, 222, 0),
VERY_DARK_APPLE_GREEN(84, 107, 0),
COBALT_BLUE(0, 160, 255),
DARK_COBALT_BLUE(0, 97, 176),
VERY_DARK_COBALT_BLUE(28, 56, 92),
PURPLE(145, 61, 255),
DARK_PURPLE(96, 0, 222),
VERY_DARK_PURPLE(49, 0, 102),
PINK(255, 121, 186),
DARK_PINK(235, 0, 109),
VERY_DARK_PINK(107, 0, 43),
BROWN(199, 89, 27),
DARK_BROWN(117, 37, 0),
VERY_DARK_BROWN(51, 13, 0),
CORNFLOWER_BLUE(100, 149, 237),
DARK_CORNFLOWER_BLUE(80, 129, 217),
VERY_DARK_CORNFLOWER_BLUE(60, 109, 197),
BIDOOF(242, 225, 179),
DARK_BIDOOF(156, 117, 58),
VERY_DARK_BIDOOF(81, 68, 62),
PALE_RED(255, 179, 183),
PALE_ORANGE(255, 229, 187),
PALE_YELLOW(255, 253, 181),
PALE_GREEN(202, 255, 192),
PALE_CYAN(192, 255, 240),
PALE_COBALT(194, 220, 255),
PALE_PURPLE(208, 186, 255),
PALE_PINK(255, 178, 216),
PALE_DARK_RED(130, 66, 61),
PALE_DARK_ORANGE(133, 94, 61),
PALE_DARK_YELLOW(133, 117, 70),
PALE_DARK_GREEN(110, 133, 67),
PALE_DARK_CYAN(78, 133, 112),
PALE_DARK_COBALT(75, 114, 133),
PALE_DARK_PURPLE(83, 69, 133),
PALE_DARK_PINK(130, 66, 133),
AMETHYST(153, 102, 204),
AMBER(255,191,0),
GOLDEN(255,215,0),
SILVER(192,192,192),
PLATINUM(229, 228, 226),
ANTIQUE_BRONZE(102, 93, 30),
BRONZE(205, 127, 50),
COPPER(184, 115, 51),
VERMILION(227, 66, 52),
INDIGO(63, 0, 255),
ULTRAMARINE(18, 10, 143);
// Taken from https://en.wikipedia.org/wiki/HSL_and_HSV#HSV_to_RGB
// Creates a new Pixel instance from hsv space (hue, saturation and value).
// Hue ranges from 0 to 360, saturation and value from 0 to 1.
static olc::Pixel FromHsv(float hue, float saturation, float value, const float alpha = 1)
{
hue = std::clamp(hue, 0.0f, 360.0f);
saturation = std::clamp(saturation, 0.0f, 1.0f);
value = std::clamp(value, 0.0f, 1.0f);
const float chroma = value * saturation;
const float x = chroma * (1 - std::fabs(fmodf((hue / 60), 2) - 1));
const float m = value - chroma;
float rawRed, rawGreen, rawBlue;
if (saturation == 0) {
rawRed = rawGreen = rawBlue = value;
}
else if (hue < 60) {
rawRed = chroma;
rawGreen = x;
rawBlue = 0;
}
else if (60 <= hue && hue < 120) {
rawRed = x;
rawGreen = chroma;
rawBlue = 0;
}
else if (120 <= hue && hue < 180) {
rawRed = 0;
rawGreen = chroma;
rawBlue = x;
}
else if (180 <= hue && hue < 240) {
rawRed = 0;
rawGreen = x;
rawBlue = chroma;
}
else if (240 <= hue && hue < 300) {
rawRed = x;
rawGreen = 0;
rawBlue = chroma;
}
else {
rawRed = chroma;
rawGreen = 0;
rawBlue = x;
}
return olc::PixelF(rawRed + m , rawGreen + m , rawBlue + m , alpha);
}
}
}