Get sRGB Luminance From RGB
Added in: @sardine/colour@1.2.0
Description
Calculates the sRGB luminance value for a given RGB colour object.
Signature
function getSRGBLuminanceFromRGB(rgb: RGB): number;
Parameters
rgb
:RGB
— The RGB colour object (e.g.,{ r: 34, g: 36, b: 41 }
).
Returns
number
— The sRGB luminance value (0 to 1).
Examples
import { getSRGBLuminanceFromRGB } from "@sardine/colour";
getSRGBLuminanceFromRGB({ r: 34, g: 36, b: 41 });
// => 0.052
Error Handling
- Throws an error if the input is not a valid RGB object.
Interactive Demo
Try the function yourself with our interactive playground: