How to use the @microsoft/fast-colors.rgbToRelativeLuminance function in @microsoft/fast-colors

To help you get started, we’ve selected a few @microsoft/fast-colors examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github microsoft / fast-dna / packages / fast-components-styles-msft / src / utilities / elevation.ts View on Github external
return (config: DesignSystem): string => {
        const { r, g, b }: ColorRGBA64 = parseColorString(color);
        const {
            xOffsetMultiplier,
            yOffsetMultiplier,
            opacity,
            blurMultiplier,
            blurBase = 0,
        }: ShadowConfig = shadowConfig;
        // TODO: (Breaking) Remove default https://github.com/microsoft/fast-dna/issues/2469

        const lum: number = rgbToRelativeLuminance(
            parseColorString(backgroundColor(config))
        );
        const opacityMultiple: number = 2 - lum; // white (1) = 1; black (0) = 2;
        return [xOffsetMultiplier, yOffsetMultiplier]
            .map((val: number) => parseFloat((val * elevationValue).toFixed(1)))
            .concat(blurBase + blurMultiplier * elevationValue)
            .map(toPx)
            .concat(new ColorRGBA64(r, g, b, opacity * opacityMultiple).toStringWebRGBA())
            .join(" ");
    };
}
github microsoft / fast-dna / packages / fast-components-styles-msft / src / utilities / color / common.ts View on Github external
export function luminance(color: string): number {
    return rgbToRelativeLuminance(parseColorString(color));
}