Same name in other branches
- 3.0.x src/ColorRGB.php \Drupal\color_field\ColorRGB::toString()
A string representation of this color in the current format.
Parameters
bool $opacity: Whether or not to display the opacity.
Return value
string The color in format: #RRGGBB
Overrides ColorInterface::toString
File
-
src/
ColorRGB.php, line 102
Class
- ColorRGB
- RGB represents the RGB color format.
Namespace
Drupal\color_fieldCode
public function toString($opacity = TRUE) {
if ($opacity) {
$output = 'rgba(' . $this->getRed() . ',' . $this->getGreen() . ',' . $this->getBlue() . ',' . $this->getOpacity() . ')';
}
else {
$output = 'rgb(' . $this->getRed() . ',' . $this->getGreen() . ',' . $this->getBlue() . ')';
}
return strtolower($output);
}