'Color picking by coordinates

When using a colorpicker like from google, the luminosity at the top left is 100%, on the top right it is 50%. However on both corners on the bottom the luminosity is 0%.

What's the mathematical function to compute the luminosity?

Here's the code I already have:

const map = (val, in_min, in_max, out_min, out_max) =>
    ((val - in_min) * (out_max - out_min)) / (in_max - in_min) + out_min;

let hue = 0;
let s = map(y, 0, width, 0, 100); // y: y position of the cursor, width: width of the color field

Nevermind, i was reading hsl but the values i was getting were hsv



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source