// Based on: https://en.wikipedia.org/wiki/HSL_and_HSV#Formal_derivation
export default function convertRgbToHsv({ r, g, b, alpha }) {
let M = Math.max(r, g, b),
m = Math.min(r, g, b);
let res = {
mode: 'hsv',
s: M === 0 ? 0 : 1 - m / M,
v: M
};
if (M - m !== 0)
res.h =
(M === r
? (g - b) / (M - m) + (g < b) * 6
: M === g
? (b - r) / (M - m) + 2
: (r - g) / (M - m) + 4) * 60;
if (alpha !== undefined) res.alpha = alpha;
return res;
}
MCP directory API
We provide all the information about MCP servers via our MCP API.
curl -X GET 'https://glama.ai/api/mcp/v1/servers/MatheusgVentura/Project-One'
If you have feedback or need assistance with the MCP directory API, please join our Discord server