Converts RGB to HTML.
@access		public
@static
@param		array	rgb		RGB-Color as array
@return		string
431932
public static function rgb2html( $rgb )
	{
		list( $r, $g, $b ) = $rgb;
		$html	= sprintf( "%2X%2X%2X", $r, $g, $b );
		$html	= str_replace( " ", "0", $html );
		return	$html;
	}
1047575
static function htmltorgbPchart($color)
    {
        if (is_array($color)) {
            return $color;
        }

        if ($color[0] == '#') {
            $color = substr($color, 1);
        }

        if (strlen($color) == 6) {
            list($r, $g, $b) = array($color[0] . $color[1],
                $color[2] . $color[3],
                $color[4] . $color[5]);
        } elseif (strlen($color) == 3) {
            list($r, $g, $b) = array($color[0] . $color[0], $color[1] . $color[1], $color[2] . $color[2]);
        } else {
            return array("R" => 0, "G" => 0, "B" => 0);
        }

        $r = hexdec($r);
        $g = hexdec($g);
        $b = hexdec($b);

        return array("R" => $r, "G" => $g, "B" => $b);
    }
1176793
public function cssRGBA($color, $alpha = 1.00) {

        if (0 === preg_match_all("/^#?([A-Fa-f0-9]{6}|[A-Fa-f0-9]{3})$/", strtolower($color), $hex)) {
            return "";
        }

        $length = strlen($hex[1][0]);

        $pattern = "/[A-Fa-f0-9]{" . intval($length / 3) . "}/";
        preg_match_all($pattern, $hex[1][0], $channels);

        if (3 === $length) {
            $channels[0][0] = str_repeat($channels[0][0], 2);
            $channels[0][1] = str_repeat($channels[0][1], 2);
            $channels[0][2] = str_repeat($channels[0][2], 2);
        }

        $template = "rgba(%r%, %g%, %b%, %a%)";

        return StringHelper::replace($template, ["%r%", "%g%", "%b%", "%a%"], [hexdec($channels[0][0]), hexdec($channels[0][1]), hexdec($channels[0][2]), number_format($alpha, 2)]);
    }
280411
public function initFromArray($array)
    {
        $array = array_values($array);

        if (count($array) == 4) {

            // color array with alpha value
            list($r, $g, $b, $a) = $array;

        } elseif (count($array) == 3) {

            // color array without alpha value
            list($r, $g, $b) = $array;
            $a = 1;
        }

        $this->setPixel($r, $g, $b, $a);
    }
184515
private static function rgb($color) {

		return (object) [

			'r' => intval(hexdec(substr($color, 0, 2))),
			'g' => intval(hexdec(substr($color, 2, 2))),
			'b' => intval(hexdec(substr($color, 4, 2)))
		];
	}
1341795
public function toHTML($width=2)
    {
        print('<table style="background-color:#eee;">');
        for ($i = 0; $i < $this->m; $i++) {
            print('<tr>');
            for ($j = 0; $j < $this->n; $j++) {
                print('<td style="background-color:#fff;border:1px solid #000;padding:2px;text-align:center;vertical-align:middle;">' . $this->A[$i][$j] . '</td>');
            }
            print('</tr>');
        }
        print('</table>');
    }
1190819
public function colors_preview_css() {

		?>
		<script type="text/html" id="tmpl-rock-colors-css">
			<?php

			foreach ( $this->colors as $name => $args ) {

				if ( empty( $name ) || empty( $args['css'] ) || ! is_array( $args['css'] ) ) {

					continue;

				}

				printf(
					Rock_Customizer::parse_css_rules( $args['css'] ),
					sprintf( '{{ data.%s }}', $name )
				);

			}

			?>
		</script>
		<?php

		$rgba_colors = $this->get_rgba_css();

		if ( ! $rgba_colors ) {

			// Required for themes without rgba css rules
			echo '<script type="text/html" id="tmpl-rock-colors-css-rgba"></script>';

		}

		?>
		<script type="text/html" id="tmpl-rock-colors-css-rgba">
			<?php

			foreach ( $rgba_colors as $name => $css ) {

				printf(
					Rock_Customizer::parse_css_rules( $css ),
					sprintf( '{{ data.%s }}', $name )
				);

			}

			?>
		</script>
		<?php

	}
245014
public static function ToDecArray ($rgb) {
		return (($hex_array = static::ToHexStringArray($rgb)) !== false) ? [hexdec($hex_array[0]), hexdec($hex_array[1]), hexdec($hex_array[2])] : false;
	}
