colors::Health visual Improvement
This commit is contained in:
parent
57444af7fe
commit
778c9ab64a
@ -158,6 +158,7 @@ constexpr rgba_t FromHSL(float h, float s, float v)
|
||||
return rgba_t{ v, p, q, 1.0f };
|
||||
}
|
||||
}
|
||||
// Made more readable for future reference
|
||||
constexpr rgba_t Health(int health, int max)
|
||||
{
|
||||
float hf = float(health) / float(max);
|
||||
@ -165,7 +166,21 @@ constexpr rgba_t Health(int health, int max)
|
||||
{
|
||||
return colors::FromRGBA8(64, 128, 255, 255);
|
||||
}
|
||||
return rgba_t{ (hf <= 0.5f ? 1.0f : 1.0f - 2.0f * (hf - 0.5f)), (hf <= 0.5f ? (2.0f * hf) : 1.0f), 0.0f, 1.0f };
|
||||
rgba_t to_return{ 0.0f, 0.0f, 0.0f, 1.0f };
|
||||
|
||||
// If More than 50% Health Set Red to 100% (Yes the <= 0.5f is "More than 50%" in this case)
|
||||
if (hf <= 0.5f)
|
||||
to_return.r = 1.0f;
|
||||
// Else if Less than 50% health Make red get reduced based on Percentage
|
||||
else
|
||||
to_return.r = 1.0f - (2.0f * (hf - 0.5f));
|
||||
// If More than 50% Health Make the green get increased based on percentage
|
||||
if (hf <= 0.5f)
|
||||
to_return.g = 2.0f * hf;
|
||||
// Else set Green to 100%
|
||||
else
|
||||
to_return.g = 1.0f;
|
||||
return to_return;
|
||||
}
|
||||
rgba_t RainbowCurrent();
|
||||
rgba_t EntityF(CachedEntity *ent);
|
||||
|
Reference in New Issue
Block a user