From be2491b093b1f0ca430bede679ecbb670041e483 Mon Sep 17 00:00:00 2001 From: cassio Date: Tue, 2 Jul 2013 09:46:45 +0400 Subject: restructuring of boca's git --- src/libchart/classes/Color.php | 74 ++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 74 insertions(+) create mode 100644 src/libchart/classes/Color.php (limited to 'src/libchart/classes/Color.php') diff --git a/src/libchart/classes/Color.php b/src/libchart/classes/Color.php new file mode 100644 index 0000000..178435b --- /dev/null +++ b/src/libchart/classes/Color.php @@ -0,0 +1,74 @@ +red = (int)$red; + $this->green = (int)$green; + $this->blue = (int)$blue; + $this->alpha = (int)round($alpha * 127.0 / 255); + + $this->gdColor = null; + } + + /** + * Get GD color + * + * @access public + * @param $img GD image resource + */ + + function getColor($img) + { + // Checks if color has already been allocated + + if(!$this->gdColor) + { + if($this->alpha == 0 || !function_exists('imagecolorallocatealpha')) + $this->gdColor = imagecolorallocate($img, $this->red, $this->green, $this->blue); + else + $this->gdColor = imagecolorallocatealpha($img, $this->red, $this->green, $this->blue, $this->alpha); + } + + // Returns GD color + + return $this->gdColor; + } + } +?> -- cgit v1.2.3