-- Colors.lua
-- Small HSV -> RGB helper so the options panel can expose a single
-- "Hue" slider (plus saturation/brightness/opacity) instead of a full
-- RGB picker, per the addon's design.

local ADDON_NAME, ns = ...
ns = ns or {}
select(2, ...)

WheresMeMouse = WheresMeMouse or {}
local WMM = WheresMeMouse

-- h: 0-360, s: 0-100, v: 0-100  ->  r, g, b in 0-1
function WMM.HSVToRGB(h, s, v)
    h = (h % 360) / 360
    s = math.max(0, math.min(100, s)) / 100
    v = math.max(0, math.min(100, v)) / 100

    if s <= 0 then
        return v, v, v
    end

    local hh = h * 6
    local i = math.floor(hh)
    local f = hh - i
    local p = v * (1 - s)
    local q = v * (1 - s * f)
    local t = v * (1 - s * (1 - f))
    i = i % 6

    if i == 0 then return v, t, p end
    if i == 1 then return q, v, p end
    if i == 2 then return p, v, t end
    if i == 3 then return p, q, v end
    if i == 4 then return t, p, v end
    return v, p, q
end
