Hi I spent lot of time to get luma value from a rgb color.
I get my reference value for HSL in the info panel, I just have to put the mouse on the right color.
if the rgb color is a gray at 30% (0.3020 , 0.3020 , 0.3020) in decimal.
the results of this expression is:
rgbToHsl(0.3020 , 0.3020 , 0.3020) = 30 (it's ok)
But it doesn't work for this pure red color (1,0,0) luma should be at 100%.
rgbToHsl(1 , 0 , 0) = 50
same for this
rgbToHsl(0 , 0.75 , 0) = 37 (should be 75%)
So I tried an other way:
Math.round ((Math.max(rgb,rgb,rgb) + Math.min(rgb,rgb,rgb) /2)*100)
This time a get the right luma value if I choose a color sample but a wrong result for a grayscale sample !
What do you think ?
I want the expression on a text layer to make a kind of color picker to show only the luma. It's quite simple but I want it reliable.