Skip to content

Color.RGB.ToHex

RGB to Hex conversion

DaxLib.SVG.Color.RGB.ToHex( red, green, blue, alpha )
Parameter Type Required Description
red INT64 The red value (0-255)
green INT64 The green value (0-255)
blue INT64 The blue value (0-255)
alpha DECIMAL Optional: The alpha value (0-1)

STRING hex color code

DaxLib.SVG.Color.RGB.ToHex(255, 0, 0, BLANK())
// Returns: "#FF0000" (red)
function 'DaxLib.SVG.Color.RGB.ToHex' =
        (
            red: INT64,
            green: INT64,
            blue: INT64,
            alpha: DOUBLE
        ) =>

            "#" &
            DaxLib.SVG.Color.Int.ToHex( red, 2 ) &
            DaxLib.SVG.Color.Int.ToHex( green, 2 ) &
            DaxLib.SVG.Color.Int.ToHex( blue, 2 ) &
            IF( NOT ISBLANK( alpha ), DaxLib.SVG.Color.Int.ToHex( alpha * 255, 2 ) )