MCPcopy Create free account
hub / github.com/OpenStarbound/OpenStarbound / temperature

Method temperature

source/core/StarColor.cpp:96–125  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

94}
95
96Color Color::temperature(float temp) {
97 // Magic numbers ahoy!
98 Color c;
99 c.setAlpha(255);
100
101 temp = clamp<float>(temp, 1000, 40000);
102
103 temp /= 100;
104
105 double r, g, b;
106 if (temp <= 66) {
107 r = 255;
108 g = clamp<double>(99.4708025861 * log(temp) - 161.1195681661, 0, 255);
109 if (temp <= 19) {
110 b = 0;
111 } else {
112 b = clamp<double>(138.5177312231 * log(temp - 10) - 305.0447927307, 0, 255);
113 }
114 } else {
115 r = clamp<double>(329.698727446 * pow(temp - 60, -0.1332047592), 0, 255);
116 g = clamp<double>(288.1221695283 * pow(temp - 60, -0.0755148492), 0, 255);
117 b = 255;
118 }
119
120 c.setRedF((float)r / 255.0f);
121 c.setGreenF((float)g / 255.0f);
122 c.setBlueF((float)b / 255.0f);
123
124 return c;
125}
126
127#ifdef STAR_COMPILER_GNU
128#pragma GCC push_options

Callers

nothing calls this directly

Calls 4

setAlphaMethod · 0.80
setRedFMethod · 0.80
setGreenFMethod · 0.80
setBlueFMethod · 0.80

Tested by

no test coverage detected