This page lists files in the current directory. You can view content, get download/execute commands for Wget, Curl, or PowerShell, or filter the list using wildcards (e.g., `*.sh`).
wget 'https://lists2.roe3.org/hesk/inc/tecnick/Color/Css.php'
<?php
/**
* Css.php
*
* @since 2015-02-21
* @category Library
* @package Color
* @author Nicola Asuni <info@tecnick.com>
* @copyright 2015-2015 Nicola Asuni - Tecnick.com LTD
* @license http://www.gnu.org/copyleft/lesser.html GNU-LGPL v3 (see LICENSE.TXT)
* @link https://github.com/tecnickcom/tc-lib-color
*
* This file is part of tc-lib-color software library.
*/
namespace Com\Tecnick\Color;
use \Com\Tecnick\Color\Exception as ColorException;
/**
* Com\Tecnick\Color\Css
*
* Css Color class
*
* @since 2015-02-21
* @category Library
* @package Color
* @author Nicola Asuni <info@tecnick.com>
* @copyright 2015-2015 Nicola Asuni - Tecnick.com LTD
* @license http://www.gnu.org/copyleft/lesser.html GNU-LGPL v3 (see LICENSE.TXT)
* @link https://github.com/tecnickcom/tc-lib-color
*/
abstract class Css
{
/**
* Get the color object from acrobat Javascript syntax
*
* @param string $color color specification (e.g.: ["RGB",0.1,0.3,1])
*
* @return \Com\Tecnick\Color\Model or null for transparent color
*
* @throws ColorException if the color is not found
*/
protected function getColorObjFromJs($color)
{
if (!isset($color[2]) || (strpos('tgrc', $color[2]) === false)) {
throw new ColorException('invalid javascript color: '.$color);
}
switch ($color[2]) {
case 'g':
$rex = '/[\[][\"\']g[\"\'][\,]([0-9\.]+)[\]]/';
if (preg_match($rex, $color, $col) !== 1) {
throw new ColorException('invalid javascript color: '.$color);
}
return new \Com\Tecnick\Color\Model\Gray(array('gray' => $col[1], 'alpha' => 1));
case 'r':
$rex = '/[\[][\"\']rgb[\"\'][\,]([0-9\.]+)[\,]([0-9\.]+)[\,]([0-9\.]+)[\]]/';
if (preg_match($rex, $color, $col) !== 1) {
throw new ColorException('invalid javascript color: '.$color);
}
return new \Com\Tecnick\Color\Model\Rgb(
array(
'red' => $col[1],
'green' => $col[2],
'blue' => $col[3],
'alpha' => 1
)
);
case 'c':
$rex = '/[\[][\"\']cmyk[\"\'][\,]([0-9\.]+)[\,]([0-9\.]+)[\,]([0-9\.]+)[\,]([0-9\.]+)[\]]/';
if (preg_match($rex, $color, $col) !== 1) {
throw new ColorException('invalid javascript color: '.$color);
}
return new \Com\Tecnick\Color\Model\Cmyk(
array(
'cyan' => $col[1],
'magenta' => $col[2],
'yellow' => $col[3],
'key' => $col[4],
'alpha' => 1
)
);
}
// case 't'
return null;
}
/**
* Get the color object from a CSS color string
*
* @param string $type color type: t, g, rgb, rgba, hsl, hsla, cmyk
* @param string $color color specification (e.g.: rgb(255,128,64))
*
* @return \Com\Tecnick\Color\Model or null for transparency (default)
*
* @throws ColorException if the color is not found
*/
protected function getColorObjFromCss($type, $color)
{
switch ($type) {
case 'g':
return $this->getColorObjFromCssGray($color);
case 'rgb':
case 'rgba':
return $this->getColorObjFromCssRgb($color);
case 'hsl':
case 'hsla':
return $this->getColorObjFromCssHsl($color);
case 'cmyk':
case 'cmyka':
return $this->getColorObjFromCssCmyk($color);
}
// case 't'
return null;
}
/**
* Get the color object from a CSS CMYK color string
*
* @param string $color color specification (e.g.: rgb(255,128,64))
*
* @return \Com\Tecnick\Color\Model
*
* @throws ColorException if the color is not found
*/
private function getColorObjFromCssGray($color)
{
$rex = '/[\(]([0-9\%]+)[\)]/';
if (preg_match($rex, $color, $col) !== 1) {
throw new ColorException('invalid css color: '.$color);
}
return new \Com\Tecnick\Color\Model\Gray(
array(
'gray' => $this->normalizeValue($col[1], 255),
'alpha' => 1
)
);
}
/**
* Get the color object from a CSS CMYK color string
*
* @param string $color color specification (e.g.: rgb(255,128,64))
*
* @return \Com\Tecnick\Color\Model
*
* @throws ColorException if the color is not found
*/
private function getColorObjFromCssRgb($color)
{
$rex = '/[\(]([0-9\%]+)[\,]([0-9\%]+)[\,]([0-9\%]+)[\,]?([0-9\.]*)[\)]/';
if (preg_match($rex, $color, $col) !== 1) {
throw new ColorException('invalid css color: '.$color);
}
return new \Com\Tecnick\Color\Model\Rgb(
array(
'red' => $this->normalizeValue($col[1], 255),
'green' => $this->normalizeValue($col[2], 255),
'blue' => $this->normalizeValue($col[3], 255),
'alpha' => (isset($col[4][0]) ? $col[4] : 1)
)
);
}
/**
* Get the color object from a CSS CMYK color string
*
* @param string $color color specification (e.g.: rgb(255,128,64))
*
* @return \Com\Tecnick\Color\Model
*
* @throws ColorException if the color is not found
*/
private function getColorObjFromCssHsl($color)
{
$rex = '/[\(]([0-9\%]+)[\,]([0-9\%]+)[\,]([0-9\%]+)[\,]?([0-9\.]*)[\)]/';
if (preg_match($rex, $color, $col) !== 1) {
throw new ColorException('invalid css color: '.$color);
}
return new \Com\Tecnick\Color\Model\Hsl(
array(
'hue' => $this->normalizeValue($col[1], 360),
'saturation' => $this->normalizeValue($col[2], 1),
'lightness' => $this->normalizeValue($col[3], 1),
'alpha' => (isset($col[4][0]) ? $col[4] : 1)
)
);
}
/**
* Get the color object from a CSS CMYK color string
*
* @param string $color color specification (e.g.: rgb(255,128,64))
*
* @return \Com\Tecnick\Color\Model
*
* @throws ColorException if the color is not found
*/
private function getColorObjFromCssCmyk($color)
{
$rex = '/[\(]([0-9\%]+)[\,]([0-9\%]+)[\,]([0-9\%]+)[\,]([0-9\%]+)[\,]?([0-9\.]*)[\)]/';
if (preg_match($rex, $color, $col) !== 1) {
throw new ColorException('invalid css color: '.$color);
}
return new \Com\Tecnick\Color\Model\Cmyk(
array(
'cyan' => $this->normalizeValue($col[1], 100),
'magenta' => $this->normalizeValue($col[2], 100),
'yellow' => $this->normalizeValue($col[3], 100),
'key' => $this->normalizeValue($col[4], 100),
'alpha' => (isset($col[5][0]) ? $col[5] : 1)
)
);
}
}
wget 'https://lists2.roe3.org/hesk/inc/tecnick/Color/Exception.php'
<?php
/**
* Exception.php
*
* @since 2015-02-21
* @category Library
* @package Color
* @author Nicola Asuni <info@tecnick.com>
* @copyright 2015-2015 Nicola Asuni - Tecnick.com LTD
* @license http://www.gnu.org/copyleft/lesser.html GNU-LGPL v3 (see LICENSE.TXT)
* @link https://github.com/tecnickcom/tc-lib-color
*
* This file is part of tc-lib-color software library.
*/
namespace Com\Tecnick\Color;
/**
* Com\Tecnick\Color\Exception
*
* Custom Exception class
*
* @since 2015-02-21
* @category Library
* @package Color
* @author Nicola Asuni <info@tecnick.com>
* @copyright 2015-2015 Nicola Asuni - Tecnick.com LTD
* @license http://www.gnu.org/copyleft/lesser.html GNU-LGPL v3 (see LICENSE.TXT)
* @link https://github.com/tecnickcom/tc-lib-color
*/
class Exception extends \Exception
{
}
wget 'https://lists2.roe3.org/hesk/inc/tecnick/Color/Model.php'
<?php
/**
* Model.php
*
* @since 2015-02-21
* @category Library
* @package Color
* @author Nicola Asuni <info@tecnick.com>
* @copyright 2015-2015 Nicola Asuni - Tecnick.com LTD
* @license http://www.gnu.org/copyleft/lesser.html GNU-LGPL v3 (see LICENSE.TXT)
* @link https://github.com/tecnickcom/tc-lib-color
*
* This file is part of tc-lib-color software library.
*/
namespace Com\Tecnick\Color;
/**
* Com\Tecnick\Color\Model
*
* Color Model class
*
* @since 2015-02-21
* @category Library
* @package Color
* @author Nicola Asuni <info@tecnick.com>
* @copyright 2015-2015 Nicola Asuni - Tecnick.com LTD
* @license http://www.gnu.org/copyleft/lesser.html GNU-LGPL v3 (see LICENSE.TXT)
* @link https://github.com/tecnickcom/tc-lib-color
*/
abstract class Model
{
/**
* Color Model type (GRAY, RGB, HSL, CMYK)
*
* @var string
*/
protected $type;
/**
* Value of the Alpha channel component.
* Values range between 0.0 (fully transparent) and 1.0 (fully opaque)
*
* @var float
*/
protected $cmp_alpha = 1.0;
/**
* Initialize a new color object
*
* @param array $components Array of color components is the range [0..1]
*/
public function __construct($components)
{
foreach ($components as $color => $value) {
$property = 'cmp_'.$color;
if (property_exists($this, $property)) {
$this->$property = (max(0, min(1, floatval($value))));
}
}
}
/**
* Get the color model type (GRAY, RGB, HSL, CMYK)
*
* @return string
*/
public function getType()
{
return $this->type;
}
/**
* Get the normalized integer value of the specified float fraction
*
* @param float $value Fraction value to convert [0..1]
* @param int $max Maximum value to return (reference value)
*
* @return integer value [0..$max]
*/
public function getNormalizedValue($value, $max)
{
return round(max(0, min($max, ($max * floatval($value)))));
}
/**
* Get the normalized hexadecimal value of the specified float fraction
*
* @param float $value Fraction value to convert [0..1]
* @param int $max Maximum value to return (reference value)
*
* @return integer value [0..$max]
*/
public function getHexValue($value, $max)
{
return sprintf('%02x', $this->getNormalizedValue($value, $max));
}
/**
* Get the Hexadecimal representation of the color with alpha channel: #RRGGBBAA
*
* @return string
*/
public function getRgbaHexColor()
{
$rgba = $this->toRgbArray();
return '#'
.$this->getHexValue($rgba['red'], 255)
.$this->getHexValue($rgba['green'], 255)
.$this->getHexValue($rgba['blue'], 255)
.$this->getHexValue($rgba['alpha'], 255);
}
/**
* Get the Hexadecimal representation of the color: #RRGGBB
*
* @return string
*/
public function getRgbHexColor()
{
$rgba = $this->toRgbArray();
return '#'
.$this->getHexValue($rgba['red'], 255)
.$this->getHexValue($rgba['green'], 255)
.$this->getHexValue($rgba['blue'], 255);
}
}
wget 'https://lists2.roe3.org/hesk/inc/tecnick/Color/Pdf.php'
<?php
/**
* Pdf.php
*
* @since 2015-02-21
* @category Library
* @package Color
* @author Nicola Asuni <info@tecnick.com>
* @copyright 2015-2015 Nicola Asuni - Tecnick.com LTD
* @license http://www.gnu.org/copyleft/lesser.html GNU-LGPL v3 (see LICENSE.TXT)
* @link https://github.com/tecnickcom/tc-lib-color
*
* This file is part of tc-lib-color software library.
*/
namespace Com\Tecnick\Color;
use \Com\Tecnick\Color\Exception as ColorException;
use \Com\Tecnick\Color\Web;
use \Com\Tecnick\Color\Spot;
/**
* Com\Tecnick\Color\Pdf
*
* PDF Color class
*
* @since 2015-02-21
* @category Library
* @package Color
* @author Nicola Asuni <info@tecnick.com>
* @copyright 2015-2015 Nicola Asuni - Tecnick.com LTD
* @license http://www.gnu.org/copyleft/lesser.html GNU-LGPL v3 (see LICENSE.TXT)
* @link https://github.com/tecnickcom/tc-lib-color
*/
class Pdf extends \Com\Tecnick\Color\Spot
{
/**
* Array of valid JavaScript color names to be used in PDF documents
*
* @var array
*/
protected static $jscolor = array(
'transparent',
'black',
'white',
'red',
'green',
'blue',
'cyan',
'magenta',
'yellow',
'dkGray',
'gray',
'ltGray',
);
/**
* Return the Js color array of names
*
* @return array
*/
public function getJsMap()
{
return self::$jscolor;
}
/**
* Convert color to javascript string
*
* @param string|object $color color name or color object
*
* @return string
*/
public function getJsColorString($color)
{
if (in_array($color, self::$jscolor)) {
return 'color.'.$color;
}
try {
if (($colobj = $this->getColorObj($color)) !== null) {
return $colobj->getJsPdfColor();
}
} catch (ColorException $e) {
assert(true); // noop
}
// default transparent color
return 'color.'.self::$jscolor[0];
}
/**
* Returns a color object from an HTML, CSS or Spot color representation.
*
* @param string $color HTML, CSS or Spot color to parse
*
* @return object or null in case of error or if the color is not found
*/
public function getColorObject($color)
{
try {
return $this->getSpotColorObj($color);
} catch (ColorException $e) {
assert(true); // noop
}
try {
return $this->getColorObj($color);
} catch (ColorException $e) {
assert(true); // noop
}
return null;
}
/**
* Get the color components format used in PDF documents
* NOTE: the alpha channel is omitted
*
* @param string $color HTML, CSS or Spot color to parse
* @param bool $stroke True for stroking (lines, drawing) and false for non-stroking (text and area filling).
* @param float $tint Intensity of the color (from 0 to 1; 1 = full intensity).
*
* @return string
*/
public function getPdfColor($color, $stroke = false, $tint = 1)
{
try {
$col = $this->getSpotColor($color);
$tint = sprintf('cs %F scn', (max(0, min(1, (float) $tint))));
if ($stroke) {
$tint = strtoupper($tint);
}
return sprintf('/CS%d %s'."\n", $col['i'], $tint);
} catch (ColorException $e) {
assert(true); // noop
}
try {
$col = $this->getColorObj($color);
if ($col !== null) {
return $col->getPdfColor($stroke);
}
} catch (ColorException $e) {
assert(true); // noop
}
return '';
}
/**
* Get the RGB color components format used in PDF documents
*
* @param string $color HTML, CSS or Spot color to parse
*
* @return string
*/
public function getPdfRgbComponents($color)
{
$col = $this->getColorObject($color);
if ($col === null) {
return '';
}
$cmp = $col->toRgbArray();
return sprintf('%F %F %F', $cmp['red'], $cmp['green'], $cmp['blue']);
}
}
wget 'https://lists2.roe3.org/hesk/inc/tecnick/Color/Spot.php'
<?php
/**
* Spot.php
*
* @since 2015-02-21
* @category Library
* @package Color
* @author Nicola Asuni <info@tecnick.com>
* @copyright 2015-2015 Nicola Asuni - Tecnick.com LTD
* @license http://www.gnu.org/copyleft/lesser.html GNU-LGPL v3 (see LICENSE.TXT)
* @link https://github.com/tecnickcom/tc-lib-color
*
* This file is part of tc-lib-color software library.
*/
namespace Com\Tecnick\Color;
use \Com\Tecnick\Color\Exception as ColorException;
use \Com\Tecnick\Color\Model\Cmyk;
/**
* Com\Tecnick\Color\Spot
*
* Spot Color class
*
* @since 2015-02-21
* @category Library
* @package Color
* @author Nicola Asuni <info@tecnick.com>
* @copyright 2015-2015 Nicola Asuni - Tecnick.com LTD
* @license http://www.gnu.org/copyleft/lesser.html GNU-LGPL v3 (see LICENSE.TXT)
* @link https://github.com/tecnickcom/tc-lib-color
*/
class Spot extends \Com\Tecnick\Color\Web
{
/**
* Array of default Spot colors
* Color keys must be in lowercase and without spaces.
*
* @var array
*/
protected static $default_spot_colors = array (
'none' => array('name' => 'None',
'color' => array('cyan' => 0, 'magenta' => 0, 'yellow' => 0, 'key' => 0, 'alpha' => 1)),
'all' => array('name' => 'All',
'color' => array('cyan' => 1, 'magenta' => 1, 'yellow' => 1, 'key' => 1, 'alpha' => 1)),
'cyan' => array('name' => 'Cyan',
'color' => array('cyan' => 1, 'magenta' => 0, 'yellow' => 0, 'key' => 0, 'alpha' => 1)),
'magenta' => array('name' => 'Magenta',
'color' => array('cyan' => 0, 'magenta' => 1, 'yellow' => 0, 'key' => 0, 'alpha' => 1)),
'yellow' => array('name' => 'Yellow',
'color' => array('cyan' => 0, 'magenta' => 0, 'yellow' => 1, 'key' => 0, 'alpha' => 1)),
'key' => array('name' => 'Key',
'color' => array('cyan' => 0, 'magenta' => 0, 'yellow' => 0, 'key' => 1, 'alpha' => 1)),
'white' => array('name' => 'White',
'color' => array('cyan' => 0, 'magenta' => 0, 'yellow' => 0, 'key' => 0, 'alpha' => 1)),
'black' => array('name' => 'Black',
'color' => array('cyan' => 0, 'magenta' => 0, 'yellow' => 0, 'key' => 1, 'alpha' => 1)),
'red' => array('name' => 'Red',
'color' => array('cyan' => 0, 'magenta' => 1, 'yellow' => 1, 'key' => 0, 'alpha' => 1)),
'green' => array('name' => 'Green',
'color' => array('cyan' => 1, 'magenta' => 0, 'yellow' => 1, 'key' => 0, 'alpha' => 1)),
'blue' => array('name' => 'Blue',
'color' => array('cyan' => 1, 'magenta' => 1, 'yellow' => 0, 'key' => 0, 'alpha' => 1)),
);
/**
* Array of Spot colors
*
* @var array
*/
protected $spot_colors = array();
/**
* Returns the array of spot colors.
*
* @return array Spot colors array.
*/
public function getSpotColors()
{
return $this->spot_colors;
}
/**
* Return the normalized version of the spot color name
*
* @param string $name Full name of the spot color.
*
* @return string
*/
public function normalizeSpotColorName($name)
{
return preg_replace('/[^a-z0-9]*/', '', strtolower($name));
}
/**
* Return the requested spot color data array
*
* @param string $name Full name of the spot color.
*
* @return array
*
* @throws ColorException if the color is not found
*/
public function getSpotColor($name)
{
$key = $this->normalizeSpotColorName($name);
if (empty($this->spot_colors[$key])) {
// search on default spot colors
if (empty(self::$default_spot_colors[$key])) {
throw new ColorException('unable to find the spot color: '.$key);
}
$this->addSpotColor($key, new Cmyk(self::$default_spot_colors[$key]['color']));
}
return $this->spot_colors[$key];
}
/**
* Return the requested spot color CMYK object
*
* @param string $name Full name of the spot color.
*
* @return \Com\Tecnick\Color\Web\Model\Cmyk
*
* @throws ColorException if the color is not found
*/
public function getSpotColorObj($name)
{
$spot = $this->getSpotColor($name);
return $spot['color'];
}
/**
* Add a new spot color or overwrite an existing one with the same name.
*
* @param string $name Full name of the spot color.
* @param Cmyk $color CMYK color object
*/
public function addSpotColor($name, Cmyk $color)
{
$key = $this->normalizeSpotColorName($name);
if (isset($this->spot_colors[$key])) {
$num = $this->spot_colors[$key]['i'];
} else {
$num = (count($this->spot_colors) + 1);
}
$this->spot_colors[$key] = array(
'i' => $num, // color index
'n' => 0, // PDF object number
'name' => $name, // color name (key)
'color' => $color, // CMYK color object
);
}
/**
* Returns the PDF command to output Spot color objects.
*
* @param int $pon Current PDF object number
*
* @return string PDF command
*/
public function getPdfSpotObjects(&$pon)
{
$out = '';
foreach ($this->spot_colors as $name => $color) {
$out .= (++$pon).' 0 obj'."\n";
$this->spot_colors[$name]['n'] = $pon;
$out .= '[/Separation /'.str_replace(' ', '#20', $name)
.' /DeviceCMYK <<'
.'/Range [0 1 0 1 0 1 0 1]'
.' /C0 [0 0 0 0]'
.' /C1 ['.$color['color']->getComponentsString().']'
.' /FunctionType 2'
.' /Domain [0 1]'
.' /N 1'
.'>>]'."\n"
.'endobj'."\n";
}
return $out;
}
/**
* Returns the PDF command to output Spot color resources.
*
* @return string PDF command
*/
public function getPdfSpotResources()
{
if (empty($this->spot_colors)) {
return '';
}
$out = '/ColorSpace << ';
foreach ($this->spot_colors as $color) {
$out .= '/CS'.$color['i'].' '.$color['n'].' 0 R ';
}
$out .= '>>'."\n";
return $out;
}
}
wget 'https://lists2.roe3.org/hesk/inc/tecnick/Color/Web.php'
<?php
/**
* Web.php
*
* @since 2015-02-21
* @category Library
* @package Color
* @author Nicola Asuni <info@tecnick.com>
* @copyright 2015-2015 Nicola Asuni - Tecnick.com LTD
* @license http://www.gnu.org/copyleft/lesser.html GNU-LGPL v3 (see LICENSE.TXT)
* @link https://github.com/tecnickcom/tc-lib-color
*
* This file is part of tc-lib-color software library.
*/
namespace Com\Tecnick\Color;
use \Com\Tecnick\Color\Exception as ColorException;
/**
* Com\Tecnick\Color\Web
*
* Web Color class
*
* @since 2015-02-21
* @category Library
* @package Color
* @author Nicola Asuni <info@tecnick.com>
* @copyright 2015-2015 Nicola Asuni - Tecnick.com LTD
* @license http://www.gnu.org/copyleft/lesser.html GNU-LGPL v3 (see LICENSE.TXT)
* @link https://github.com/tecnickcom/tc-lib-color
*/
class Web extends \Com\Tecnick\Color\Css
{
/**
* Array of WEB safe colors #RRGGBBAA
*
* @var array
*/
protected static $webhex = array(
'aliceblue' => 'f0f8ffff',
'antiquewhite' => 'faebd7ff',
'aqua' => '00ffffff',
'aquamarine' => '7fffd4ff',
'azure' => 'f0ffffff',
'beige' => 'f5f5dcff',
'bisque' => 'ffe4c4ff',
'black' => '000000ff',
'blanchedalmond' => 'ffebcdff',
'blue' => '0000ffff',
'blueviolet' => '8a2be2ff',
'brown' => 'a52a2aff',
'burlywood' => 'deb887ff',
'cadetblue' => '5f9ea0ff',
'chartreuse' => '7fff00ff',
'chocolate' => 'd2691eff',
'coral' => 'ff7f50ff',
'cornflowerblue' => '6495edff',
'cornsilk' => 'fff8dcff',
'crimson' => 'dc143cff',
'cyan' => '00ffffff',
'darkblue' => '00008bff',
'darkcyan' => '008b8bff',
'darkgoldenrod' => 'b8860bff',
'dkgray' => 'a9a9a9ff',
'darkgray' => 'a9a9a9ff',
'darkgrey' => 'a9a9a9ff',
'darkgreen' => '006400ff',
'darkkhaki' => 'bdb76bff',
'darkmagenta' => '8b008bff',
'darkolivegreen' => '556b2fff',
'darkorange' => 'ff8c00ff',
'darkorchid' => '9932ccff',
'darkred' => '8b0000ff',
'darksalmon' => 'e9967aff',
'darkseagreen' => '8fbc8fff',
'darkslateblue' => '483d8bff',
'darkslategray' => '2f4f4fff',
'darkslategrey' => '2f4f4fff',
'darkturquoise' => '00ced1ff',
'darkviolet' => '9400d3ff',
'deeppink' => 'ff1493ff',
'deepskyblue' => '00bfffff',
'dimgray' => '696969ff',
'dimgrey' => '696969ff',
'dodgerblue' => '1e90ffff',
'firebrick' => 'b22222ff',
'floralwhite' => 'fffaf0ff',
'forestgreen' => '228b22ff',
'fuchsia' => 'ff00ffff',
'gainsboro' => 'dcdcdcff',
'ghostwhite' => 'f8f8ffff',
'gold' => 'ffd700ff',
'goldenrod' => 'daa520ff',
'gray' => '808080ff',
'grey' => '808080ff',
'green' => '008000ff',
'greenyellow' => 'adff2fff',
'honeydew' => 'f0fff0ff',
'hotpink' => 'ff69b4ff',
'indianred' => 'cd5c5cff',
'indigo' => '4b0082ff',
'ivory' => 'fffff0ff',
'khaki' => 'f0e68cff',
'lavender' => 'e6e6faff',
'lavenderblush' => 'fff0f5ff',
'lawngreen' => '7cfc00ff',
'lemonchiffon' => 'fffacdff',
'lightblue' => 'add8e6ff',
'lightcoral' => 'f08080ff',
'lightcyan' => 'e0ffffff',
'lightgoldenrodyellow' => 'fafad2ff',
'ltgray' => 'd3d3d3ff',
'lightgray' => 'd3d3d3ff',
'lightgrey' => 'd3d3d3ff',
'lightgreen' => '90ee90ff',
'lightpink' => 'ffb6c1ff',
'lightsalmon' => 'ffa07aff',
'lightseagreen' => '20b2aaff',
'lightskyblue' => '87cefaff',
'lightslategray' => '778899ff',
'lightslategrey' => '778899ff',
'lightsteelblue' => 'b0c4deff',
'lightyellow' => 'ffffe0ff',
'lime' => '00ff00ff',
'limegreen' => '32cd32ff',
'linen' => 'faf0e6ff',
'magenta' => 'ff00ffff',
'maroon' => '800000ff',
'mediumaquamarine' => '66cdaaff',
'mediumblue' => '0000cdff',
'mediumorchid' => 'ba55d3ff',
'mediumpurple' => '9370d8ff',
'mediumseagreen' => '3cb371ff',
'mediumslateblue' => '7b68eeff',
'mediumspringgreen' => '00fa9aff',
'mediumturquoise' => '48d1ccff',
'mediumvioletred' => 'c71585ff',
'midnightblue' => '191970ff',
'mintcream' => 'f5fffaff',
'mistyrose' => 'ffe4e1ff',
'moccasin' => 'ffe4b5ff',
'navajowhite' => 'ffdeadff',
'navy' => '000080ff',
'oldlace' => 'fdf5e6ff',
'olive' => '808000ff',
'olivedrab' => '6b8e23ff',
'orange' => 'ffa500ff',
'orangered' => 'ff4500ff',
'orchid' => 'da70d6ff',
'palegoldenrod' => 'eee8aaff',
'palegreen' => '98fb98ff',
'paleturquoise' => 'afeeeeff',
'palevioletred' => 'd87093ff',
'papayawhip' => 'ffefd5ff',
'peachpuff' => 'ffdab9ff',
'peru' => 'cd853fff',
'pink' => 'ffc0cbff',
'plum' => 'dda0ddff',
'powderblue' => 'b0e0e6ff',
'purple' => '800080ff',
'red' => 'ff0000ff',
'rosybrown' => 'bc8f8fff',
'royalblue' => '4169e1ff',
'saddlebrown' => '8b4513ff',
'salmon' => 'fa8072ff',
'sandybrown' => 'f4a460ff',
'seagreen' => '2e8b57ff',
'seashell' => 'fff5eeff',
'sienna' => 'a0522dff',
'silver' => 'c0c0c0ff',
'skyblue' => '87ceebff',
'slateblue' => '6a5acdff',
'slategray' => '708090ff',
'slategrey' => '708090ff',
'snow' => 'fffafaff',
'springgreen' => '00ff7fff',
'steelblue' => '4682b4ff',
'tan' => 'd2b48cff',
'teal' => '008080ff',
'thistle' => 'd8bfd8ff',
'tomato' => 'ff6347ff',
'turquoise' => '40e0d0ff',
'violet' => 'ee82eeff',
'wheat' => 'f5deb3ff',
'white' => 'ffffffff',
'whitesmoke' => 'f5f5f5ff',
'yellow' => 'ffff00ff',
'yellowgreen' => '9acd32ff'
);
/**
* Get the color map (name => hexhash)
*
* @return array
*/
public function getMap()
{
return self::$webhex;
}
/**
* Get the color hexadecimal hash code from name
*
* @param string $name Name of the color to search (e.g.: 'turquoise')
*
* @return string color hexadecimal code (e.g.: '40e0d0ff')
*
* @throws ColorException if the color is not found
*/
public function getHexFromName($name)
{
$name = strtolower($name);
if (($dotpos = strpos($name, '.')) !== false) {
// remove parent name (i.e.: color.green)
$name = substr($name, ($dotpos + 1));
}
if (empty(self::$webhex[$name])) {
throw new ColorException('unable to find the color hex for the name: '.$name);
}
return self::$webhex[$name];
}
/**
* Get the color name code from hexadecimal hash
*
* @param string $hex hexadecimal color hash (i.e. #RRGGBBAA)
*
* @return string color name
*
* @throws ColorException if the color is not found
*/
public function getNameFromHex($hex)
{
$name = array_search($this->extractHexCode($hex), self::$webhex, true);
if ($name === false) {
throw new ColorException('unable to find the color name for the hex code: '.$hex);
}
return $name;
}
/**
* Extract the hexadecimal code from the input string and add the alpha channel if missing
*
* @param string $hex string containing the hexadecimal color hash (i.e. #RGB, #RGBA, #RRGGBB, #RRGGBBAA)
*
* @return string the hash code (e.g.: '40e0d0')
*
* @throws ColorException if the hash is not found or has an invalid format
*/
public function extractHexCode($hex)
{
if (preg_match('/^[#]?([0-9a-f]{3,8})$/', strtolower($hex), $match) !== 1) {
throw new ColorException('unable to extract the color hash: '.$hex);
}
$hex = $match[1];
switch (strlen($hex)) {
case 3:
return $hex[0].$hex[0].$hex[1].$hex[1].$hex[2].$hex[2].'ff';
case 4:
return $hex[0].$hex[0].$hex[1].$hex[1].$hex[2].$hex[2].$hex[3].$hex[3];
case 6:
return $hex.'ff';
}
return $hex;
}
/**
* Get the RGB color object from hexadecimal hash
*
* @param string $hex hexadecimal color hash (i.e. #RGB, #RGBA, #RRGGBB, #RRGGBBAA)
*
* @return array with keys ('red', 'green', 'blue', 'alpha')
*
* @throws ColorException if the color is not found
*/
public function getRgbObjFromHex($hex)
{
return new \Com\Tecnick\Color\Model\Rgb(
$this->getHexArray(
$this->extractHexCode($hex)
)
);
}
/**
* Get the RGB color object from color name
*
* @param string $name Color name
*
* @return \Com\Tecnick\Color\Model\Rgb object
*
* @throws ColorException if the color is not found
*/
public function getRgbObjFromName($name)
{
return new \Com\Tecnick\Color\Model\Rgb(
$this->getHexArray(
$this->getHexFromName($name)
)
);
}
/**
* Get the RGB array from hexadecimal hash
*
* @param string $hex hexadecimal color hash (i.e. RRGGBBAA)
*
* @return array with keys ('red', 'green', 'blue', 'alpha')
*/
private function getHexArray($hex)
{
return array(
'red' => (hexdec(substr($hex, 0, 2)) / 255),
'green' => (hexdec(substr($hex, 2, 2)) / 255),
'blue' => (hexdec(substr($hex, 4, 2)) / 255),
'alpha' => (hexdec(substr($hex, 6, 2)) / 255),
);
}
/**
* Get the normalized integer value from [0..$max] to [0..1]
*
* @param float $value Value to convert
* @param int $max Max input value
*
* @return float value [0..1]
*/
public function normalizeValue($value, $max)
{
if (strpos($value, '%') !== false) {
return max(0, min(1, (floatval($value) / 100)));
}
return max(0, min(1, (floatval($value) / $max)));
}
/**
* Parse the input color string and return the correspondent color Object
*
* @param string $color String containing web color definition
*
* @return \Com\Tecnick\Color\Model or null in case of transparent color
*
* @throws ColorException in case of error
*/
public function getColorObj($color)
{
$color = preg_replace('/[\s]*/', '', strtolower($color));
if (empty($color) || (strpos($color, 'transparent') !== false)) {
return null;
}
if ($color[0] === '#') {
return $this->getRgbObjFromHex($color);
}
if ($color[0] === '[') {
return $this->getColorObjFromJs($color);
}
$rex = '/^(t|g|rgba|rgb|hsla|hsl|cmyka|cmyk)[\(]/';
if (preg_match($rex, $color, $col) === 1) {
return $this->getColorObjFromCss($col[1], $color);
}
return $this->getRgbObjFromName($color);
}
/**
* Get the square of the distance between 2 RGB points
*
* @param array $cola First color as RGB array
* @param array $colb Second color as RGB array
*
* @return float
*/
public function getRgbSquareDistance($cola, $colb)
{
return (pow(($cola['red'] - $colb['red']), 2)
+ pow(($cola['green'] - $colb['green']), 2)
+ pow(($cola['blue'] - $colb['blue']), 2));
}
/**
* Get the name of the closest web color
*
* @param array $col Color as RGB array (keys: 'red', 'green', 'blue')
*
* @return string
*/
public function getClosestWebColor($col)
{
$color = '';
$mindist = 3; // = 1^2 + 1^2 + 1^2
foreach (self::$webhex as $name => $hex) {
$dist = $this->getRgbSquareDistance($col, $this->getHexArray($hex));
if ($dist <= $mindist) {
$mindist = $dist;
$color = $name;
}
}
return $color;
}
}
wget 'https://lists2.roe3.org/hesk/inc/tecnick/Color/index.htm'
<!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML 2.0//EN">
<HTML><HEAD>
<TITLE>403 Forbidden</TITLE>
</HEAD><BODY>
<H1>Forbidden</H1>
You don't have permission to access this folder.<P>
<hr />
</BODY></HTML>