MCPcopy Create free account
hub / github.com/StereoKit/StereoKit / gradient_get

Function gradient_get

StereoKitC/color.cpp:190–205  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

188///////////////////////////////////////////
189
190color128 gradient_get(gradient_t gradient, float at) {
191 if (gradient->count == 0)
192 return { 1,0,0,1 };
193 if (at < gradient->keys[0].position)
194 return gradient->keys[0].color;
195 if (at >= gradient->keys[gradient->count - 1].position)
196 return gradient->keys[gradient->count - 1].color;
197
198 for (int32_t i = 1; i < gradient->count; i++) {
199 if (gradient->keys[i].position >= at) {
200 float pct = (at - gradient->keys[i-1].position) / (gradient->keys[i].position - gradient->keys[i-1].position);
201 return color_lerp(gradient->keys[i-1].color, gradient->keys[i].color, pct);
202 }
203 }
204 return { 1,0,0,1 };
205}
206
207///////////////////////////////////////////
208

Callers 2

gradient_get32Function · 0.85
tex_gen_cubemapFunction · 0.85

Calls 1

color_lerpFunction · 0.85

Tested by

no test coverage detected