Update to PEAR 1.7.2, Image_Canvas 0.3.1, Image_Color 1.0.3, Image_Graph 0.7.2, XML_Parser 1.3.1.

Removed PHP_Compat, and references to it.
Removed ionCube/Zend/mmCache compatibility checks in test.php script.
Changed minimum PHP requirement to 5.0 in test.php script.
This commit is contained in:
anubis
2009-01-04 19:22:54 -05:00
parent 60b674c776
commit fae6352bf2
384 changed files with 34150 additions and 44524 deletions

View File

@@ -1,182 +1,182 @@
<?php
/* vim: set expandtab tabstop=4 shiftwidth=4: */
// +----------------------------------------------------------------------+
// | PHP Version 4 |
// +----------------------------------------------------------------------+
// | Copyright (c) 1997-2003 The PHP Group |
// +----------------------------------------------------------------------+
// | This source file is subject to version 2.02 of the PHP license, |
// | that is bundled with this package in the file LICENSE, and is |
// | available at through the world-wide-web at |
// | http://www.php.net/license/2_02.txt. |
// | If you did not receive a copy of the PHP license and are unable to |
// | obtain it through the world-wide-web, please send a note to |
// | license@php.net so we can mail you a copy immediately. |
// +----------------------------------------------------------------------+
// | Author: Stefan Neufeind <pear.neufeind@speedpartner.de> |
// +----------------------------------------------------------------------+
//
// $Id: Color.php,v 1.3 2005/09/14 17:25:46 nosey Exp $
/**
* Class for color-handling
*
* @author Stefan Neufeind <pear.neufeind@speedpartner.de>
* @package Image_Canvas
* @category images
* @license The PHP License, version 2.02
*/
/**
* Color class to be extended; from package PEAR::Image_Color
*/
require_once 'Image/Color.php';
/**
* Class for color-handling
*
* This is used to extend the functionality of the current PEAR::Image_Color v0.4.
* I hope to be allowed to incorporate some of the improvements in a new Image_Color release.
*
* @author Stefan Neufeind <pear.neufeind@speedpartner.de>
* @package Image_Canvas
* @access public
*/
class Image_Canvas_Color extends Image_Color
{
/**
* Allocates a color in the given image.
*
* Userdefined color specifications get translated into
* an array of rgb values.
*
* @param resource GD-resource
* @param mixed any color representation supported by color2RGB()
* @return resource Image color handle
* @see color2RGB()
* @access public
* @static
*/
function allocateColor(&$img, $color)
{
$color = Image_Canvas_Color::color2RGB($color);
if (($color[3] == 255) || (!function_exists("imagecolorallocatealpha"))) {
return imagecolorallocate($img, $color[0], $color[1], $color[2]);
} else {
return imagecolorallocatealpha($img, $color[0], $color[1], $color[2], 127-round(($color[3]*127)/255));
}
}
/**
* Convert any color-representation into an array of 4 ints (RGBA).
*
* Userdefined color specifications get translated into
* an array of rgb values.
*
* @param mixed any color representation supported by Image_Canvas_Color::color2RGB()
* @return array Array of 4 ints (RGBA-representation)
* @access public
* @static
*/
function color2RGB($color)
{
if (is_array($color)) {
if (!is_numeric($color[0])) {
return null; // error
}
if (count($color) == 3) { // assume RGB-color
// 255 = alpha-value; full opaque
return array((int) $color[0],
(int) $color[1],
(int) $color[2],
255);
}
if (count($color) == 4) { // assume RGBA-color
// 255 = alpha-value; full opaque
return array((int) $color[0],
(int) $color[1],
(int) $color[2],
(int) $color[3]);
}
return null; // error
} elseif (is_string($color)) {
$alphaPos = strpos($color, '@');
if ($alphaPos === false) {
$alpha = 255;
} else {
$alphaFloat = (float) substr($color, $alphaPos+1);
// restrict to range 0..1
$alphaFloat = max(min($alphaFloat, 1), 0);
$alpha = (int) round((float) 255 * $alphaFloat);
$color = substr($color, 0, $alphaPos);
}
if ($color[0] == '#') { // hex-color given, e.g. #FFB4B4
$tempColor = parent::hex2rgb($color);
return array((int) $tempColor[0],
(int) $tempColor[1],
(int) $tempColor[2],
$alpha);
}
if (strpos($color,'%') !== false) {
$tempColor = parent::percentageColor2RGB($color);
return array((int) $tempColor[0],
(int) $tempColor[1],
(int) $tempColor[2],
$alpha);
} else {
$tempColor = parent::namedColor2RGB($color);
return array((int) $tempColor[0],
(int) $tempColor[1],
(int) $tempColor[2],
$alpha);
}
} else {
return null; // error
}
}
/**
* getRange
* Given a degree, you can get the range of colors between one color and
* another color.
*
* @access public
* @param string How much each 'step' between the colors we should take.
* @return array Returns an array of all the colors, one element for each color.
*/
function getRange ($degrees)
{
$tempColors = parent::getRange($degrees);
// now add alpha-channel information
$steps = count($tempColors);
for($counter=0;$counter<$steps;$counter++) {
$tempColors[$counter] = parent::hex2rgb($tempColors[$counter]);
unset($tempColors[$counter]['hex']);
$tempColors[$counter][3] = (int) round(
(((float) $this->color1[3]*($steps-$counter))+
((float) $this->color2[3]*($counter))
) / $steps
);
}
return $tempColors;
}
/**
* Internal method to correctly set the colors.
*
* @param mixed color 1
* @param mixed color 2
* @access private
*/
function _setColors ( $col1, $col2 )
{
$this->color1 = Image_Canvas_Color::color2RGB($col1);
$this->color2 = Image_Canvas_Color::color2RGB($col2);
}
}
<?php
/* vim: set expandtab tabstop=4 shiftwidth=4: */
// +----------------------------------------------------------------------+
// | PHP Version 4 |
// +----------------------------------------------------------------------+
// | Copyright (c) 1997-2003 The PHP Group |
// +----------------------------------------------------------------------+
// | This source file is subject to version 2.02 of the PHP license, |
// | that is bundled with this package in the file LICENSE, and is |
// | available at through the world-wide-web at |
// | http://www.php.net/license/2_02.txt. |
// | If you did not receive a copy of the PHP license and are unable to |
// | obtain it through the world-wide-web, please send a note to |
// | license@php.net so we can mail you a copy immediately. |
// +----------------------------------------------------------------------+
// | Author: Stefan Neufeind <pear.neufeind@speedpartner.de> |
// +----------------------------------------------------------------------+
//
// $Id: Color.php,v 1.3 2005/09/14 17:25:46 nosey Exp $
/**
* Class for color-handling
*
* @author Stefan Neufeind <pear.neufeind@speedpartner.de>
* @package Image_Canvas
* @category images
* @license The PHP License, version 2.02
*/
/**
* Color class to be extended; from package PEAR::Image_Color
*/
require_once 'Image/Color.php';
/**
* Class for color-handling
*
* This is used to extend the functionality of the current PEAR::Image_Color v0.4.
* I hope to be allowed to incorporate some of the improvements in a new Image_Color release.
*
* @author Stefan Neufeind <pear.neufeind@speedpartner.de>
* @package Image_Canvas
* @access public
*/
class Image_Canvas_Color extends Image_Color
{
/**
* Allocates a color in the given image.
*
* Userdefined color specifications get translated into
* an array of rgb values.
*
* @param resource GD-resource
* @param mixed any color representation supported by color2RGB()
* @return resource Image color handle
* @see color2RGB()
* @access public
* @static
*/
function allocateColor(&$img, $color)
{
$color = Image_Canvas_Color::color2RGB($color);
if (($color[3] == 255) || (!function_exists("imagecolorallocatealpha"))) {
return imagecolorallocate($img, $color[0], $color[1], $color[2]);
} else {
return imagecolorallocatealpha($img, $color[0], $color[1], $color[2], 127-round(($color[3]*127)/255));
}
}
/**
* Convert any color-representation into an array of 4 ints (RGBA).
*
* Userdefined color specifications get translated into
* an array of rgb values.
*
* @param mixed any color representation supported by Image_Canvas_Color::color2RGB()
* @return array Array of 4 ints (RGBA-representation)
* @access public
* @static
*/
function color2RGB($color)
{
if (is_array($color)) {
if (!is_numeric($color[0])) {
return null; // error
}
if (count($color) == 3) { // assume RGB-color
// 255 = alpha-value; full opaque
return array((int) $color[0],
(int) $color[1],
(int) $color[2],
255);
}
if (count($color) == 4) { // assume RGBA-color
// 255 = alpha-value; full opaque
return array((int) $color[0],
(int) $color[1],
(int) $color[2],
(int) $color[3]);
}
return null; // error
} elseif (is_string($color)) {
$alphaPos = strpos($color, '@');
if ($alphaPos === false) {
$alpha = 255;
} else {
$alphaFloat = (float) substr($color, $alphaPos+1);
// restrict to range 0..1
$alphaFloat = max(min($alphaFloat, 1), 0);
$alpha = (int) round((float) 255 * $alphaFloat);
$color = substr($color, 0, $alphaPos);
}
if ($color[0] == '#') { // hex-color given, e.g. #FFB4B4
$tempColor = parent::hex2rgb($color);
return array((int) $tempColor[0],
(int) $tempColor[1],
(int) $tempColor[2],
$alpha);
}
if (strpos($color,'%') !== false) {
$tempColor = parent::percentageColor2RGB($color);
return array((int) $tempColor[0],
(int) $tempColor[1],
(int) $tempColor[2],
$alpha);
} else {
$tempColor = parent::namedColor2RGB($color);
return array((int) $tempColor[0],
(int) $tempColor[1],
(int) $tempColor[2],
$alpha);
}
} else {
return null; // error
}
}
/**
* getRange
* Given a degree, you can get the range of colors between one color and
* another color.
*
* @access public
* @param string How much each 'step' between the colors we should take.
* @return array Returns an array of all the colors, one element for each color.
*/
function getRange ($degrees)
{
$tempColors = parent::getRange($degrees);
// now add alpha-channel information
$steps = count($tempColors);
for($counter=0;$counter<$steps;$counter++) {
$tempColors[$counter] = parent::hex2rgb($tempColors[$counter]);
unset($tempColors[$counter]['hex']);
$tempColors[$counter][3] = (int) round(
(((float) $this->color1[3]*($steps-$counter))+
((float) $this->color2[3]*($counter))
) / $steps
);
}
return $tempColors;
}
/**
* Internal method to correctly set the colors.
*
* @param mixed color 1
* @param mixed color 2
* @access private
*/
function _setColors ( $col1, $col2 )
{
$this->color1 = Image_Canvas_Color::color2RGB($col1);
$this->color2 = Image_Canvas_Color::color2RGB($col2);
}
}
?>