1006751
public function render()
    {
        $lines = [];

        for ($i = 0; $i < $this->numbers; $i++) {
            $lines[ $i ] = $this->color->paint(str_repeat($this->string, $this->width));
        }

        return str_repeat(PHP_EOL, $this->newLinesBefore) . implode(PHP_EOL, $lines) . str_repeat(PHP_EOL,
                $this->newLinesAfter);
    }
390159
public static function rgb($r = 255, $g = 255, $b = 255)
    {
        // Check if values are in range.
        static::validateComp('R', $r, 0, 255);
        static::validateComp('G', $g, 0, 255);
        static::validateComp('B', $b, 0, 255);

        return new static($r, $g, $b);
    }
406829
public static function rgb_to_hsv( $color = array() ) {
		$var_r = ( $color[0] / 255 );
		$var_g = ( $color[1] / 255 );
		$var_b = ( $color[2] / 255 );
		$var_min = min( $var_r, $var_g, $var_b );
		$var_max = max( $var_r, $var_g, $var_b );
		$del_max = $var_max - $var_min;
		$h = 0;
		$s = 0;
		$v = $var_max;
		if ( 0 != $del_max ) {
			$s = $del_max / $var_max;
			$del_r = ( ( ( $var_max - $var_r ) / 6 ) + ( $del_max / 2 ) ) / $del_max;
			$del_g = ( ( ( $var_max - $var_g ) / 6 ) + ( $del_max / 2 ) ) / $del_max;
			$del_b = ( ( ( $var_max - $var_b ) / 6 ) + ( $del_max / 2 ) ) / $del_max;
			if ( $var_r == $var_max ) {
				$h = $del_b - $del_g;
			} elseif ( $var_g == $var_max ) {
				$h = ( 1 / 3 ) + $del_r - $del_b;
			} elseif ( $var_b == $var_max ) {
				$h = ( 2 / 3 ) + $del_g - $del_r;
			}
			if ( $h < 0 ) {
				$h++;
			}
			if ( $h > 1 ) {
				$h--;
			}
		}
		return array(
			'h' => round( $h, 2 ),
			's' => round( $s, 2 ),
			'v' => round( $v, 2 ),
		);
	}
1253093
public function getStyleArray($array)
	{
		switch ($this->_parentPropertyName) {
			case '_endColor':
				$key = 'endcolor';
				break;
			case '_color':
				$key = 'color';
				break;
			case '_startColor':
				$key = 'startcolor';
				break;

		}
		return $this->_parent->getStyleArray(array($key => $array));
	}
1144146
@Pure
	public static String toColor(int red, int green, int blue, int alpha) {
		return toColor(encodeRgbaColor(red, green, blue, alpha));
	}
499989
private function fromArrayToXmlString(array $array)
    {
        $string = '';

        foreach ($array as $key => $value) {
            $string .= '<' . $key . '>' .
                ((is_array($value))
                    ? $this->fromArrayToXmlString($value)
                    : $value) .
                '</' . $key . '>';
        }

        return $string;
    }
1102975
private function createImageColor($colorArray)
	{
		$r = $colorArray['r'];
		$g = $colorArray['g'];
		$b = $colorArray['b'];

		return imagecolorallocate($this->imageResized, $r, $g, $b);
	}
973992
public function mix() : Color
    {
        foreach ($this->colors as $color) {
            $colors  = $color->dec();
            $reds  []= $colors[0];
            $greens[]= $colors[1];
            $blues []= $colors[2];
        }

        $red   = dechex( round(array_sum($reds)  / count($reds)  ) );
        $green = dechex( round(array_sum($greens)/ count($greens)) );
        $blue  = dechex( round(array_sum($blues) / count($blues) ) );

        // pad single-digit hexadecimals with leading zero
        foreach ([&$red, &$green, &$blue] as &$color) {
            if (strlen($color) === 1) {
                $color = "0$color";
            }
        }

        return new Color($red.$green.$blue);
    }
98303
public static function ToHexStringArray ($rgb) {
		$rgb = trim($rgb, '#');
		if ($rgb === '' || ($range = strlen($rgb) / 3) > 2) {
			return false;
		}

		$hex_array = [substr($rgb, 0, $range), substr($rgb, 1 * $range, $range), substr($rgb, 2 * $range, $range)];
		if ($range === 1) {
			$hex_array[0] .= $hex_array[0];
			$hex_array[1] .= $hex_array[1];
			$hex_array[2] .= $hex_array[2];
		}

		return $hex_array;
	}