You are here

public function ColorHex::toRgb in Color Field 8.2

Get the color as a RGB instance.

Return value

\Drupal\color_field\ColorRGB The color as a RGB instance.

Overrides ColorInterface::toRgb

1 call to ColorHex::toRgb()
ColorHex::toString in src/ColorHex.php
A string representation of this color in the current format.

File

src/ColorHex.php, line 79

Class

ColorHex
Hex represents the Hex color format.

Namespace

Drupal\color_field

Code

public function toRgb() {
  $red = ($this->color & 0xff0000) >> 16;
  $green = ($this->color & 0xff00) >> 8;
  $blue = $this->color & 0xff;
  $opacity = $this
    ->getOpacity();
  return new ColorRGB($red, $green, $blue, $opacity);
}