mirror of
https://github.com/ocornut/imgui.git
synced 2024-11-27 16:29:02 +08:00
ImColor: Added SetHSV helper function.
This commit is contained in:
parent
7b0bf23071
commit
8afbdd1ade
7
imgui.h
7
imgui.h
@ -971,12 +971,15 @@ struct ImColor
|
||||
{
|
||||
ImVec4 Value;
|
||||
|
||||
ImColor() { Value.x = Value.y = Value.z = Value.w = 0.0f; }
|
||||
ImColor(int r, int g, int b, int a = 255) { float sc = 1.0f/255.0f; Value.x = (float)r * sc; Value.y = (float)g * sc; Value.z = (float)b * sc; Value.w = (float)a * sc; }
|
||||
ImColor(ImU32 rgba) { float sc = 1.0f/255.0f; Value.x = (float)(rgba&0xFF) * sc; Value.y = (float)((rgba>>8)&0xFF) * sc; Value.z = (float)((rgba>>16)&0xFF) * sc; Value.w = (float)(rgba >> 24) * sc; }
|
||||
ImColor(float r, float g, float b, float a = 1.0f) { Value.x = r; Value.y = g; Value.z = b; Value.w = a; }
|
||||
ImColor(const ImVec4& col) { Value = col; }
|
||||
operator ImU32() const { return ImGui::ColorConvertFloat4ToU32(Value); }
|
||||
operator ImVec4() const { return Value; }
|
||||
inline operator ImU32() const { return ImGui::ColorConvertFloat4ToU32(Value); }
|
||||
inline operator ImVec4() const { return Value; }
|
||||
|
||||
inline void SetHSV(float h, float s, float v, float a = 1.0f){ ImGui::ColorConvertHSVtoRGB(h, s, v, Value.x, Value.y, Value.z); Value.w = a; }
|
||||
|
||||
static ImColor HSV(float h, float s, float v, float a = 1.0f) { float r,g,b; ImGui::ColorConvertHSVtoRGB(h, s, v, r, g, b); return ImColor(r,g,b,a); }
|
||||
};
|
||||
|
Loading…
Reference in New Issue
Block a user