Same name and namespace in other branches
  1. 8.x-2.x src/ColorHSL.php \Drupal\color_field\ColorHSL::toString() 1 comment

A string representation of this color in the current format.

Parameters

bool $opacity: Whether to display the opacity.

Return value

string The color as hsla(#, #, #, #) or hsl(#, #, #) if opacity is false.

Overrides ColorInterface::toString

File

src/ColorHSL.php, line 105

Class

ColorHSL
RGB represents the RGB color format.

Namespace

Drupal\color_field

Code

public function toString(bool $opacity = TRUE) : string {
    $output = $opacity ? 'hsla(' . $this->hue . ',' . $this->sat . ',' . $this->lum . ',' . $this->getOpacity() . ')' : 'hsl(' . $this->hue . ',' . $this->sat . ',' . $this->lum . ')';
    return strtolower($output);
}