forked from spring/spring
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathHeightLinePalette.cpp
More file actions
70 lines (59 loc) · 1.48 KB
/
HeightLinePalette.cpp
File metadata and controls
70 lines (59 loc) · 1.48 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
/* This file is part of the Spring engine (GPL v2 or later), see LICENSE.html */
#include "HeightLinePalette.h"
#include "System/Config/ConfigHandler.h"
CONFIG(bool, ColorElev).defaultValue(true).description("If heightmap (default hotkey [F1]) should be colored or not.");
static std::array<SColor, 256> CreateColored()
{
std::array<SColor, 256> arr;
for(int a = 0; a < 86; ++a) {
arr[a].r = 255 - a*3;
arr[a].g = a*3;
arr[a].b = 0;
}
for (int a = 86; a < 172; ++a) {
arr[a].r = 0;
arr[a].g = 255 - (a - 86) * 3;
arr[a].b = (a - 86) * 3;
}
for (int a = 172; a < 256; ++a) {
arr[a].r = (a - 172) * 3;
arr[a].g = 0;
arr[a].b = 255 - (a - 172) * 3;
}
for (SColor& c: arr) {
c.r = (64 + c.r) >> 1;
c.g = (64 + c.g) >> 1;
c.b = (64 + c.b) >> 1;
}
return arr;
}
static std::array<SColor, 256> CreateBW()
{
std::array<SColor, 256> arr;
for (int a = 0; a < 29; ++a) {
arr[a].r = 255 - a*8;
arr[a].g = 255 - a*8;
arr[a].b = 255 - a*8;
}
for (int a = 29; a < 256; ++a) {
arr[a].r = a;
arr[a].g = a;
arr[a].b = a;
}
for (SColor& c: arr) {
c.r = 64 + (c.r >> 1);
c.g = 64 + (c.g >> 1);
c.b = 64 + (c.b >> 1);
}
return arr;
}
std::array<SColor, 256> CHeightLinePalette::paletteColored = CreateColored();
std::array<SColor, 256> CHeightLinePalette::paletteBlackAndWhite = CreateBW();
const SColor* CHeightLinePalette::GetData()
{
if (configHandler->GetBool("ColorElev")) {
return &paletteColored[0];
} else {
return &paletteBlackAndWhite[0];
}
}