Source for file Color.php
Documentation is available at Color.php
* Description: Color characteristics
* @copyright (c) 1995-2008 by Steema Software SL. All Rights Reserved. <info@steema.com>
* @link http://www.steema.com
function __get( $property ) {
$method = "get{$property}";
function __set ( $property,$value ) {
$method = "set{$property}";
return $this->$method($value);
* @param integer red [0,255]
* @param integer green [0,255]
* @param integer blue [0,255]
* @param integer alpha [0,255]
function Color($red= 0, $green= 0, $blue= 0, $alpha = 0, $_empty= false, $none= false)
$this->green = (int) $green;
$this->blue = (int) $blue;
$this->alpha = (int) $alpha;
// $this->alpha = (int)round($alpha * 127.0 / 255);
* @param $img GD image resource
// Checks if color has already been allocated
$this->gdColor = imagecolorallocate($img, $this->red, $this->green, $this->blue);
$this->gdColor = imagecolorallocatealpha($img, $this->red, $this->green, $this->blue, $this->alpha);
* Returns true when the Color equals to EMPTY color. <br>
* EMPTY Color means objects will not fill drawing elements.
static public function fromArgb($a, $r, $g, $b) {
return new Color($r, $g, $b, $a);
return new Color(0,0,0,0,true,false);
return new Color (0,0,0,127,false,true); // Transparent
static public Color fromArgb(int value) {
static public Color fromArgb(int value, Color c) {
return new Color(c.getRed(), c.getGreen(), c.getBlue(), value);
static public fromCode($nm) {
return new Color(Color.decode(nm).getRed(),
Color.decode(nm).getGreen(),Color.decode(nm).getBlue(),Color.decode(nm).getAlpha());
static public function fromRgb($r, $g, $b) {
return new Color($r, $g, $b);
* Creates a new Color instance with random RED, GREEN and BLUE color
static public function random() {
* The color black. In the default sRGB space.
static public final function getBlack() {
* The color black. In the default sRGB space.
static public final function BLACK() {
* The color dark gray. In the default sRGB space.
return new Color(169, 169, 169);
* The color dark gray. In the default sRGB space.
return self::getDarkGray();
* The color yellow. In the default sRGB space.
return new Color(255,255,0);
* The color yellow. In the default sRGB space.
static public final function YELLOW() {
return self::getYellow();
* The color red. In the default sRGB space.
* The color red. In the default sRGB space.
static public final function RED() {
return new Color(255,0,0);
* The color green. In the default sRGB space.
* The color green. In the default sRGB space.
static public final function GREEN() {
return new Color(0,128,0);
* The color blue. In the default sRGB space.
* The color blue. In the default sRGB space.
static public final function BLUE() {
return new Color(0,0,255);
* The color silver. In the default sRGB space.
return new Color(192, 192, 192);
* The color silver. In the default sRGB space.
static public final function SILVER() {
return self::getSilver();
* The color gray. In the default sRGB space.
static public final function getGray() {
return new Color(128,128,128);
* The color gray. In the default sRGB space.
static public final function GRAY() {
* The color white. In the default sRGB space.
static public final function getWhite() {
return new Color(255,255,255);
* The color white. In the default sRGB space.
static public final function WHITE() {
* The color white smoke. In the default sRGB space.
return new Color(245, 245, 245);
* The color white smoke. In the default sRGB space.
return self::getWhiteSmoke();
* The color navy. In the default sRGB space.
static public final function getNavy() {
return new Color(0, 0, 128);
* The color navy. In the default sRGB space.
static public final function NAVY() {
* The color gold. In the default sRGB space.
static public final function getGold() {
return new Color(255, 215, 0);
* The color gold. In the default sRGB space.
static public final function GOLD() {
* The color light yellow. In the default sRGB space.
return new Color(255, 255, 224);
* The color light yellow. In the default sRGB space.
return self::getLightYellow();
* The color fuchsia. In the default sRGB space.
return new Color(255, 0, 255);
* The color fuchsia. In the default sRGB space.
static public final function FUCHSIA() {
return self::getFuchsia();
* The color teal. In the default sRGB space.
static public final function getTeal() {
return new Color(0, 128, 128);
* The color teal. In the default sRGB space.
static public final function TEAL() {
* The color maroon. In the default sRGB space.
return new Color(128, 0, 0);
* The color maroon. In the default sRGB space.
static public final function MAROON() {
return self::getMaroon();
* The color lime. In the default sRGB space.
static public final function getLime() {
return new Color(0, 255, 0);
* The color lime. In the default sRGB space.
static public final function LIME() {
* The color olive. In the default sRGB space.
static public final function getOlive() {
return new Color(128, 128, 0);
* The color olive. In the default sRGB space.
static public final function OLIVE() {
* The color purple. In the default sRGB space.
return new Color(128, 0, 128);
* The color purple. In the default sRGB space.
static public final function PURPLE() {
return self::getPurple();
* The color aqua. In the default sRGB space.
static public final function getAqua() {
return new Color(0, 255, 255);
* The color aqua. In the default sRGB space.
static public final function AQUA() {
* The color green yellow. In the default sRGB space.
return new Color(173, 255, 47);
* The color green yellow. In the default sRGB space.
return self::getGreenYellow();
* The color sky blue. In the default sRGB space.
return new Color(135, 206, 235);
* The color sky blue. In the default sRGB space.
static public final function SKY_BLUE() {
return self::getSkyBlue();
* The color bisque. In the default sRGB space.
return new Color(255, 228, 196);
* The color bisque. In the default sRGB space.
static public final function BISQUE() {
return self::getBisque();
* The color indigo. In the default sRGB space.
return new Color(75, 0, 130);
* The color indigo. In the default sRGB space.
static public final function INDIGO() {
return self::getIndigo();
* The color pink. In the default sRGB space.
static public final function getPink() {
return new Color(255,0,255);
* The color pink. In the default sRGB space.
static public final function PINK() {
* The color orange. In the default sRGB space.
return new Color(255,128,64);
* The color orange. In the default sRGB space.
static public final function ORANGE() {
return self::getOrange();
* The color magenta. In the default sRGB space.
return new Color(168, 0, 168);
* The color magenta. In the default sRGB space.
static public final function MAGENTA() {
return self::getMagenta();
* The color cyan. In the default sRGB space.
static public final function getCyan() {
return new Color(0, 128, 128);
* The color cyan. In the default sRGB space.
static public final function CYAN() {
* Returns Color with transparency percentage applied.
* @return Color with transparency percentage applied.
return new Color(self::getRed(), self::getGreen(), self::getBlue(),
* Returns an integer from 0 to 100 that is the percent of transparency
* @see java.awt.Color#getAlpha
return (a == 255) ? 0 : (a == 0) ? 100 : (int) (0.39216 * (255 - a));
* Returns the alpha component in the range 0-255.
* @return the alpha component.
//return ($this->getRGB() >> 24) & 0xff;
* Returns the RGB value representing the color in the default sRGB
* (Bits 24-31 are alpha, 16-23 are red, 8-15 are green, 0-7 are
* @return the RGB value of the color in the default sRGB
* <code>ColorModel</code>.
* @see java.awt.image.ColorModel#getRGBdefault
return 0/*value*/; /* TODO review what to return ?? */
* Converts the Color parameter to a darker color.<br> The HowMuch
* parameter indicates the quantity of dark increment.<br>
* It is used by Bar Series and Pie Series to calculate the right color t
* to draw Bar sides and Pie 3D zones.
return new Color($r, $gr, $b, $this->alpha);
* Converts the Color parameter to a brighter color.<br>
* The HowMuch parameter indicates the quantity of bright increment.<br>
* It is used by Styles.Bar Series and Styles.Pie Series to calculate the
* right color to draw Bar sides and Pie 3D zones.
if (($r + $howMuch) < 256) {
if (($g + $howMuch) < 256) {
if (($b + $howMuch) < 256) {
|