You are here

public static function TwigColor::hexToCssRgb in Twig Tools 8

Returns the CSS RGB string equivalent of the passed hexadecimal color.

Parameters

string $hex: The hexadecimal color to get the CSS RGB equivalent string value of.

Return value

string The CSS RGB equivalent string of the passed hexadecimal color.

File

src/TwigExtension/TwigColor.php, line 142

Class

TwigColor
Class TwigConvert.

Namespace

Drupal\twig_tools\TwigExtension

Code

public static function hexToCssRgb($hex) {
  $rgb = self::hexToRgb($hex);
  if (is_array($rgb) && count($rgb) === 3) {
    return sprintf('rgb(%s, %s, %s)', $rgb[0], $rgb[1], $rgb[2]);
  }
}