View File

@@ -1,12 +1,12 @@
This is where the font files are located.
Font files can be found at:
MS CoreFonts
http://corefonts.sourceforge.net/
Divide By Zero (most are cartoonish)
http://fonts.tom7.com/
MING FDB Fonts
This is where the font files are located.
Font files can be found at:
MS CoreFonts
http://corefonts.sourceforge.net/
Divide By Zero (most are cartoonish)
http://fonts.tom7.com/
MING FDB Fonts
http://ming.sf.net/

View File

@@ -1,25 +1,25 @@
Arial,arial.ttf
Arial Bold,arialbd.ttf
Arial Bold Italic,arialbi.ttf
Arial Italic,ariali.ttf
Courier New,cour.ttf
Courier New Bold,courbd.ttf
Courier New Bold Italic,courbi.ttf
Courier New Italic,couri.ttf
Garamond,gara.ttf
Garamond Bold,garabd.ttf
Garamond Italic,garait.ttf
Gothic,gothic.ttf
Gothic Bold,gothicb.ttf
Gothic Bold Italic,gothicbi.ttf
Gothic Italic,gothici.ttf
Sans Serif,micross.ttf
Reference Sans Serif,refsan.ttf
Times New Roman,times.ttf
Times New Roman Bold,timesbd.ttf
Times New Roman Bold Italic,timesbi.ttf
Times New Roman Italic,timesi.ttf
Verdana,verdana.ttf
Verdana Bold,verdanab.ttf
Verdana Bold Italic,verdanaz.ttf
Arial,arial.ttf
Arial Bold,arialbd.ttf
Arial Bold Italic,arialbi.ttf
Arial Italic,ariali.ttf
Courier New,cour.ttf
Courier New Bold,courbd.ttf
Courier New Bold Italic,courbi.ttf
Courier New Italic,couri.ttf
Garamond,gara.ttf
Garamond Bold,garabd.ttf
Garamond Italic,garait.ttf
Gothic,gothic.ttf
Gothic Bold,gothicb.ttf
Gothic Bold Italic,gothicbi.ttf
Gothic Italic,gothici.ttf
Sans Serif,micross.ttf
Reference Sans Serif,refsan.ttf
Times New Roman,times.ttf
Times New Roman Bold,timesbd.ttf
Times New Roman Bold Italic,timesbi.ttf
Times New Roman Italic,timesi.ttf
Verdana,verdana.ttf
Verdana Bold,verdanab.ttf
Verdana Bold Italic,verdanaz.ttf
Verdana Italic,verdanai.ttf

File diff suppressed because it is too large Load Diff

View File

@@ -1,119 +1,119 @@
<?php
/* vim: set expandtab tabstop=4 shiftwidth=4 softtabstop=4: */
/**
* Image_Canvas
*
* Canvas class to handle JPEG format.
*
* PHP versions 4 and 5
*
* LICENSE: This library is free software; you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation; either version 2.1 of the License, or (at your
* option) any later version. This library is distributed in the hope that it
* will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty
* of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser
* General Public License for more details. You should have received a copy of
* the GNU Lesser General Public License along with this library; if not, write
* to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
* 02111-1307 USA
*
* @category Images
* @package Image_Canvas
* @author Jesper Veggerby <pear.nosey@veggerby.dk>
* @copyright Copyright (C) 2003, 2004 Jesper Veggerby Hansen
* @license http://www.gnu.org/copyleft/lesser.html LGPL License 2.1
* @version CVS: $Id: JPG.php,v 1.2 2005/08/24 20:37:34 nosey Exp $
* @link http://pear.php.net/pepr/pepr-proposal-show.php?id=212
*/
/**
* Include file Image/Canvas/GD.php
*/
require_once 'Image/Canvas/GD.php';
/**
* JPEG Canvas class.
*
* @category Images
* @package Image_Canvas
* @author Jesper Veggerby <pear.nosey@veggerby.dk>
* @copyright Copyright (C) 2003, 2004 Jesper Veggerby Hansen
* @license http://www.gnu.org/copyleft/lesser.html LGPL License 2.1
* @version Release: @package_version@
* @link http://pear.php.net/pepr/pepr-proposal-show.php?id=212
*/
class Image_Canvas_GD_JPG extends Image_Canvas_GD
{
/**
* The JPEG quality
* @var int
* @access private
*/
var $_quality = 75;
/**
* Create the JPEG canvas
*
* Additional parameters other than those available for common {@link
* Image_Graph_Canvas_GD} class are:
*
* 'quality' The JPEG quality in as a percentage value from 0 (lowest
* quality, smallest file) to 100 (highest quality, biggest file)
*
* @param array $param Parameter array
*/
function Image_Canvas_GD_JPG($param)
{
parent::Image_Canvas_GD($param);
if (isset($param['quality'])) {
$this->_quality = max(0, min(100, $param['quality']));
}
$this->rectangle(
array(
'x0' => $this->_left,
'y0' => $this->_top,
'x1' => $this->_left + $this->_width - 1,
'y1' => $this->_top + $this->_height - 1,
'fill' => 'white',
'line' => 'transparent'
)
);
}
/**
* Output the result of the canvas
*
* @param array $param Parameter array
* @abstract
*/
function show($param = false)
{
parent::show($param);
header('Content-type: image/jpg');
header('Content-Disposition: inline; filename = \"'. basename($_SERVER['PHP_SELF'], '.php') . '.jpg\"');
ImageJPEG($this->_canvas, '', $this->_quality);
ImageDestroy($this->_canvas);
}
/**
* Output the result of the canvas
*
* @param array $param Parameter array
* @abstract
*/
function save($param = false)
{
parent::save($param);
ImageJPEG($this->_canvas, $param['filename'], $this->_quality);
ImageDestroy($this->_canvas);
}
}
<?php
/* vim: set expandtab tabstop=4 shiftwidth=4 softtabstop=4: */
/**
* Image_Canvas
*
* Canvas class to handle JPEG format.
*
* PHP versions 4 and 5
*
* LICENSE: This library is free software; you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation; either version 2.1 of the License, or (at your
* option) any later version. This library is distributed in the hope that it
* will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty
* of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser
* General Public License for more details. You should have received a copy of
* the GNU Lesser General Public License along with this library; if not, write
* to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
* 02111-1307 USA
*
* @category Images
* @package Image_Canvas
* @author Jesper Veggerby <pear.nosey@veggerby.dk>
* @copyright Copyright (C) 2003, 2004 Jesper Veggerby Hansen
* @license http://www.gnu.org/copyleft/lesser.html LGPL License 2.1
* @version CVS: $Id: JPG.php,v 1.2 2005/08/24 20:37:34 nosey Exp $
* @link http://pear.php.net/pepr/pepr-proposal-show.php?id=212
*/
/**
* Include file Image/Canvas/GD.php
*/
require_once 'Image/Canvas/GD.php';
/**
* JPEG Canvas class.
*
* @category Images
* @package Image_Canvas
* @author Jesper Veggerby <pear.nosey@veggerby.dk>
* @copyright Copyright (C) 2003, 2004 Jesper Veggerby Hansen
* @license http://www.gnu.org/copyleft/lesser.html LGPL License 2.1
* @version Release: @package_version@
* @link http://pear.php.net/pepr/pepr-proposal-show.php?id=212
*/
class Image_Canvas_GD_JPG extends Image_Canvas_GD
{
/**
* The JPEG quality
* @var int
* @access private
*/
var $_quality = 75;
/**
* Create the JPEG canvas
*
* Additional parameters other than those available for common {@link
* Image_Graph_Canvas_GD} class are:
*
* 'quality' The JPEG quality in as a percentage value from 0 (lowest
* quality, smallest file) to 100 (highest quality, biggest file)
*
* @param array $param Parameter array
*/
function Image_Canvas_GD_JPG($param)
{
parent::Image_Canvas_GD($param);
if (isset($param['quality'])) {
$this->_quality = max(0, min(100, $param['quality']));
}
$this->rectangle(
array(
'x0' => $this->_left,
'y0' => $this->_top,
'x1' => $this->_left + $this->_width - 1,
'y1' => $this->_top + $this->_height - 1,
'fill' => 'white',
'line' => 'transparent'
)
);
}
/**
* Output the result of the canvas
*
* @param array $param Parameter array
* @abstract
*/
function show($param = false)
{
parent::show($param);
header('Content-type: image/jpg');
header('Content-Disposition: inline; filename = \"'. basename($_SERVER['PHP_SELF'], '.php') . '.jpg\"');
ImageJPEG($this->_canvas, '', $this->_quality);
ImageDestroy($this->_canvas);
}
/**
* Output the result of the canvas
*
* @param array $param Parameter array
* @abstract
*/
function save($param = false)
{
parent::save($param);
ImageJPEG($this->_canvas, $param['filename'], $this->_quality);
ImageDestroy($this->_canvas);
}
}
?>

