How to use the @microsoft/fast-colors.ColorRGBA64 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
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 / acrylic.ts View on Github external
export function applyAcrylicMaterial(
    backgroundColor: string,
    opacity: number,
    fallbackOpacity: number = 0.9,
    topHighlight: boolean = false
): CSSRules {
    const background: ColorRGBA64 = parseColorString(backgroundColor);
    const acrylicConfig: AcrylicConfig = {
        textureImage: acrylicNoise,
        backgroundColor: new ColorRGBA64(
            background.r,
            background.g,
            background.b,
            opacity
        ).toStringWebRGBA(),
        fallbackBackgroundColor: new ColorRGBA64(
            background.r,
            background.g,
            background.b,
            fallbackOpacity
        ).toStringWebRGBA(),
    };

    return {
        "border-top": topHighlight
            ? `${toPx(1)} solid ${new ColorRGBA64(
                  background.r,
                  background.g,
                  background.b,
                  0.1
              ).toStringWebRGBA()}`
            : "",
github microsoft / fast-dna / packages / fast-components-styles-msft / src / utilities / color / neutral-layer.ts View on Github external
const darkNeutralLayerL4: DesignSystemResolver = (
    designSystem: DesignSystem
): number => {
    const darkLum: number = 0.14;
    const darkColor: ColorRGBA64 = new ColorRGBA64(darkLum, darkLum, darkLum, 1);
    const darkRefIndex: number = findClosestSwatchIndex(
        PaletteType.neutral,
        darkColor.toStringHexRGB()
    )(designSystem);
    return darkRefIndex;
};
github microsoft / fast-dna / packages / fast-components-styles-msft / src / utilities / acrylic.ts View on Github external
export function applyAcrylicMaterial(
    backgroundColor: string,
    opacity: number,
    fallbackOpacity: number = 0.9,
    topHighlight: boolean = false
): CSSRules {
    const background: ColorRGBA64 = parseColorString(backgroundColor);
    const acrylicConfig: AcrylicConfig = {
        textureImage: acrylicNoise,
        backgroundColor: new ColorRGBA64(
            background.r,
            background.g,
            background.b,
            opacity
        ).toStringWebRGBA(),
        fallbackBackgroundColor: new ColorRGBA64(
            background.r,
            background.g,
            background.b,
            fallbackOpacity
        ).toStringWebRGBA(),
    };

    return {
        "border-top": topHighlight
            ? `${toPx(1)} solid ${new ColorRGBA64(
github microsoft / fast-dna / packages / fast-components-styles-msft / src / utilities / acrylic.ts View on Github external
background.r,
            background.g,
            background.b,
            opacity
        ).toStringWebRGBA(),
        fallbackBackgroundColor: new ColorRGBA64(
            background.r,
            background.g,
            background.b,
            fallbackOpacity
        ).toStringWebRGBA(),
    };

    return {
        "border-top": topHighlight
            ? `${toPx(1)} solid ${new ColorRGBA64(
                  background.r,
                  background.g,
                  background.b,
                  0.1
              ).toStringWebRGBA()}`
            : "",
        ...applyAcrylic(acrylicConfig),
    };
}