diff options
author | Kore Nordmann <github@kore-nordmann.de> | 2006-08-25 01:20:36 +0000 |
---|---|---|
committer | Kore Nordmann <github@kore-nordmann.de> | 2006-08-25 01:20:36 +0000 |
commit | 4e50ab6291dc2430ef9ce4cc42c100c021e1a3b0 (patch) | |
tree | b476fac1f2f6caf72c476fa2cb71d496878d911f /src/structs | |
parent | 5298e85976086eeaac3517c359e41f2c2ee444d5 (diff) | |
download | zetacomponents-graph-4e50ab6291dc2430ef9ce4cc42c100c021e1a3b0.zip zetacomponents-graph-4e50ab6291dc2430ef9ce4cc42c100c021e1a3b0.tar.gz |
- Pimped pie charts
Look at Graph/tests/data/compare/ezcGraphRenderer3dTest_testRenderLabeledPieSegmentWithGleamAndShadow.svg
# Caused by a 25h travel from Dortmund to Vancover and commited on an open
# WLAN in Osoyoos in Okanagan Valley, Canada
Diffstat (limited to 'src/structs')
-rw-r--r-- | src/structs/color.php | 240 |
1 files changed, 0 insertions, 240 deletions
diff --git a/src/structs/color.php b/src/structs/color.php deleted file mode 100644 index 99d9fde..0000000 --- a/src/structs/color.php +++ /dev/null @@ -1,240 +0,0 @@ -<?php - -/** - * ezcGraphColor - * - * Struct for representing colors in ezcGraph. A color is defined using the - * common RGBA model with integer values between 0 and 255. An alpha value - * of zero means full opacity, while 255 means full transparency. - */ -class ezcGraphColor -{ - /** - * Red color value. - * - * Contains a value between 0 and 255 - * - * @var integer - */ - public $red = 0; - - /** - * Green color value. - * - * Contains a value between 0 and 255 - * - * @var integer - */ - public $green = 0; - - /** - * Blue color value. - * - * Contains a value between 0 and 255 - * - * @var integer - */ - public $blue = 0; - - /** - * Alpha color value. - * - * Contains a value between 0 and 255. 0 means full opacity and 255 full - * transparency. - * - * @var integer - */ - public $alpha = 0; - - /** - * Empty constructor - */ - public function __construct() - { - } - - /** - * Throws a BasePropertyNotFound exception. - */ - public function __set( $name, $key ) - { - throw new ezcBasePropertyNotFoundException( $name ); - } - - /** - * Throws a BasePropertyNotFound exception. - */ - public function __get( $name ) - { - throw new ezcBasePropertyNotFoundException( $name ); - } - - /** - * Creates an ezcGraphColor object from a hexadecimal color representation - * - * @param mixed $string Hexadecimal color representation - * @return ezcGraphColor - */ - static public function fromHex( $string ) - { - // Remove trailing # - if ( $string[0] === '#' ) - { - $string = substr( $string, 1 ); - } - - // Iterate over chunks and convert to integer - $color = new ezcGraphColor(); - $keys = array( 'red', 'green', 'blue', 'alpha' ); - foreach ( str_split( $string, 2) as $nr => $hexValue ) - { - if ( isset( $keys[$nr] ) ) - { - $key = $keys[$nr]; - $color->$key = hexdec( $hexValue ) % 256; - } - } - - // Set missing values to zero - for ( ++$nr; $nr < count( $keys ); ++$nr ) - { - $key = $keys[$nr]; - $color->$key = 0; - } - - return $color; - } - - /** - * Creates an ezcGraphColor object from an array of integers - * - * @param array $array Array of integer color values - * @return ezcGraphColor - */ - static public function fromIntegerArray( array $array ) - { - // Iterate over array elements - $color = new ezcGraphColor(); - $keys = array( 'red', 'green', 'blue', 'alpha' ); - $nr = 0; - foreach ( $array as $colorValue ) - { - if ( isset( $keys[$nr] ) ) - { - $key = $keys[$nr++]; - $color->$key = ( (int) $colorValue ) % 256; - } - } - - // Set missing values to zero - for ( ++$nr; $nr < count( $keys ); ++$nr ) - { - $key = $keys[$nr]; - $color->$key = 0; - } - - return $color; - } - - /** - * Creates an ezcGraphColor object from an array of floats - * - * @param array $array Array of float color values - * @return ezcGraphColor - */ - static public function fromFloatArray( array $array ) - { - // Iterate over array elements - $color = new ezcGraphColor(); - $keys = array( 'red', 'green', 'blue', 'alpha' ); - $nr = 0; - foreach ( $array as $colorValue ) - { - if ( isset( $keys[$nr] ) ) - { - $key = $keys[$nr++]; - $color->$key = ( (float) $colorValue * 255 ) % 256; - } - } - - // Set missing values to zero - for ( ++$nr; $nr < count( $keys ); ++$nr ) - { - $key = $keys[$nr]; - $color->$key = 0; - } - - return $color; - } - - /** - * Tries to detect type of color color definition and returns an - * ezcGraphColor object - * - * @param mixed $color Some kind of color definition - * @return ezcGraphColor - */ - static public function create( $color ) - { - if ( $color instanceof ezcGraphColor ) - { - return $color; - } - elseif ( is_string( $color ) ) - { - return ezcGraphColor::fromHex( $color ); - } - elseif ( is_array( $color ) ) - { - $testElement = reset( $color ); - if ( is_int( $testElement ) ) - { - return ezcGraphColor::fromIntegerArray( $color ); - } - else - { - return ezcGraphColor::fromFloatArray( $color ); - } - } - else - { - throw new ezcGraphUnknownColorDefinitionException( $color ); - } - } - - /** - * Returns a copy of the current color made more transparent by the given - * factor - * - * @param mixed $value Percent to make color mor transparent - * @return ezcGraphColor New color - */ - public function transparent( $value ) - { - $color = clone $this; - - $color->alpha = 255 - (int) round( ( 255 - $this->alpha ) * ( 1 - $value ) ); - - return $color; - } - - /** - * Returns a copy of the current color darkened by the given factor - * - * @param float $value Percent to darken the color - * @return ezcGraphColor New color - */ - public function darken( $value ) - { - $color = clone $this; - - $value = 1 - $value; - $color->red = (int) round( $this->red * $value ); - $color->green = (int) round( $this->green * $value ); - $color->blue = (int) round( $this->blue * $value ); - - return $color; - } -} - -?> |