MCPcopy Create free account
hub / github.com/Wemino/MarkerPatch / ColorConvertRGBtoHSV

Method ColorConvertRGBtoHSV

include/imgui/imgui.cpp:2852–2870  ·  view source on GitHub ↗

Convert rgb floats ([0-1],[0-1],[0-1]) to hsv floats ([0-1],[0-1],[0-1]), from Foley & van Dam p592 Optimized http://lolengine.net/blog/2013/01/13/fast-rgb-to-hsv

Source from the content-addressed store, hash-verified

2850// Convert rgb floats ([0-1],[0-1],[0-1]) to hsv floats ([0-1],[0-1],[0-1]), from Foley & van Dam p592
2851// Optimized http://lolengine.net/blog/2013/01/13/fast-rgb-to-hsv
2852void ImGui::ColorConvertRGBtoHSV(float r, float g, float b, float& out_h, float& out_s, float& out_v)
2853{
2854 float K = 0.f;
2855 if (g < b)
2856 {
2857 ImSwap(g, b);
2858 K = -1.f;
2859 }
2860 if (r < g)
2861 {
2862 ImSwap(r, g);
2863 K = -2.f / 6.f - K;
2864 }
2865
2866 const float chroma = r - (g < b ? g : b);
2867 out_h = ImFabs(K + (g - b) / (6.f * chroma + 1e-20f));
2868 out_s = chroma / (r + 1e-20f);
2869 out_v = r;
2870}
2871
2872// Convert hsv floats ([0-1],[0-1],[0-1]) to rgb floats ([0-1],[0-1],[0-1]), from Foley & van Dam p593
2873// also http://en.wikipedia.org/wiki/HSL_and_HSV

Callers

nothing calls this directly

Calls 1

ImSwapFunction · 0.85

Tested by

no test coverage detected