View File

@@ -1,125 +1,125 @@
<?php
/* vim: set expandtab tabstop=4 shiftwidth=4 softtabstop=4: */
/**
* Image_Canvas
*
* Canvas class to handle PNG format.
*
* PHP versions 4 and 5
*
* LICENSE: This library is free software; you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation; either version 2.1 of the License, or (at your
* option) any later version. This library is distributed in the hope that it
* will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty
* of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser
* General Public License for more details. You should have received a copy of
* the GNU Lesser General Public License along with this library; if not, write
* to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
* 02111-1307 USA
*
* @category Images
* @package Image_Canvas
* @author Jesper Veggerby <pear.nosey@veggerby.dk>
* @copyright Copyright (C) 2003, 2004 Jesper Veggerby Hansen
* @license http://www.gnu.org/copyleft/lesser.html LGPL License 2.1
* @version CVS: $Id: PNG.php,v 1.3 2005/08/24 20:37:34 nosey Exp $
* @link http://pear.php.net/pepr/pepr-proposal-show.php?id=212
*/
/**
* Include file Image/Canvas/GD.php
*/
require_once 'Image/Canvas/GD.php';
/**
* PNG Canvas class.
*
* @category Images
* @package Image_Canvas
* @author Jesper Veggerby <pear.nosey@veggerby.dk>
* @copyright Copyright (C) 2003, 2004 Jesper Veggerby Hansen
* @license http://www.gnu.org/copyleft/lesser.html LGPL License 2.1
* @version Release: @package_version@
* @link http://pear.php.net/pepr/pepr-proposal-show.php?id=212
*/
class Image_Canvas_GD_PNG extends Image_Canvas_GD
{
/**
* Create the PNG canvas
*
* @param array $param Parameter array
*/
function Image_Canvas_GD_PNG($param)
{
parent::Image_Canvas_GD($param);
if ((isset($param['transparent'])) && ($param['transparent']) &&
($this->_gd2)
) {
if ($param['transparent'] === true) {
$transparent = '#123ABD';
} else {
$transparent = $param['transparent'];
}
$color = $this->_color($transparent);
$trans = ImageColorTransparent($this->_canvas, $color);
$this->rectangle(
array(
'x0' => $this->_left,
'y0' => $this->_top,
'x1' => $this->_left + $this->_width - 1,
'y1' => $this->_top + $this->_height - 1,
'fill' => 'opague',
'line' => 'transparent'
)
);
} else {
$this->rectangle(
array(
'x0' => $this->_left,
'y0' => $this->_top,
'x1' => $this->_left + $this->_width - 1,
'y1' => $this->_top + $this->_height - 1,
'fill' => 'white',
'line' => 'transparent'
)
);
}
}
/**
* Output the result of the canvas
*
* @param array $param Parameter array
* @abstract
*/
function show($param = false)
{
parent::show($param);
header('Content-type: image/png');
header('Content-Disposition: inline; filename = \"'. basename($_SERVER['PHP_SELF'], '.php') . '.png\"');
ImagePNG($this->_canvas);
ImageDestroy($this->_canvas);
}
/**
* Output the result of the canvas
*
* @param array $param Parameter array
* @abstract
*/
function save($param = false)
{
parent::save($param);
ImagePNG($this->_canvas, $param['filename']);
ImageDestroy($this->_canvas);
}
}
<?php
/* vim: set expandtab tabstop=4 shiftwidth=4 softtabstop=4: */
/**
* Image_Canvas
*
* Canvas class to handle PNG format.
*
* PHP versions 4 and 5
*
* LICENSE: This library is free software; you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation; either version 2.1 of the License, or (at your
* option) any later version. This library is distributed in the hope that it
* will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty
* of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser
* General Public License for more details. You should have received a copy of
* the GNU Lesser General Public License along with this library; if not, write
* to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
* 02111-1307 USA
*
* @category Images
* @package Image_Canvas
* @author Jesper Veggerby <pear.nosey@veggerby.dk>
* @copyright Copyright (C) 2003, 2004 Jesper Veggerby Hansen
* @license http://www.gnu.org/copyleft/lesser.html LGPL License 2.1
* @version CVS: $Id: PNG.php,v 1.3 2005/08/24 20:37:34 nosey Exp $
* @link http://pear.php.net/pepr/pepr-proposal-show.php?id=212
*/
/**
* Include file Image/Canvas/GD.php
*/
require_once 'Image/Canvas/GD.php';
/**
* PNG Canvas class.
*
* @category Images
* @package Image_Canvas
* @author Jesper Veggerby <pear.nosey@veggerby.dk>
* @copyright Copyright (C) 2003, 2004 Jesper Veggerby Hansen
* @license http://www.gnu.org/copyleft/lesser.html LGPL License 2.1
* @version Release: @package_version@
* @link http://pear.php.net/pepr/pepr-proposal-show.php?id=212
*/
class Image_Canvas_GD_PNG extends Image_Canvas_GD
{
/**
* Create the PNG canvas
*
* @param array $param Parameter array
*/
function Image_Canvas_GD_PNG($param)
{
parent::Image_Canvas_GD($param);
if ((isset($param['transparent'])) && ($param['transparent']) &&
($this->_gd2)
) {
if ($param['transparent'] === true) {
$transparent = '#123ABD';
} else {
$transparent = $param['transparent'];
}
$color = $this->_color($transparent);
$trans = ImageColorTransparent($this->_canvas, $color);
$this->rectangle(
array(
'x0' => $this->_left,
'y0' => $this->_top,
'x1' => $this->_left + $this->_width - 1,
'y1' => $this->_top + $this->_height - 1,
'fill' => 'opague',
'line' => 'transparent'
)
);
} else {
$this->rectangle(
array(
'x0' => $this->_left,
'y0' => $this->_top,
'x1' => $this->_left + $this->_width - 1,
'y1' => $this->_top + $this->_height - 1,
'fill' => 'white',
'line' => 'transparent'
)
);
}
}
/**
* Output the result of the canvas
*
* @param array $param Parameter array
* @abstract
*/
function show($param = false)
{
parent::show($param);
header('Content-type: image/png');
header('Content-Disposition: inline; filename = \"'. basename($_SERVER['PHP_SELF'], '.php') . '.png\"');
ImagePNG($this->_canvas);
ImageDestroy($this->_canvas);
}
/**
* Output the result of the canvas
*
* @param array $param Parameter array
* @abstract
*/
function save($param = false)
{
parent::save($param);
ImagePNG($this->_canvas, $param['filename']);
ImageDestroy($this->_canvas);
}
}
?>

View File

