Same name and namespace in other branches
  1. 3.0.x src/ColorRGB.php \Drupal\color_field\ColorRGB::__construct()

Create a new RGB color.

Parameters

int $red: The red (0-255)

int $green: The green (0-255)

int $blue: The blue (0-255)

float $opacity: The opacity.

Throws

Exception

File

src/ColorRGB.php, line 45

Class

ColorRGB
RGB represents the RGB color format.

Namespace

Drupal\color_field

Code

public function __construct($red, $green, $blue, $opacity) {
    if ($red < 0 || $red > 255) {
        // @throws exception.
    }
    if ($green < 0 || $green > 255) {
        // @throws exception.
    }
    if ($blue < 0 || $blue > 255) {
        // @throws exception.
    }
    $this->red = $red;
    $this->green = $green;
    $this->blue = $blue;
    $this->opacity = floatval($opacity);
}