Added ColorConvertU32ToFloat4() helper and ImColor(ImU32) constructor.

This commit is contained in:
ocornut
2015-08-26 21:18:08 +01:00
parent 62671ef96e
commit 59d498f3d0
2 changed files with 9 additions and 1 deletions

View File

@ -1039,6 +1039,12 @@ int ImTextCountUtf8BytesFromStr(const ImWchar* in_text, const ImWchar* in_text_e
return bytes_count;
}
ImVec4 ImGui::ColorConvertU32ToFloat4(ImU32 in)
{
float s = 1.0f/255.0f;
return ImVec4((in & 0xFF) * s, ((in >> 8) & 0xFF) * s, ((in >> 16) & 0xFF) * s, (in >> 24) * s);
}
ImU32 ImGui::ColorConvertFloat4ToU32(const ImVec4& in)
{
ImU32 out = ((ImU32)(ImSaturate(in.x)*255.f));