@@ -1,354 +1,354 @@
<?php
/* vim: set expandtab tabstop=4 shiftwidth=4 softtabstop=4: */
/**
* Image_Canvas
*
* Class for handling output as a HTML imagemap
*
* PHP versions 4 and 5
*
* LICENSE: This library is free software; you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation; either version 2.1 of the License, or (at your
* option) any later version. This library is distributed in the hope that it
* will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty
* of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser
* General Public License for more details. You should have received a copy of
* the GNU Lesser General Public License along with this library; if not, write
* to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
* 02111-1307 USA
*
* @category Images
* @package Image_Canvas
* @author Jesper Veggerby <pear.nosey@veggerby.dk>
* @copyright Copyright (C) 2003, 2004 Jesper Veggerby Hansen
* @license http://www.gnu.org/copyleft/lesser.html LGPL License 2.1
* @version CVS: $Id: ImageMap.php,v 1.6 2005/08/17 17:59:11 nosey Exp $
* @link http://pear.php.net/pepr/pepr-proposal-show.php?id=212
*/
/**
* Class for handling output as a HTML imagemap
*
* @category Images
* @package Image_Canvas
* @author Jesper Veggerby <pear.nosey@veggerby.dk>
* @copyright Copyright (C) 2003, 2004 Jesper Veggerby Hansen
* @license http://www.gnu.org/copyleft/lesser.html LGPL License 2.1
* @version Release: @package_version@
* @link http://pear.php.net/pepr/pepr-proposal-show.php?id=212
* @since version 0.2.0
*/
class Image_Canvas_ImageMap extends Image_Canvas
{
/**
* The image map (if any)
* @var array
* @access private
*/
var $_map = array();
/**
* Add a map tag
* @param string $shape The shape, either rect, circle or polygon
* @param string $coords The list of coordinates for the shape
* @param array $params Parameter array
*/
function _addMapTag($shape, $coords, $params)
{
if (isset($params['url'])) {
$url = $params['url'];
$target = (isset($params['target']) ? $params['target'] : false);
$alt = (isset($params['alt']) ? $params['alt'] : false);
$tags = '';
if (isset($params['htmltags'])) {
foreach ($params['htmltags'] as $key => $value) {
$tags .= ' ';
if (strpos($value, '"') >= 0) {
$tags .= $key . '=\'' . $value . '\'';
} else {
$tags .= $key . '="' . $value . '"';
}
}
}
$this->_map[] =
'<area shape="' . $shape . '" coords="' . $coords . '" href="' . $url . '"' .
($target ? ' target="' . $target . '"' : '') .
($alt ? ' alt="' . $alt . '"' : '') .
(isset($params['id']) ? ' id="' . $params['id'] . '"' : '') .
$tags .
'>';
}
}
/**
* Draw a line
*
* Parameter array:
* 'x0': int X start point
* 'y0': int Y start point
* 'x1': int X end point
* 'y1': int Y end point
* 'color': mixed [optional] The line color
* 'mapsize': int [optional] The size of the image map (surrounding the line)
* @param array $params Parameter array
*/
function line($params)
{
if (isset($params['url'])) {
$mapsize = (isset($params['mapsize']) ? $params['mapsize'] : 2);
$this->_addMapTag(
'polygon',
$this->_getX($params['x0'] - $mapsize) . ',' .
$this->_getY($params['y0'] - $mapsize) . ',' .
$this->_getX($params['x1'] + $mapsize) . ',' .
$this->_getY($params['y1'] - $mapsize) . ',' .
$this->_getX($params['x1'] + $mapsize) . ',' .
$this->_getY($params['y1'] + $mapsize) . ',' .
$this->_getX($params['x0'] - $mapsize) . ',' .
$this->_getY($params['y0'] + $mapsize),
$params
);
}
parent::line($params);
}
/**
* Draws a polygon
*
* Parameter array:
* 'connect': bool [optional] Specifies whether the start point should be
* connected to the endpoint (closed polygon) or not (connected line)
* 'fill': mixed [optional] The fill color
* 'line': mixed [optional] The line color
* 'map_vertices': bool [optional] Specifies whether the image map should map the vertices instead of the polygon as a whole
* 'url': string [optional] URL to link the polygon as a whole to (also used for default in case 'map_vertices' is used)
* 'alt': string [optional] Alternative text to show in the image map (also used for default in case 'map_vertices' is used)
* 'target': string [optional] The link target on the image map (also used for default in case 'map_vertices' is used)
* @param array $params Parameter array
*/
function polygon($params)
{
if ((isset($params['map_vertices'])) && ($params['map_vertices'] === true)) {
$mapsize = (isset($params['mapsize']) ? $params['mapsize'] : 2);
foreach ($this->_polygon as $point) {
$vertex_param = $params;
if (isset($point['url'])) {
$vertex_param['url'] = $point['url'];
}
if (isset($point['target'])) {
$vertex_param['target'] = $point['target'];
}
if (isset($point['alt'])) {
$vertex_param['alt'] = $point['alt'];
}
$vertex_mapsize = $mapsize;
if (isset($point['mapsize'])) {
$vertex_mapsize = $point['mapsize'];
}
if (isset($point['htmltags'])) {
$vertex_param['htmltags'] = $point['htmltags'];
}
$this->_addMapTag(
'circle',
$this->_getX($point['X']) . ',' .
$this->_getY($point['Y']) . ',' .
$mapsize,
$vertex_param
);
}
}
else if (isset($params['url'])) {
$points = '';
foreach ($this->_polygon as $point) {
if ($points != '') {
$points .= ',';
}
$points .= $this->_getX($point['X']) . ',' . $this->_getY($point['Y']);
}
$this->_addMapTag('polygon', $points, $params);
}
parent::polygon($params);
}
/**
* Draw a rectangle
*
* Parameter array:
* 'x0': int X start point
* 'y0': int Y start point
* 'x1': int X end point
* 'y1': int Y end point
* 'fill': mixed [optional] The fill color
* 'line': mixed [optional] The line color
* @param array $params Parameter array
*/
function rectangle($params)
{
if (isset($params['url'])) {
$this->_addMapTag(
'rect',
$this->_getX($params['x0']) . ',' .
$this->_getY($params['y0']) . ',' .
$this->_getX($params['x1']) . ',' .
$this->_getY($params['y1']),
$params
);
}
parent::rectangle($params);
}
/**
* Draw an ellipse
*
* Parameter array:
* 'x': int X center point
* 'y': int Y center point
* 'rx': int X radius
* 'ry': int Y radius
* 'fill': mixed [optional] The fill color
* 'line': mixed [optional] The line color
* @param array $params Parameter array
*/
function ellipse($params)
{
if (isset($params['url'])) {
if ($params['rx'] == $params['ry']) {
$this->_addMapTag(
'circle',
$this->_getX($params['x']) . ',' .
$this->_getY($params['y']) . ',' .
$this->_getX($params['rx']),
$params
);
} else {
$points = '';
for ($v = 0; $v <= 360; $v += 30) {
if ($points != '') {
$points .= ',';
}
$points .=
round($this->_getX($params['x']) + $this->_getX($params['rx']) * cos(deg2rad($v % 360))) . ',' .
round($this->_getY($params['y']) + $this->_getX($params['ry']) * sin(deg2rad($v % 360)));
}
$this->_addMapTag(
'polygon',
$points,
$params
);
}
}
parent::ellipse($params);
}
/**
* Draw a pie slice
*
* Parameter array:
* 'x': int X center point
* 'y': int Y center point
* 'rx': int X radius
* 'ry': int Y radius
* 'v1': int The starting angle (in degrees)
* 'v2': int The end angle (in degrees)
* 'srx': int [optional] Starting X-radius of the pie slice (i.e. for a doughnut)
* 'sry': int [optional] Starting Y-radius of the pie slice (i.e. for a doughnut)
* 'fill': mixed [optional] The fill color
* 'line': mixed [optional] The line color
* @param array $params Parameter array
*/
function pieslice($params)
{
if (isset($params['url'])) {
$x = $this->_getX($params['x']);
$y = $this->_getY($params['y']);
$rx = $params['rx'];
$ry = $params['ry'];
$v1a = $params['v1'];
$v2a = $params['v2'];
$v1 = min($v1a, $v2a);
$v2 = max($v1a, $v2a);
$srx = (isset($params['srx']) ? $params['srx'] : 0);
$sry = (isset($params['sry']) ? $params['sry'] : 0);
$points =
round(($x + $srx * cos(deg2rad($v1 % 360)))) . ',' .
round(($y + $sry * sin(deg2rad($v1 % 360)))) . ',';
for ($v = $v1; $v < $v2; $v += 30) {
$points .=
round(($x + $rx * cos(deg2rad($v % 360)))) . ',' .
round(($y + $ry * sin(deg2rad($v % 360)))) . ',';
}
$points .=
round(($x + $rx * cos(deg2rad($v2 % 360)))) . ',' .
round(($y + $ry * sin(deg2rad($v2 % 360))));
if (($srx != 0) || ($sry != 0)) {
$points .= ',';
for ($v = $v2; $v > $v1; $v -= 30) {
$points .=
round(($x + $srx * cos(deg2rad($v % 360)))) . ',' .
round(($y + $sry * sin(deg2rad($v % 360)))) . ',';
}
}
$this->_addMapTag('polygon', $points, $params);
}
parent::pieslice($params);
}
/**
* Output the result of the canvas to the browser
*
* @param array $params Parameter array, the contents and meaning depends on the actual Canvas
* @abstract
*/
function show($params = false)
{
parent::show($params);
if (count($this->_map) > 0) {
print $this->toHtml($params);
}
}
/**
* Save the result of the canvas to a file
*
* Parameter array:
* 'filename': string The file to output to
* @param array $params Parameter array, the contents and meaning depends on the actual Canvas
* @abstract
*/
function save($params = false)
{
parent::save($params);
$file = fopen($param['filename'], 'w+');
fwrite($file, $this->toHtml($params));
fclose($file);
}
/**
* Get a canvas specific HTML tag.
*
* Parameter array:
* 'name': string The name of the image map
*/
function toHtml($params)
{
if (count($this->_map) > 0) {
return '<map name="' . $params['name'] . '">' . "\n\t" . implode($this->_map, "\n\t") . "\n</map>";
}
return '';
}
}
<?php
/* vim: set expandtab tabstop=4 shiftwidth=4 softtabstop=4: */
/**
* Image_Canvas
*
* Class for handling output as a HTML imagemap
*
* PHP versions 4 and 5
*
* LICENSE: This library is free software; you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation; either version 2.1 of the License, or (at your
* option) any later version. This library is distributed in the hope that it
* will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty
* of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser
* General Public License for more details. You should have received a copy of
* the GNU Lesser General Public License along with this library; if not, write
* to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
* 02111-1307 USA
*
* @category Images
* @package Image_Canvas
* @author Jesper Veggerby <pear.nosey@veggerby.dk>
* @copyright Copyright (C) 2003, 2004 Jesper Veggerby Hansen
* @license http://www.gnu.org/copyleft/lesser.html LGPL License 2.1
* @version CVS: $Id: ImageMap.php,v 1.8 2006/10/24 18:58:16 nosey Exp $
* @link http://pear.php.net/pepr/pepr-proposal-show.php?id=212
*/
/**
* Class for handling output as a HTML imagemap
*
* @category Images
* @package Image_Canvas
* @author Jesper Veggerby <pear.nosey@veggerby.dk>
* @copyright Copyright (C) 2003, 2004 Jesper Veggerby Hansen
* @license http://www.gnu.org/copyleft/lesser.html LGPL License 2.1
* @version Release: @package_version@
* @link http://pear.php.net/pepr/pepr-proposal-show.php?id=212
* @since version 0.2.0
*/
class Image_Canvas_ImageMap extends Image_Canvas
{
/**
* The image map (if any)
* @var array
* @access private
*/
var $_map = array();
/**
* Add a map tag
* @param string $shape The shape, either rect, circle or polygon
* @param string $coords The list of coordinates for the shape
* @param array $params Parameter array
*/
function _addMapTag($shape, $coords, $params)
{
if (isset($params['url'])) {
$url = $params['url'];
$target = (isset($params['target']) ? $params['target'] : false);
$alt = (isset($params['alt']) ? $params['alt'] : false);
$tags = '';
if (isset($params['htmltags'])) {
foreach ($params['htmltags'] as $key => $value) {
$tags .= ' ';
if (strpos($value, '"') !== false) {
$tags .= $key . '=\'' . $value . '\'';
} else {
$tags .= $key . '="' . $value . '"';
}
}
}
$this->_map[] =
'<area shape="' . $shape . '" coords="' . $coords . '" href="' . $url . '"' .
($target ? ' target="' . $target . '"' : '') .
($alt ? ' alt="' . $alt . '"' : '') .
(isset($params['id']) ? ' id="' . $params['id'] . '"' : '') .
$tags .
'>';
}
}
/**
* Draw a line
*
* Parameter array:
* 'x0': int X start point
* 'y0': int Y start point
* 'x1': int X end point
* 'y1': int Y end point
* 'color': mixed [optional] The line color
* 'mapsize': int [optional] The size of the image map (surrounding the line)
* @param array $params Parameter array
*/
function line($params)
{
if (isset($params['url'])) {
$mapsize = (isset($params['mapsize']) ? $params['mapsize'] : 2);
$this->_addMapTag(
'polygon',
$this->_getX($params['x0'] - $mapsize) . ',' .
$this->_getY($params['y0'] - $mapsize) . ',' .
$this->_getX($params['x1'] + $mapsize) . ',' .
$this->_getY($params['y1'] - $mapsize) . ',' .
$this->_getX($params['x1'] + $mapsize) . ',' .
$this->_getY($params['y1'] + $mapsize) . ',' .
$this->_getX($params['x0'] - $mapsize) . ',' .
$this->_getY($params['y0'] + $mapsize),
$params
);
}
parent::line($params);
}
/**
* Draws a polygon
*
* Parameter array:
* 'connect': bool [optional] Specifies whether the start point should be
* connected to the endpoint (closed polygon) or not (connected line)
* 'fill': mixed [optional] The fill color
* 'line': mixed [optional] The line color
* 'map_vertices': bool [optional] Specifies whether the image map should map the vertices instead of the polygon as a whole
* 'url': string [optional] URL to link the polygon as a whole to (also used for default in case 'map_vertices' is used)
* 'alt': string [optional] Alternative text to show in the image map (also used for default in case 'map_vertices' is used)
* 'target': string [optional] The link target on the image map (also used for default in case 'map_vertices' is used)
* @param array $params Parameter array
*/
function polygon($params)
{
if ((isset($params['map_vertices'])) && ($params['map_vertices'] === true)) {
$mapsize = (isset($params['mapsize']) ? $params['mapsize'] : 2);
foreach ($this->_polygon as $point) {
$vertex_param = $params;
if (isset($point['url'])) {
$vertex_param['url'] = $point['url'];
}
if (isset($point['target'])) {
$vertex_param['target'] = $point['target'];
}
if (isset($point['alt'])) {
$vertex_param['alt'] = $point['alt'];
}
$vertex_mapsize = $mapsize;
if (isset($point['mapsize'])) {
$vertex_mapsize = $point['mapsize'];
}
if (isset($point['htmltags'])) {
$vertex_param['htmltags'] = $point['htmltags'];
}
$this->_addMapTag(
'circle',
$this->_getX($point['X']) . ',' .
$this->_getY($point['Y']) . ',' .
$mapsize,
$vertex_param
);
}
}
else if (isset($params['url'])) {
$points = '';
foreach ($this->_polygon as $point) {
if ($points != '') {
$points .= ',';
}
$points .= $this->_getX($point['X']) . ',' . $this->_getY($point['Y']);
}
$this->_addMapTag('polygon', $points, $params);
}
parent::polygon($params);
}
/**
* Draw a rectangle
*
* Parameter array:
* 'x0': int X start point
* 'y0': int Y start point
* 'x1': int X end point
* 'y1': int Y end point
* 'fill': mixed [optional] The fill color
* 'line': mixed [optional] The line color
* @param array $params Parameter array
*/
function rectangle($params)
{
if (isset($params['url'])) {
$this->_addMapTag(
'rect',
$this->_getX($params['x0']) . ',' .
$this->_getY($params['y0']) . ',' .
$this->_getX($params['x1']) . ',' .
$this->_getY($params['y1']),
$params
);
}
parent::rectangle($params);
}
/**
* Draw an ellipse
*
* Parameter array:
* 'x': int X center point
* 'y': int Y center point
* 'rx': int X radius
* 'ry': int Y radius
* 'fill': mixed [optional] The fill color
* 'line': mixed [optional] The line color
* @param array $params Parameter array
*/
function ellipse($params)
{
if (isset($params['url'])) {
if ($params['rx'] == $params['ry']) {
$this->_addMapTag(
'circle',
$this->_getX($params['x']) . ',' .
$this->_getY($params['y']) . ',' .
$this->_getX($params['rx']),
$params
);
} else {
$points = '';
for ($v = 0; $v <= 360; $v += 30) {
if ($points != '') {
$points .= ',';
}
$points .=
round($this->_getX($params['x']) + $this->_getX($params['rx']) * cos(deg2rad($v % 360))) . ',' .
round($this->_getY($params['y']) + $this->_getX($params['ry']) * sin(deg2rad($v % 360)));
}
$this->_addMapTag(
'polygon',
$points,
$params
);
}
}
parent::ellipse($params);
}
/**
* Draw a pie slice
*
* Parameter array:
* 'x': int X center point
* 'y': int Y center point
* 'rx': int X radius
* 'ry': int Y radius
* 'v1': int The starting angle (in degrees)
* 'v2': int The end angle (in degrees)
* 'srx': int [optional] Starting X-radius of the pie slice (i.e. for a doughnut)
* 'sry': int [optional] Starting Y-radius of the pie slice (i.e. for a doughnut)
* 'fill': mixed [optional] The fill color
* 'line': mixed [optional] The line color
* @param array $params Parameter array
*/
function pieslice($params)
{
if (isset($params['url'])) {
$x = $this->_getX($params['x']);
$y = $this->_getY($params['y']);
$rx = $params['rx'];
$ry = $params['ry'];
$v1a = $params['v1'];
$v2a = $params['v2'];
$v1 = min($v1a, $v2a);
$v2 = max($v1a, $v2a);
$srx = (isset($params['srx']) ? $params['srx'] : 0);
$sry = (isset($params['sry']) ? $params['sry'] : 0);
$points =
round(($x + $srx * cos(deg2rad($v1 % 360)))) . ',' .
round(($y + $sry * sin(deg2rad($v1 % 360)))) . ',';
for ($v = $v1; $v < $v2; $v += 30) {
$points .=
round(($x + $rx * cos(deg2rad($v % 360)))) . ',' .
round(($y + $ry * sin(deg2rad($v % 360)))) . ',';
}
$points .=
round(($x + $rx * cos(deg2rad($v2 % 360)))) . ',' .
round(($y + $ry * sin(deg2rad($v2 % 360))));
if (($srx != 0) || ($sry != 0)) {
$points .= ',';
for ($v = $v2; $v > $v1; $v -= 30) {
$points .=
round(($x + $srx * cos(deg2rad($v % 360)))) . ',' .
round(($y + $sry * sin(deg2rad($v % 360)))) . ',';
}
}
$this->_addMapTag('polygon', $points, $params);
}
parent::pieslice($params);
}
/**
* Output the result of the canvas to the browser
*
* @param array $params Parameter array, the contents and meaning depends on the actual Canvas
* @abstract
*/
function show($params = false)
{
parent::show($params);
if (count($this->_map) > 0) {
print $this->toHtml($params);
}
}
/**
* Save the result of the canvas to a file
*
* Parameter array:
* 'filename': string The file to output to
* @param array $params Parameter array, the contents and meaning depends on the actual Canvas
* @abstract
*/
function save($params = false)
{
parent::save($params);
$file = fopen($params['filename'], 'w+');
fwrite($file, $this->toHtml($params));
fclose($file);
}
/**
* Get a canvas specific HTML tag.
*
* Parameter array:
* 'name': string The name of the image map
*/
function toHtml($params)
{
if (count($this->_map) > 0) {
return '<map name="' . $params['name'] . '">' . "\n\t" . implode($this->_map, "\n\t") . "\n</map>";
}
return '';
}
}
?>

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

