Hex

hex_to_rgb

Convert a hex color code to an RGB string.

Arguments

  • $1 (string): Hex color code, with or without leading '#'

Exit codes

  • 0: Always

Output on stdout

  • rgb(r, g, b) string

rgb_to_hex

Convert RGB values to a hex color code.

Arguments

  • $1 (int): Red component (0-255)
  • $2 (int): Green component (0-255)
  • $3 (int): Blue component (0-255)

Exit codes

  • 0: Always

Output on stdout

  • Hex color code in the form #rrggbb

hex_to_rgba

Convert a hex color code (6 or 8 digits) to an RGBA string. An 8-digit hex value includes an alpha channel; 6-digit values default to alpha 1.0.

Arguments

  • $1 (string): Hex color code, with or without leading '#' (6 or 8 hex digits)

Exit codes

  • 0: Always

Output on stdout

  • rgba(r, g, b, a) string