Assert RGB format.

@param array $rgb
@return void
@throws RuntimeException
502906
public function assertRgb(array $rgb)
    {
        // Assert RGB values count.
        if (count($rgb) !== 3) {
            throw new RuntimeException(sprintf('Invalid RGB value [%s].', implode(', ', $rgb)));
        }

        foreach ($rgb as $value) {
            // Assert RGB value.
            if ($value < 0 || $value > 255) {
                throw new RuntimeException(sprintf('Invalid RGB value [%s].', implode(', ', $rgb)));
            }
        }
    }
8720
public static function rgbaValueToRgbaComponents($rgb)
    {
        self::throwExceptionIfNotRgbaValue($rgb);

        $alpha = self::rgbaValueToAlphaComponent($rgb);

        if (0 === $alpha) {
            $alpha = 0xFF;
        }

        return [
            'R' => self::rgbaValueToRedComponent($rgb),
            'G' => self::rgbaValueToGreenComponent($rgb),
            'B' => self::rgbaValueToBlueComponent($rgb),
            'A' => $alpha
        ];
    }
1102975
private function createImageColor($colorArray)
	{
		$r = $colorArray['r'];
		$g = $colorArray['g'];
		$b = $colorArray['b'];

		return imagecolorallocate($this->imageResized, $r, $g, $b);
	}
226408
protected function assertLabel($label)
    {
        $utf8 = mb_convert_encoding($label, 'UTF-8', 'auto');

        if (!preg_match_all(static::STRICT_LABEL_PATTERN, $utf8, $matches)) {
            $message = sprintf('Could not serialize LTSV label = %s. It contains an illegal character.', $label);

            throw new \RuntimeException($message);
        }
    }
1184818
function setStrokeColor( $cmykArray, $force = 0 )
    {
        if ( $force || !$this->compareCMYK( $cmykArray, $this->currentStrokeColour ) )
        {
            $this->objects[$this->currentContents]['c'] .= "\n" .
                 sprintf( '%.3F', $cmykArray['c'] ) . ' ' . sprintf( '%.3F', $cmykArray['m'] ) . ' ' .
                 sprintf( '%.3F', $cmykArray['y'] ) . ' ' . sprintf( '%.3F', $cmykArray['k'] ) . ' K';
            $this->currentStrokeColour = $cmykArray;
        }
    }
666649
public function transparent(String $rgb) : GD
    {
        imagecolortransparent($this->canvas, $this->allocate($rgb));

        return $this;
    }
256026
public static function fromRgb(int $red, int $green, int $blue): Color
    {
        if (!Validator::isValidRgb($red, $green, $blue)) {
            throw new InvalidColorException('Invalid RGB values');
        }

        return new self($red, $green, $blue);
    }
357608
public static function IsHexColorCode ($rgb) {
		return (($hex_array = static::ToHexStringArray($rgb)) !== false) ? ctype_xdigit($hex_array[0]) && ctype_xdigit($hex_array[1]) && ctype_xdigit($hex_array[2]) : false;
	}
469666
public function start(array $tasks)
    {
        foreach ($tasks as $task) {
            if (!isset($this->tasks[$task])) {
                throw new \RuntimeException('The task "' . $task . '" does not exists.');
            }

            Output::out(sprintf(
                '[%s] Starting task "%s"',
                Output::colorize((new \DateTime())->format('H:i:s'), 'light_gray'),
                Output::colorize($task, 'light_cyan')
            ));

            $start = microtime(true);
            $callback = $this->tasks[$task];
            $callback($this);

            Output::out(sprintf(
                '[%s] Task "%s" has finished in %s',
                Output::colorize((new \DateTime())->format('H:i:s'), 'light_gray'),
                Output::colorize($task, 'light_cyan'),
                Output::colorize(
                    sprintf(
                        '%s seconds',
                        round(microtime(true) - $start, 4)
                    ),
                    'magenta'
                )
            ));
        }
    }
12521
public function setColor($color)
    {
        $allowed_values = array('#ffffff', '#ffff01', '#ff6600', '#fe0000', '#9a0000', '#660066', '#0000fe', '#0099ff', '#01ffff', '#00ff33', '#349800', '#006634', '#666666', '#999999', '#e6e6e6', '#ffffcd', '#99ffff', '#ccff9a');
        if (!is_null($color) && (!in_array($color, $allowed_values))) {
            throw new \InvalidArgumentException("Invalid value for 'color', must be one of '#ffffff', '#ffff01', '#ff6600', '#fe0000', '#9a0000', '#660066', '#0000fe', '#0099ff', '#01ffff', '#00ff33', '#349800', '#006634', '#666666', '#999999', '#e6e6e6', '#ffffcd', '#99ffff', '#ccff9a'");
        }
        $this->container['color'] = $color;

        return $this;
    }
199165
public function setAxisColor($r, $g, $b)
    {
        $this->ink['axis'] = imagecolorallocate($this->im, $r, $g, $b);
    }
204546
public function setBlackTagList(array $tags)
    {
        if (!$this->special_characters_allowed) {
            throw new RuntimeException('All special chars will be escaped. Set AllowHtml to use black list');
        }

        if ($this->white_tag_list) {
            throw new RuntimeException('White list already added.');
        }

        $this->black_tag_list = $tags;
    }
47800
function setFgColor($color)
    {
        $value = $this->_getColor($color);
        $this->_fg_color = $value;
        if ($this->_pattern == 0) { // force color to be seen
            $this->_pattern = 1;
        }
    }
290418
protected function assertFile($name)
    {
        if (strpos($name, '..') !== false) {
            throw new \InvalidArgumentException("File name '$name' isn't valid");
        }
        
        $file = $this->getFilePath($name);
        
        if (!file_exists($file)) {
            throw new \RuntimeException("View file '$file' doesn't exist");
        }
    }
603386
protected function render(array $colours)
    {
        $separator = '+';

        foreach ($this->columnLengthMax as $columnLength) {
            $separator .= str_repeat('-', $columnLength + 2) . '+';
        }

        $output = $separator;

        foreach ($this->rows as $row) {
            $output .= PHP_EOL . '|';

            foreach ($this->columnLengthMax as $key => $null) {
                $cellContent = isset($row[$key]) ? $row[$key] : '';

                $output .= ' ' . str_pad($cellContent, $this->columnLengthMax[$key]) . ' |';
            }
        }

        // flush rows
        $this->rows = [];

        // Create the coloured string
        return "\n\033[{$colours[0]}m\033[{$colours[1]}m" . $output . PHP_EOL . $separator . PHP_EOL . "\033[0m\n";
    }
33641
public static function normalizeCssRgb(array $rgba)
    {
        foreach ($rgba as &$val) {
            if (strpos($val, '%') !== false) {
                $val = str_replace('%', '', $val);
                $val = round($val * 2.55);
            }
        }

        return $rgba;
    }
1299078
public function write($message)
    {
        if ($this->output instanceof OutputInterface) {
            $this->output->write($message);
        } elseif (@fwrite($this->output, $message) === false) {
            throw new \RuntimeException('Unable to write output.');
        }
    }