View File

@@ -1,217 +1,217 @@
<?php
/* vim: set expandtab tabstop=4 shiftwidth=4 softtabstop=4: */
/**
* Image_Canvas
*
* Canvas based creation of images to facilitate different output formats
*
* PHP versions 4 and 5
*
* LICENSE: This library is free software; you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation; either version 2.1 of the License, or (at your
* option) any later version. This library is distributed in the hope that it
* will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty
* of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser
* General Public License for more details. You should have received a copy of
* the GNU Lesser General Public License along with this library; if not, write
* to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
* 02111-1307 USA
*
* @category Images
* @package Image_Canvas
* @author Jesper Veggerby <pear.nosey@veggerby.dk>
* @copyright Copyright (C) 2003, 2004 Jesper Veggerby Hansen
* @license http://www.gnu.org/copyleft/lesser.html LGPL License 2.1
* @version CVS: $Id: Tool.php,v 1.3 2005/08/22 20:52:11 nosey Exp $
* @link http://pear.php.net/pepr/pepr-proposal-show.php?id=212
*/
/**
* This class contains a set of tool-functions.
*
* These functions are all to be called statically
*
* @category Images
* @package Image_Canvas
* @author Jesper Veggerby <pear.nosey@veggerby.dk>
* @copyright Copyright (C) 2003, 2004 Jesper Veggerby Hansen
* @license http://www.gnu.org/copyleft/lesser.html LGPL License 2.1
* @version Release: @package_version@
* @link http://pear.php.net/pepr/pepr-proposal-show.php?id=212
* @abstract
*/
class Image_Canvas_Tool
{
/**
* Maps a font name to an actual font file (fx. a .ttf file)
*
* Used to translate names (i.e. 'Courier New' to 'cour.ttf' or
* '/Windows/Fonts/Cour.ttf')
*
* Font names are translated using the tab-separated file
* Image/Canvas/Tool/fontmap.txt.
*
* The translated font-name (or the original if no translation) exists is
* then returned if it is an existing file, otherwise the file is searched
* first in the path specified by IMAGE_CANVAS_SYSTEM_FONT_PATH defined in
* Image/Canvas.php, then in the Image/Canvas/Fonts folder. If a font is
* still not found and the name is not beginning with a '/' the search is
* left to the library, otherwise the font is deemed non-existing.
*
* @param string $name The name of the font
* @param string $type The needed file type of the font
* @return string The filename of the font
* @static
*/
function fontMap($name, $type = '.ttf')
{
static $_fontMap;
if (!is_array($_fontMap)) {
if (file_exists($fontmap = (dirname(__FILE__) . '/Fonts/fontmap.txt'))) {
$file = file($fontmap);
foreach($file as $fontmapping) {
list($fontname, $filenames) = explode(',', $fontmapping, 2);
$fontname = trim($fontname);
$filenames = trim($filenames);
$filenames = explode(',', $filenames);
foreach ($filenames as $filename) {
$type_pos = strrpos($filename, '.');
$type = substr($filename, $type_pos);
$_fontMap[$fontname][$type] = $filename;
}
}
}
}
$type = strtolower($type);
if ((isset($_fontMap[$name])) && (isset($_fontMap[$name][$type]))) {
$filename = $_fontMap[$name][$type];
} else {
$filename = $name;
}
if (substr($filename, -strlen($type)) !== $type) {
$filename .= $type;
}
$result = false;
if (file_exists($filename)) {
$result = $filename;
} elseif (file_exists($file = (IMAGE_CANVAS_SYSTEM_FONT_PATH . $filename))) {
$result = $file;
} elseif (file_exists($file = (dirname(__FILE__) . '/Fonts/' . $filename))) {
$result = $file;
} elseif (substr($name, 0, 1) !== '/') {
// leave it to the library to find the font
$result = $name;
}
return str_replace('\\', '/', $result);
}
/**
* Return the average of 2 points
*
* @param double P1 1st point
* @param double P2 2nd point
* @return double The average of P1 and P2
* @static
*/
function mid($p1, $p2)
{
return ($p1 + $p2) / 2;
}
/**
* Mirrors P1 in P2 by a amount of Factor
*
* @param double $p1 1st point, point to mirror
* @param double $o2 2nd point, mirror point
* @param double $factor Mirror factor, 0 returns $p2, 1 returns a pure
* mirror, ie $p1 on the exact other side of $p2
* @return double $p1 mirrored in $p2 by Factor
* @static
*/
function mirror($p1, $p2, $factor = 1)
{
return $p2 + $factor * ($p2 - $p1);
}
/**
* Calculates a Bezier control point, this function must be called for BOTH
* X and Y coordinates (will it work for 3D coordinates!?)
*
* @param double $p1 1st point
* @param double $p2 Point to
* @param double $factor Mirror factor, 0 returns P2, 1 returns a pure
* mirror, i.e. P1 on the exact other side of P2
* @return double P1 mirrored in P2 by Factor
* @static
*/
function controlPoint($p1, $p2, $factor, $smoothFactor = 0.75)
{
$sa = Image_Canvas_Tool::mirror($p1, $p2, $smoothFactor);
$sb = Image_Canvas_Tool::mid($p2, $sa);
$m = Image_Canvas_Tool::mid($p2, $factor);
$pC = Image_Canvas_Tool::mid($sb, $m);
return $pC;
}
/**
* Calculates a Bezier point, this function must be called for BOTH X and Y
* coordinates (will it work for 3D coordinates!?)
*
* @param double $t A position between $p2 and $p3, value between 0 and 1
* @param double $p1 Point to use for calculating control points
* @param double $p2 Point 1 to calculate bezier curve between
* @param double $p3 Point 2 to calculate bezier curve between
* @param double $p4 Point to use for calculating control points
* @return double The bezier value of the point t between $p2 and $p3 using
* $p1 and $p4 to calculate control points
* @static
*/
function bezier($t, $p1, $p2, $p3, $p4)
{
// (1-t)^3*p1 + 3*(1-t)^2*t*p2 + 3*(1-t)*t^2*p3 + t^3*p4
return pow(1 - $t, 3) * $p1 +
3 * pow(1 - $t, 2) * $t * $p2 +
3 * (1 - $t) * pow($t, 2) * $p3 +
pow($t, 3) * $p4;
}
/**
* Gets the angle / slope of a line relative to horizontal (left -> right)
*
* @param double $x0 The starting x point
* @param double $y0 The starting y point
* @param double $x1 The ending x point
* @param double $y1 The ending y point
* @param double The angle in degrees of the line
* @static
*/
function getAngle($x0, $y0, $x1, $y1)
{
$dx = ($x1 - $x0);
$dy = ($y1 - $y0);
$l = sqrt($dx * $dx + $dy * $dy);
$v = rad2deg(asin(($y0 - $y1) / $l));
if ($dx < 0) {
$v = 180 - $v;
}
return $v;
}
}
<?php
/* vim: set expandtab tabstop=4 shiftwidth=4 softtabstop=4: */
/**
* Image_Canvas
*
* Canvas based creation of images to facilitate different output formats
*
* PHP versions 4 and 5
*
* LICENSE: This library is free software; you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation; either version 2.1 of the License, or (at your
* option) any later version. This library is distributed in the hope that it
* will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty
* of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser
* General Public License for more details. You should have received a copy of
* the GNU Lesser General Public License along with this library; if not, write
* to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
* 02111-1307 USA
*
* @category Images
* @package Image_Canvas
* @author Jesper Veggerby <pear.nosey@veggerby.dk>
* @copyright Copyright (C) 2003, 2004 Jesper Veggerby Hansen
* @license http://www.gnu.org/copyleft/lesser.html LGPL License 2.1
* @version CVS: $Id: Tool.php,v 1.3 2005/08/22 20:52:11 nosey Exp $
* @link http://pear.php.net/pepr/pepr-proposal-show.php?id=212
*/
/**
* This class contains a set of tool-functions.
*
* These functions are all to be called statically
*
* @category Images
* @package Image_Canvas
* @author Jesper Veggerby <pear.nosey@veggerby.dk>
* @copyright Copyright (C) 2003, 2004 Jesper Veggerby Hansen
* @license http://www.gnu.org/copyleft/lesser.html LGPL License 2.1
* @version Release: @package_version@
* @link http://pear.php.net/pepr/pepr-proposal-show.php?id=212
* @abstract
*/
class Image_Canvas_Tool
{
/**
* Maps a font name to an actual font file (fx. a .ttf file)
*
* Used to translate names (i.e. 'Courier New' to 'cour.ttf' or
* '/Windows/Fonts/Cour.ttf')
*
* Font names are translated using the tab-separated file
* Image/Canvas/Tool/fontmap.txt.
*
* The translated font-name (or the original if no translation) exists is
* then returned if it is an existing file, otherwise the file is searched
* first in the path specified by IMAGE_CANVAS_SYSTEM_FONT_PATH defined in
* Image/Canvas.php, then in the Image/Canvas/Fonts folder. If a font is
* still not found and the name is not beginning with a '/' the search is
* left to the library, otherwise the font is deemed non-existing.
*
* @param string $name The name of the font
* @param string $type The needed file type of the font
* @return string The filename of the font
* @static
*/
function fontMap($name, $type = '.ttf')
{
static $_fontMap;
if (!is_array($_fontMap)) {
if (file_exists($fontmap = (dirname(__FILE__) . '/Fonts/fontmap.txt'))) {
$file = file($fontmap);
foreach($file as $fontmapping) {
list($fontname, $filenames) = explode(',', $fontmapping, 2);
$fontname = trim($fontname);
$filenames = trim($filenames);
$filenames = explode(',', $filenames);
foreach ($filenames as $filename) {
$type_pos = strrpos($filename, '.');
$type = substr($filename, $type_pos);
$_fontMap[$fontname][$type] = $filename;
}
}
}
}
$type = strtolower($type);
if ((isset($_fontMap[$name])) && (isset($_fontMap[$name][$type]))) {
$filename = $_fontMap[$name][$type];
} else {
$filename = $name;
}
if (substr($filename, -strlen($type)) !== $type) {
$filename .= $type;
}
$result = false;
if (file_exists($filename)) {
$result = $filename;
} elseif (file_exists($file = (IMAGE_CANVAS_SYSTEM_FONT_PATH . $filename))) {
$result = $file;
} elseif (file_exists($file = (dirname(__FILE__) . '/Fonts/' . $filename))) {
$result = $file;
} elseif (substr($name, 0, 1) !== '/') {
// leave it to the library to find the font
$result = $name;
}
return str_replace('\\', '/', $result);
}
/**
* Return the average of 2 points
*
* @param double P1 1st point
* @param double P2 2nd point
* @return double The average of P1 and P2
* @static
*/
function mid($p1, $p2)
{
return ($p1 + $p2) / 2;
}
/**
* Mirrors P1 in P2 by a amount of Factor
*
* @param double $p1 1st point, point to mirror
* @param double $o2 2nd point, mirror point
* @param double $factor Mirror factor, 0 returns $p2, 1 returns a pure
* mirror, ie $p1 on the exact other side of $p2
* @return double $p1 mirrored in $p2 by Factor
* @static
*/
function mirror($p1, $p2, $factor = 1)
{
return $p2 + $factor * ($p2 - $p1);
}
/**
* Calculates a Bezier control point, this function must be called for BOTH
* X and Y coordinates (will it work for 3D coordinates!?)
*
* @param double $p1 1st point
* @param double $p2 Point to
* @param double $factor Mirror factor, 0 returns P2, 1 returns a pure
* mirror, i.e. P1 on the exact other side of P2
* @return double P1 mirrored in P2 by Factor
* @static
*/
function controlPoint($p1, $p2, $factor, $smoothFactor = 0.75)
{
$sa = Image_Canvas_Tool::mirror($p1, $p2, $smoothFactor);
$sb = Image_Canvas_Tool::mid($p2, $sa);
$m = Image_Canvas_Tool::mid($p2, $factor);
$pC = Image_Canvas_Tool::mid($sb, $m);
return $pC;
}
/**
* Calculates a Bezier point, this function must be called for BOTH X and Y
* coordinates (will it work for 3D coordinates!?)
*
* @param double $t A position between $p2 and $p3, value between 0 and 1
* @param double $p1 Point to use for calculating control points
* @param double $p2 Point 1 to calculate bezier curve between
* @param double $p3 Point 2 to calculate bezier curve between
* @param double $p4 Point to use for calculating control points
* @return double The bezier value of the point t between $p2 and $p3 using
* $p1 and $p4 to calculate control points
* @static
*/
function bezier($t, $p1, $p2, $p3, $p4)
{
// (1-t)^3*p1 + 3*(1-t)^2*t*p2 + 3*(1-t)*t^2*p3 + t^3*p4
return pow(1 - $t, 3) * $p1 +
3 * pow(1 - $t, 2) * $t * $p2 +
3 * (1 - $t) * pow($t, 2) * $p3 +
pow($t, 3) * $p4;
}
/**
* Gets the angle / slope of a line relative to horizontal (left -> right)
*
* @param double $x0 The starting x point
* @param double $y0 The starting y point
* @param double $x1 The ending x point
* @param double $y1 The ending y point
* @param double The angle in degrees of the line
* @static
*/
function getAngle($x0, $y0, $x1, $y1)
{
$dx = ($x1 - $x0);
$dy = ($y1 - $y0);
$l = sqrt($dx * $dx + $dy * $dy);
$v = rad2deg(asin(($y0 - $y1) / $l));
if ($dx < 0) {
$v = 180 - $v;
}
return $v;
}
}
?>

View File

@@ -1,278 +1,278 @@
<?php
/* vim: set expandtab tabstop=4 shiftwidth=4 softtabstop=4: */
/**
* Image_Canvas
*
* Canvas based creation of images to facilitate different output formats
*
* PHP versions 4 and 5
*
* LICENSE: This library is free software; you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation; either version 2.1 of the License, or (at your
* option) any later version. This library is distributed in the hope that it
* will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty
* of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser
* General Public License for more details. You should have received a copy of
* the GNU Lesser General Public License along with this library; if not, write
* to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
* 02111-1307 USA
*
* @category Images
* @package Image_Canvas
* @author Jesper Veggerby <pear.nosey@veggerby.dk>
* @copyright Copyright (C) 2003, 2004 Jesper Veggerby Hansen
* @license http://www.gnu.org/copyleft/lesser.html LGPL License 2.1
* @version CVS: $Id: WithMap.php,v 1.3 2005/08/24 20:37:35 nosey Exp $
* @link http://pear.php.net/pepr/pepr-proposal-show.php?id=212
*/
/**
* Class for handling different output formats including a HTML image map
*
* @category Images
* @package Image_Canvas
* @author Jesper Veggerby <pear.nosey@veggerby.dk>
* @copyright Copyright (C) 2003, 2004 Jesper Veggerby Hansen
* @license http://www.gnu.org/copyleft/lesser.html LGPL License 2.1
* @version Release: @package_version@
* @link http://pear.php.net/pepr/pepr-proposal-show.php?id=212
* @since version 0.2.0
* @abstract
*/
class Image_Canvas_WithMap extends Image_Canvas
{
/**
* The image map
* @var Image_Canvas_ImageMap
* @access private
*/
var $_imageMap = null;
/**
* Create the canvas.
*
* Parameters available:
*
* 'width' The width of the graph on the canvas
*
* 'height' The height of the graph on the canvas
*
* 'left' The left offset of the graph on the canvas
*
* 'top' The top offset of the graph on the canvas
*
* 'usemap' Initialize an image map
*
* @param array $params Parameter array
* @abstract
*/
function Image_Canvas_WithMap($params)
{
parent::Image_Canvas($params);
if ((isset($params['usemap'])) && ($params['usemap'] === true)) {
$this->_imageMap =& Image_Canvas::factory(
'ImageMap',
array(
'left' => $this->_left,
'top' => $this->_top,
'width' => $this->_width,
'height' => $this->_height
)
);
}
}
/**
* Draw a line
*
* Parameter array:
* 'x0': int X start point
* 'y0': int Y start point
* 'x1': int X end point
* 'y1': int Y end point
* 'color': mixed [optional] The line color
* @param array $params Parameter array
*/
function line($params)
{
if (isset($this->_imageMap)) {
$this->_imageMap->line($params);
}
parent::line($params);
}
/**
* Adds vertex to a polygon
*
* Parameter array:
* 'x': int X point
* 'y': int Y point
* @param array $params Parameter array
*/
function addVertex($params)
{
if (isset($this->_imageMap)) {
$this->_imageMap->addVertex($params);
}
parent::addVertex($params);
}
/**
* Adds "splined" vertex to a polygon
*
* Parameter array:
* 'x': int X point
* 'y': int Y point
* 'p1x': X Control point 1
* 'p1y': Y Control point 1
* 'p2x': X Control point 2
* 'p2y': Y Control point 2
* @param array $params Parameter array
*/
function addSpline($params)
{
if (isset($this->_imageMap)) {
$this->_imageMap->addSpline($params);
}
parent::addSpline($params);
}
/**
* Draws a polygon
*
* Parameter array:
* 'connect': bool [optional] Specifies whether the start point should be
* connected to the endpoint (closed polygon) or not (connected line)
* 'fill': mixed [optional] The fill color
* 'line': mixed [optional] The line color
* @param array $params Parameter array
*/
function polygon($params)
{
if (isset($this->_imageMap)) {
$this->_imageMap->polygon($params);
}
parent::polygon($params);
}
/**
* Draw a rectangle
*
* Parameter array:
* 'x0': int X start point
* 'y0': int Y start point
* 'x1': int X end point
* 'y1': int Y end point
* 'fill': mixed [optional] The fill color
* 'line': mixed [optional] The line color
* @param array $params Parameter array
*/
function rectangle($params)
{
if (isset($this->_imageMap)) {
$this->_imageMap->rectangle($params);
}
parent::rectangle($params);
}
/**
* Draw an ellipse
*
* Parameter array:
* 'x': int X center point
* 'y': int Y center point
* 'rx': int X radius
* 'ry': int Y radius
* 'fill': mixed [optional] The fill color
* 'line': mixed [optional] The line color
* @param array $params Parameter array
*/
function ellipse($params)
{
if (isset($this->_imageMap)) {
$this->_imageMap->ellipse($params);
}
parent::ellipse($params);
}
/**
* Draw a pie slice
*
* Parameter array:
* 'x': int X center point
* 'y': int Y center point
* 'rx': int X radius
* 'ry': int Y radius
* 'v1': int The starting angle (in degrees)
* 'v2': int The end angle (in degrees)
* 'srx': int [optional] Starting X-radius of the pie slice (i.e. for a doughnut)
* 'sry': int [optional] Starting Y-radius of the pie slice (i.e. for a doughnut)
* 'fill': mixed [optional] The fill color
* 'line': mixed [optional] The line color
* @param array $params Parameter array
*/
function pieslice($params)
{
if (isset($this->_imageMap)) {
$this->_imageMap->pieslice($params);
}
parent::pieslice($params);
}
/**
* Writes text
*
* Parameter array:
* 'x': int X-point of text
* 'y': int Y-point of text
* 'text': string The text to add
* 'alignment': array [optional] Alignment
* 'color': mixed [optional] The color of the text
*/
function addText($params)
{
if (isset($this->_imageMap)) {
$this->_imageMap->addText($params);
}
parent::addText($params);
}
/**
* Overlay image
*
* Parameter array:
* 'x': int X-point of overlayed image
* 'y': int Y-point of overlayed image
* 'filename': string The filename of the image to overlay
* 'width': int [optional] The width of the overlayed image (resizing if possible)
* 'height': int [optional] The height of the overlayed image (resizing if possible)
* 'alignment': array [optional] Alignment
*/
function image($params)
{
if (isset($this->_imageMap)) {
$this->_imageMap->image($params);
}
parent::image($params);
}
/**
* Get the imagemap
* @return Image_Graph_ImageMap The image map (or false if none)
*/
function &getImageMap()
{
$result = null;
if (isset($this->_imageMap)) {
$result =& $this->_imageMap;
}
return $result;
}
}
<?php
/* vim: set expandtab tabstop=4 shiftwidth=4 softtabstop=4: */
/**
* Image_Canvas
*
* Canvas based creation of images to facilitate different output formats
*
* PHP versions 4 and 5
*
* LICENSE: This library is free software; you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation; either version 2.1 of the License, or (at your
* option) any later version. This library is distributed in the hope that it
* will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty
* of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser
* General Public License for more details. You should have received a copy of
* the GNU Lesser General Public License along with this library; if not, write
* to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
* 02111-1307 USA
*
* @category Images
* @package Image_Canvas
* @author Jesper Veggerby <pear.nosey@veggerby.dk>
* @copyright Copyright (C) 2003, 2004 Jesper Veggerby Hansen
* @license http://www.gnu.org/copyleft/lesser.html LGPL License 2.1
* @version CVS: $Id: WithMap.php,v 1.3 2005/08/24 20:37:35 nosey Exp $
* @link http://pear.php.net/pepr/pepr-proposal-show.php?id=212
*/
/**
* Class for handling different output formats including a HTML image map
*
* @category Images
* @package Image_Canvas
* @author Jesper Veggerby <pear.nosey@veggerby.dk>
* @copyright Copyright (C) 2003, 2004 Jesper Veggerby Hansen
* @license http://www.gnu.org/copyleft/lesser.html LGPL License 2.1
* @version Release: @package_version@
* @link http://pear.php.net/pepr/pepr-proposal-show.php?id=212
* @since version 0.2.0
* @abstract
*/
class Image_Canvas_WithMap extends Image_Canvas
{
/**
* The image map
* @var Image_Canvas_ImageMap
* @access private
*/
var $_imageMap = null;
/**
* Create the canvas.
*
* Parameters available:
*
* 'width' The width of the graph on the canvas
*
* 'height' The height of the graph on the canvas
*
* 'left' The left offset of the graph on the canvas
*
* 'top' The top offset of the graph on the canvas
*
* 'usemap' Initialize an image map
*
* @param array $params Parameter array
* @abstract
*/
function Image_Canvas_WithMap($params)
{
parent::Image_Canvas($params);
if ((isset($params['usemap'])) && ($params['usemap'] === true)) {
$this->_imageMap =& Image_Canvas::factory(
'ImageMap',
array(
'left' => $this->_left,
'top' => $this->_top,
'width' => $this->_width,
'height' => $this->_height
)
);
}
}
/**
* Draw a line
*
* Parameter array:
* 'x0': int X start point
* 'y0': int Y start point
* 'x1': int X end point
* 'y1': int Y end point
* 'color': mixed [optional] The line color
* @param array $params Parameter array
*/
function line($params)
{
if (isset($this->_imageMap)) {
$this->_imageMap->line($params);
}
parent::line($params);
}
/**
* Adds vertex to a polygon
*
* Parameter array:
* 'x': int X point
* 'y': int Y point
* @param array $params Parameter array
*/
function addVertex($params)
{
if (isset($this->_imageMap)) {
$this->_imageMap->addVertex($params);
}
parent::addVertex($params);
}
/**
* Adds "splined" vertex to a polygon
*
* Parameter array:
* 'x': int X point
* 'y': int Y point
* 'p1x': X Control point 1
* 'p1y': Y Control point 1
* 'p2x': X Control point 2
* 'p2y': Y Control point 2
* @param array $params Parameter array
*/
function addSpline($params)
{
if (isset($this->_imageMap)) {
$this->_imageMap->addSpline($params);
}
parent::addSpline($params);
}
/**
* Draws a polygon
*
* Parameter array:
* 'connect': bool [optional] Specifies whether the start point should be
* connected to the endpoint (closed polygon) or not (connected line)
* 'fill': mixed [optional] The fill color
* 'line': mixed [optional] The line color
* @param array $params Parameter array
*/
function polygon($params)
{
if (isset($this->_imageMap)) {
$this->_imageMap->polygon($params);
}
parent::polygon($params);
}
/**
* Draw a rectangle
*
* Parameter array:
* 'x0': int X start point
* 'y0': int Y start point
* 'x1': int X end point
* 'y1': int Y end point
* 'fill': mixed [optional] The fill color
* 'line': mixed [optional] The line color
* @param array $params Parameter array
*/
function rectangle($params)
{
if (isset($this->_imageMap)) {
$this->_imageMap->rectangle($params);
}
parent::rectangle($params);
}
/**
* Draw an ellipse
*
* Parameter array:
* 'x': int X center point
* 'y': int Y center point
* 'rx': int X radius
* 'ry': int Y radius
* 'fill': mixed [optional] The fill color
* 'line': mixed [optional] The line color
* @param array $params Parameter array
*/
function ellipse($params)
{
if (isset($this->_imageMap)) {
$this->_imageMap->ellipse($params);
}
parent::ellipse($params);
}
/**
* Draw a pie slice
*
* Parameter array:
* 'x': int X center point
* 'y': int Y center point
* 'rx': int X radius
* 'ry': int Y radius
* 'v1': int The starting angle (in degrees)
* 'v2': int The end angle (in degrees)
* 'srx': int [optional] Starting X-radius of the pie slice (i.e. for a doughnut)
* 'sry': int [optional] Starting Y-radius of the pie slice (i.e. for a doughnut)
* 'fill': mixed [optional] The fill color
* 'line': mixed [optional] The line color
* @param array $params Parameter array
*/
function pieslice($params)
{
if (isset($this->_imageMap)) {
$this->_imageMap->pieslice($params);
}
parent::pieslice($params);
}
/**
* Writes text
*
* Parameter array:
* 'x': int X-point of text
* 'y': int Y-point of text
* 'text': string The text to add
* 'alignment': array [optional] Alignment
* 'color': mixed [optional] The color of the text
*/
function addText($params)
{
if (isset($this->_imageMap)) {
$this->_imageMap->addText($params);
}
parent::addText($params);
}
/**
* Overlay image
*
* Parameter array:
* 'x': int X-point of overlayed image
* 'y': int Y-point of overlayed image
* 'filename': string The filename of the image to overlay
* 'width': int [optional] The width of the overlayed image (resizing if possible)
* 'height': int [optional] The height of the overlayed image (resizing if possible)
* 'alignment': array [optional] Alignment
*/
function image($params)
{
if (isset($this->_imageMap)) {
$this->_imageMap->image($params);
}
parent::image($params);
}
/**
* Get the imagemap
* @return Image_Graph_ImageMap The image map (or false if none)
*/
function &getImageMap()
{
$result = null;
if (isset($this->_imageMap)) {
$result =& $this->_imageMap;
}
return $result;
}
}
?>