<?php
/**
- * This class defines the Horde_Image:: API, and also provides some
- * utility functions, such as generating highlights of a color.
+ * This class provides some utility functions, such as generating highlights
+ * of a color as well as a factory method responsible for creating a concerete
+ * Horde_Image driver.
*
* Copyright 2002-2009 The Horde Project (http://www.horde.org/)
*
* @author Michael J. Rubinsky <mrubinsk@horde.org>
*
* @package Horde_Image
- *
- * @TODO: - Can we depend on the Horde_Util:: class or some other solution needed?
- * - Exceptions
*/
class Horde_Image
{
- /**
- * Background color.
- *
- * @var string
- */
- protected $_background = 'white';
-
- /**
- * Observers.
- *
- * @var array
- */
- protected $_observers = array();
-
- /**
- * Capabilites of this driver.
- *
- * @var array
- */
- protected $_capabilities = array();
-
- /**
- * The current image data.
- *
- * @var string
- */
- protected $_data = '';
-
- /**
- * The current image id.
- *
- * @TODO: Do we *really* need an image id...and if so, we can make the
- * parameter optional in the methods that take one?
- *
- * @var string
- */
- protected $_id = '';
-
- /**
- * Logger
- */
- protected $_logger;
-
- /**
- * The current width of the image data.
- *
- * @var integer
- */
- protected $_width = 0;
-
- /**
- * The current height of the image data.
- *
- * @var integer
- */
- protected $_height = 0;
-
- /**
- * A directory for temporary files.
- *
- * @var string
- */
- protected $_tmpdir;
-
- /**
- * Array containing available Effects
- *
- * @var array
- */
- protected $_loadedEffects = array();
-
- /**
- * What kind of images should ImageMagick generate? Defaults to 'png'.
- *
- * @var string
- */
- protected $_type = 'png';
-
- /**
- * Constructor.
- *
- * @param string $rgb The base color for generated pixels/images.
- */
- protected function __construct($params, $context = array())
- {
- //@TODO: This is a temporary BC hack until I update all new Horde_Image calls
- if (empty($context['tmpdir'])) {
- throw new InvalidArgumentException('A path to a temporary directory is required.');
- }
- $this->_tmpdir = $context['tmpdir'];
- if (isset($params['width'])) {
- $this->_width = $params['width'];
- }
- if (isset($params['height'])) {
- $this->_height = $params['height'];
- }
- if (!empty($params['type'])) {
- $this->_type = $params['type'];
- }
-
- if (!empty($context['logger'])) {
- $this->_logger = $context['logger'];
- }
-
- $this->_background = isset($params['background']) ? $params['background'] : 'white';
- }
-
- /**
- * Getter for the capabilities array
- *
- * @return array
- */
- public function getCapabilities()
- {
- return $this->_capabilities;
- }
-
- /**
- * Check the existence of a particular capability.
- *
- * @param string $capability The capability to check for.
- *
- * @return boolean
- */
- public function hasCapability($capability)
- {
- return in_array($capability, $this->_capabilities);
- }
-
- /**
- * Generate image headers.
- */
- public function headers()
- {
- header('Content-type: ' . $this->getContentType());
- }
-
- /**
- * Return the content type for this image.
- *
- * @return string The content type for this image.
- */
- public function getContentType()
- {
- return 'image/' . $this->_type;
- }
-
- /**
- * Getter for the simplified image type.
- *
- * @return string The type of image (png, jpg, etc...)
- */
- public function getType()
- {
- return $this->_type;
- }
-
+ static protected $_loadedEffects = array();
/**
* Calculate a lighter (or darker) version of a color.
*
}
/**
- * Draw a shaped point at the specified (x,y) point. Useful for
- * scatter diagrams, debug points, etc. Draws squares, circles,
- * diamonds, and triangles.
- *
- * @param integer $x The x coordinate of the point to brush.
- * @param integer $y The y coordinate of the point to brush.
- * @param string $color The color to brush the point with.
- * @param string $shape What brush to use? Defaults to a square.
- */
- public function brush($x, $y, $color = 'black', $shape = 'square')
- {
- switch ($shape) {
- case 'triangle':
- $verts[0] = array('x' => $x + 3, 'y' => $y + 3);
- $verts[1] = array('x' => $x, 'y' => $y - 3);
- $verts[2] = array('x' => $x - 3, 'y' => $y + 3);
- $this->polygon($verts, $color, $color);
- break;
-
- case 'circle':
- $this->circle($x, $y, 3, $color, $color);
- break;
-
- case 'diamond':
- $verts[0] = array('x' => $x - 3, 'y' => $y);
- $verts[1] = array('x' => $x, 'y' => $y + 3);
- $verts[2] = array('x' => $x + 3, 'y' => $y);
- $verts[3] = array('x' => $x, 'y' => $y - 3);
- $this->polygon($verts, $color, $color);
- break;
-
- case 'square':
- default:
- $this->rectangle($x - 2, $y - 2, 4, 4, $color, $color);
- break;
- }
- }
-
- /**
- * Add an observer to this image. The observer will be notified
- * when the image's changes.
- */
- public function addObserver($method, $object)
- {
- $this->_observers[] = array($method, $object);
- }
-
- /**
- * Let observers know that something happened worth acting on.
- */
- public function notifyObservers()
- {
- for ($i = 0; $i < count($this->_observers); ++$i) {
- $obj = $this->_observers[$i][1];
- $method = $this->_observers[$i][0];
- $obj->$method($this);
- }
- }
-
- /**
- * Reset the image data to defaults.
- */
- public function reset()
- {
- $this->_data = '';
- $this->_id = '';
- $this->_width = null;
- $this->_height = null;
- $this->_background = 'white';
- $this->_type = 'png';
- }
-
- /**
- * Get the height and width of the current image data.
- *
- * @return array An hash with 'width' containing the width,
- * 'height' containing the height of the image.
- */
- public function getDimensions()
- {
- // Check if we know it already
- if ($this->_width == 0 && $this->_height == 0) {
- $tmp = $this->toFile();
- $details = @getimagesize($tmp);
- list($this->_width, $this->_height) = $details;
- unlink($tmp);
- }
-
- return array('width' => $this->_width,
- 'height' => $this->_height);
- }
-
- /**
- * Load the image data from a string.
- *
- * @param string $id An arbitrary id for the image.
- * @param string $image_data The data to use for the image.
- */
- public function loadString($id, $image_data)
- {
- if ($id != $this->_id) {
- $this->reset();
- $this->_data = $image_data;
- $this->_id = $id;
- }
- }
-
- /**
- * Load the image data from a file.
- *
- * @param string $filename The full path and filename to the file to load
- * the image data from. The filename will also be
- * used for the image id.
- *
- * @return mixed True if successful or already loaded, PEAR Error if file
- * does not exist or could not be loaded.
- */
- public function loadFile($filename)
- {
- if ($filename != $this->_id) {
- $this->reset();
- if (!file_exists($filename)) {
- return PEAR::raiseError('The image file ' . $filename . ' does not exist.');
- }
- if ($this->_data = file_get_contents($filename)) {
- $this->_id = $filename;
- } else {
- return PEAR::raiseError('Could not load the image file ' . $filename);
- }
- }
-
- return true;
- }
-
- /**
- * Ouputs image data to file. If $data is false, outputs current
- * image data after performing any pending operations on the data.
- * If $data contains raw image data, outputs that data to file without
- * regard for $this->_data
- *
- * @param mixed String of binary image data | false
- *
- * @return string Path to temporary file.
- */
- public function toFile($data = false)
- {
- $tmp = Horde_Util::getTempFile('img', false, $this->_tmpdir);
- $fp = @fopen($tmp, 'wb');
- fwrite($fp, $data ? $data : $this->raw());
- fclose($fp);
- return $tmp;
- }
-
- /**
- * Display the current image.
- */
- public function display()
- {
- $this->headers();
- echo $this->raw();
- }
-
- /**
- * Returns the raw data for this image.
- *
- * @param boolean $convert If true, the image data will be returned in the
- * target format, independently from any image
- * operations.
- *
- * @return string The raw image data.
- */
- public function raw($convert = false)
- {
- return $this->_data;
- }
-
- // @TODO: I don't see why these need to be private/protected...
- // probably can just make them static. Right now, I think
- // only _arcPoints is used (in gd.php)
- /**
* Get an x,y pair on circle, assuming center is 0,0.
*
* @access private
*
* @return array (x coordinate, y coordinate) of the point.
*/
- static protected function _circlePoint($degrees, $diameter)
+ static public function circlePoint($degrees, $diameter)
{
// Avoid problems with doubles.
$degrees += 0.0001;
*
* @return array The start point, end point, and anchor point.
*/
- static protected function _arcPoints($r, $start, $end)
+ static public function arcPoints($r, $start, $end)
{
// Start point.
$pts['x1'] = $r * cos(deg2rad($start));
}
/**
- * Attempts to apply requested effect to this image. If the
- * effect cannot be found a PEAR_Error is returned.
- *
- * @param string $type The type of effect to apply.
- * @param array $params Any parameters for the effect.
- *
- * @return mixed true on success | PEAR_Error on failure.
- */
- public function addEffect($type, $params)
- {
- $class = str_replace('Horde_Image_', '', get_class($this));
- $effect = Horde_Image_Effect::factory($type, $class, $params);
- if (is_a($effect, 'PEAR_Error')) {
- return $effect;
- }
- $effect->setImageObject($this);
- return $effect->apply();
- }
-
- /**
- * Load a list of available effects for this driver.
- */
- public function getLoadedEffects()
- {
- if (empty($this->_loadedEffects)) {
- $class = str_replace('Horde_Image_', '', get_class($this));
-
- // First, load the driver-agnostic Effects.
- $path = dirname(__FILE__) . '/Image/Effect/';
- if (is_dir($path)) {
- if ($handle = opendir($path)) {
- while (($file = readdir($handle)) !== false) {
- if (substr($file, -4, 4) == '.php') {
- $this->_loadedEffects[] = substr($file, 0, strlen($file) - 4);
- }
- }
- }
- }
-
- // Driver specific effects.
- $path = $path . $class;
- if (is_dir($path)) {
- if ($handle = opendir($path)) {
- while (($file = readdir($handle)) !== false) {
- if (substr($file, -4, 4) == '.php') {
- $this->_loadedEffects[] = substr($file, 0, strlen($file) - 4);
- }
- }
- }
- }
- }
-
- return $this->_loadedEffects;
- }
-
- /**
- * Apply any effects in the effect queue.
- */
- public function applyEffects()
- {
- $this->raw();
- }
-
- /**
* Attempts to return a concrete Horde_Image instance based on $driver.
*
* @param mixed $driver The type of concrete Horde_Image subclass to
return $image;
}
- public function getTmpDir()
- {
- return $this->_tmpdir;
- }
-
- /**
- * Utility function to zero out cached geometry information. Shouldn't
- * really be called from client code, but is needed since Effects may need
- * to clear these.
- *
- */
- public function clearGeometry()
- {
- $this->_height = 0;
- $this->_width = 0;
- }
-
- protected function _logDebug($message)
- {
- if (!empty($this->_logger)) {
- $this->_logger->debug($message);
- }
- }
-
- protected function _logErr($message)
- {
- if (!empty($this->_logger)) {
- $this->_logger->err($message);
- }
- }
-
/**
* Return point size for font
*/
--- /dev/null
+<?php
+/**
+ * This class defines the Horde_Image:: API, and also provides some
+ * utility functions, such as generating highlights of a color.
+ *
+ * Copyright 2002-2009 The Horde Project (http://www.horde.org/)
+ *
+ * See the enclosed file COPYING for license information (LGPL). If you
+ * did not receive this file, see http://www.fsf.org/copyleft/lgpl.html.
+ *
+ * @author Chuck Hagenbuch <chuck@horde.org>
+ * @author Michael J. Rubinsky <mrubinsk@horde.org>
+ *
+ * @package Horde_Image
+ *
+ * @TODO: - Can we depend on the Horde_Util:: class or some other solution needed?
+ * - Exceptions
+ */
+class Horde_Image_Base
+{
+ /**
+ * Background color.
+ *
+ * @var string
+ */
+ protected $_background = 'white';
+
+ /**
+ * Observers.
+ *
+ * @var array
+ */
+ protected $_observers = array();
+
+ /**
+ * Capabilites of this driver.
+ *
+ * @var array
+ */
+ protected $_capabilities = array();
+
+ /**
+ * The current image data.
+ *
+ * @var string
+ */
+ protected $_data = '';
+
+ /**
+ * The current image id.
+ *
+ * @TODO: Do we *really* need an image id...and if so, we can make the
+ * parameter optional in the methods that take one?
+ *
+ * @var string
+ */
+ protected $_id = '';
+
+ /**
+ * Logger
+ */
+ protected $_logger;
+
+ /**
+ * The current width of the image data.
+ *
+ * @var integer
+ */
+ protected $_width = 0;
+
+ /**
+ * The current height of the image data.
+ *
+ * @var integer
+ */
+ protected $_height = 0;
+
+ /**
+ * A directory for temporary files.
+ *
+ * @var string
+ */
+ protected $_tmpdir;
+
+ /**
+ * Array containing available Effects
+ *
+ * @var array
+ */
+ protected $_loadedEffects = array();
+
+ /**
+ * What kind of images should ImageMagick generate? Defaults to 'png'.
+ *
+ * @var string
+ */
+ protected $_type = 'png';
+
+ /**
+ * Constructor.
+ *
+ * @param string $rgb The base color for generated pixels/images.
+ */
+ protected function __construct($params, $context = array())
+ {
+ //@TODO: This is a temporary BC hack until I update all new Horde_Image calls
+ if (empty($context['tmpdir'])) {
+ throw new InvalidArgumentException('A path to a temporary directory is required.');
+ }
+ $this->_tmpdir = $context['tmpdir'];
+ if (isset($params['width'])) {
+ $this->_width = $params['width'];
+ }
+ if (isset($params['height'])) {
+ $this->_height = $params['height'];
+ }
+ if (!empty($params['type'])) {
+ $this->_type = $params['type'];
+ }
+
+ if (!empty($context['logger'])) {
+ $this->_logger = $context['logger'];
+ }
+
+ $this->_background = isset($params['background']) ? $params['background'] : 'white';
+ }
+
+ /**
+ * Getter for the capabilities array
+ *
+ * @return array
+ */
+ public function getCapabilities()
+ {
+ return $this->_capabilities;
+ }
+
+ /**
+ * Check the existence of a particular capability.
+ *
+ * @param string $capability The capability to check for.
+ *
+ * @return boolean
+ */
+ public function hasCapability($capability)
+ {
+ return in_array($capability, $this->_capabilities);
+ }
+
+ /**
+ * Generate image headers.
+ */
+ public function headers()
+ {
+ header('Content-type: ' . $this->getContentType());
+ }
+
+ /**
+ * Return the content type for this image.
+ *
+ * @return string The content type for this image.
+ */
+ public function getContentType()
+ {
+ return 'image/' . $this->_type;
+ }
+
+ /**
+ * Getter for the simplified image type.
+ *
+ * @return string The type of image (png, jpg, etc...)
+ */
+ public function getType()
+ {
+ return $this->_type;
+ }
+
+ /**
+ * Draw a shaped point at the specified (x,y) point. Useful for
+ * scatter diagrams, debug points, etc. Draws squares, circles,
+ * diamonds, and triangles.
+ *
+ * @param integer $x The x coordinate of the point to brush.
+ * @param integer $y The y coordinate of the point to brush.
+ * @param string $color The color to brush the point with.
+ * @param string $shape What brush to use? Defaults to a square.
+ */
+ public function brush($x, $y, $color = 'black', $shape = 'square')
+ {
+ switch ($shape) {
+ case 'triangle':
+ $verts[0] = array('x' => $x + 3, 'y' => $y + 3);
+ $verts[1] = array('x' => $x, 'y' => $y - 3);
+ $verts[2] = array('x' => $x - 3, 'y' => $y + 3);
+ $this->polygon($verts, $color, $color);
+ break;
+
+ case 'circle':
+ $this->circle($x, $y, 3, $color, $color);
+ break;
+
+ case 'diamond':
+ $verts[0] = array('x' => $x - 3, 'y' => $y);
+ $verts[1] = array('x' => $x, 'y' => $y + 3);
+ $verts[2] = array('x' => $x + 3, 'y' => $y);
+ $verts[3] = array('x' => $x, 'y' => $y - 3);
+ $this->polygon($verts, $color, $color);
+ break;
+
+ case 'square':
+ default:
+ $this->rectangle($x - 2, $y - 2, 4, 4, $color, $color);
+ break;
+ }
+ }
+
+ /**
+ * Add an observer to this image. The observer will be notified
+ * when the image's changes.
+ */
+ public function addObserver($method, $object)
+ {
+ $this->_observers[] = array($method, $object);
+ }
+
+ /**
+ * Let observers know that something happened worth acting on.
+ */
+ public function notifyObservers()
+ {
+ for ($i = 0; $i < count($this->_observers); ++$i) {
+ $obj = $this->_observers[$i][1];
+ $method = $this->_observers[$i][0];
+ $obj->$method($this);
+ }
+ }
+
+ /**
+ * Reset the image data to defaults.
+ */
+ public function reset()
+ {
+ $this->_data = '';
+ $this->_id = '';
+ $this->_width = null;
+ $this->_height = null;
+ $this->_background = 'white';
+ $this->_type = 'png';
+ }
+
+ /**
+ * Get the height and width of the current image data.
+ *
+ * @return array An hash with 'width' containing the width,
+ * 'height' containing the height of the image.
+ */
+ public function getDimensions()
+ {
+ // Check if we know it already
+ if ($this->_width == 0 && $this->_height == 0) {
+ $tmp = $this->toFile();
+ $details = @getimagesize($tmp);
+ list($this->_width, $this->_height) = $details;
+ unlink($tmp);
+ }
+
+ return array('width' => $this->_width,
+ 'height' => $this->_height);
+ }
+
+ /**
+ * Load the image data from a string.
+ *
+ * @param string $id An arbitrary id for the image.
+ * @param string $image_data The data to use for the image.
+ */
+ public function loadString($id, $image_data)
+ {
+ if ($id != $this->_id) {
+ $this->reset();
+ $this->_data = $image_data;
+ $this->_id = $id;
+ }
+ }
+
+ /**
+ * Load the image data from a file.
+ *
+ * @param string $filename The full path and filename to the file to load
+ * the image data from. The filename will also be
+ * used for the image id.
+ *
+ * @return mixed True if successful or already loaded, PEAR Error if file
+ * does not exist or could not be loaded.
+ */
+ public function loadFile($filename)
+ {
+ if ($filename != $this->_id) {
+ $this->reset();
+ if (!file_exists($filename)) {
+ return PEAR::raiseError('The image file ' . $filename . ' does not exist.');
+ }
+ if ($this->_data = file_get_contents($filename)) {
+ $this->_id = $filename;
+ } else {
+ return PEAR::raiseError('Could not load the image file ' . $filename);
+ }
+ }
+
+ return true;
+ }
+
+ /**
+ * Ouputs image data to file. If $data is false, outputs current
+ * image data after performing any pending operations on the data.
+ * If $data contains raw image data, outputs that data to file without
+ * regard for $this->_data
+ *
+ * @param mixed String of binary image data | false
+ *
+ * @return string Path to temporary file.
+ */
+ public function toFile($data = false)
+ {
+ $tmp = Horde_Util::getTempFile('img', false, $this->_tmpdir);
+ $fp = @fopen($tmp, 'wb');
+ fwrite($fp, $data ? $data : $this->raw());
+ fclose($fp);
+ return $tmp;
+ }
+
+ /**
+ * Display the current image.
+ */
+ public function display()
+ {
+ $this->headers();
+ echo $this->raw();
+ }
+
+ /**
+ * Returns the raw data for this image.
+ *
+ * @param boolean $convert If true, the image data will be returned in the
+ * target format, independently from any image
+ * operations.
+ *
+ * @return string The raw image data.
+ */
+ public function raw($convert = false)
+ {
+ return $this->_data;
+ }
+
+ /**
+ * Attempts to apply requested effect to this image. If the
+ * effect cannot be found a PEAR_Error is returned.
+ *
+ * @param string $type The type of effect to apply.
+ * @param array $params Any parameters for the effect.
+ *
+ * @return mixed true on success | PEAR_Error on failure.
+ */
+ public function addEffect($type, $params)
+ {
+ $class = str_replace('Horde_Image_', '', get_class($this));
+ $effect = Horde_Image_Effect::factory($type, $class, $params);
+ if (is_a($effect, 'PEAR_Error')) {
+ return $effect;
+ }
+ $effect->setImageObject($this);
+ return $effect->apply();
+ }
+
+ /**
+ * Load a list of available effects for this driver.
+ */
+ public function getLoadedEffects()
+ {
+ if (empty($this->_loadedEffects)) {
+ $class = str_replace('Horde_Image_', '', get_class($this));
+
+ // First, load the driver-agnostic Effects.
+ $path = dirname(__FILE__) . '/Image/Effect/';
+ if (is_dir($path)) {
+ if ($handle = opendir($path)) {
+ while (($file = readdir($handle)) !== false) {
+ if (substr($file, -4, 4) == '.php') {
+ $this->_loadedEffects[] = substr($file, 0, strlen($file) - 4);
+ }
+ }
+ }
+ }
+
+ // Driver specific effects.
+ $path = $path . $class;
+ if (is_dir($path)) {
+ if ($handle = opendir($path)) {
+ while (($file = readdir($handle)) !== false) {
+ if (substr($file, -4, 4) == '.php') {
+ $this->_loadedEffects[] = substr($file, 0, strlen($file) - 4);
+ }
+ }
+ }
+ }
+ }
+
+ return $this->_loadedEffects;
+ }
+
+ /**
+ * Apply any effects in the effect queue.
+ */
+ public function applyEffects()
+ {
+ $this->raw();
+ }
+
+ public function getTmpDir()
+ {
+ return $this->_tmpdir;
+ }
+
+ /**
+ * Utility function to zero out cached geometry information. Shouldn't
+ * really be called from client code, but is needed since Effects may need
+ * to clear these.
+ *
+ */
+ public function clearGeometry()
+ {
+ $this->_height = 0;
+ $this->_width = 0;
+ }
+
+ protected function _logDebug($message)
+ {
+ if (!empty($this->_logger)) {
+ $this->_logger->debug($message);
+ }
+ }
+
+ protected function _logErr($message)
+ {
+ if (!empty($this->_logger)) {
+ $this->_logger->err($message);
+ }
+ }
+
+}
* @author Michael J. Rubinsky <mrubinsk@horde.org>
* @package Horde_Image
*/
-class Horde_Image_Gd extends Horde_Image
+class Horde_Image_Gd extends Horde_Image_Base
{
/**
$r = $round * 2;
// Calculate the upper left arc.
- $p1 = self::_arcPoints($round, 180, 225);
- $p2 = self::_arcPoints($round, 225, 270);
+ $p1 = Horde_Image::arcPoints($round, 180, 225);
+ $p2 = Horde_Image::arcPoints($round, 225, 270);
// Calculate the upper right arc.
- $p3 = self::_arcPoints($round, 270, 315);
- $p4 = self::_arcPoints($round, 315, 360);
+ $p3 = Horde_Image::arcPoints($round, 270, 315);
+ $p4 = Horde_Image::arcPoints($round, 315, 360);
// Calculate the lower right arc.
- $p5 = self::_arcPoints($round, 0, 45);
- $p6 = self::_arcPoints($round, 45, 90);
+ $p5 = Horde_Image::arcPoints($round, 0, 45);
+ $p6 = Horde_Image::arcPoints($round, 45, 90);
// Calculate the lower left arc.
- $p7 = self::_arcPoints($round, 90, 135);
- $p8 = self::_arcPoints($round, 135, 180);
+ $p7 = Horde_Image::arcPoints($round, 90, 135);
+ $p8 = Horde_Image::arcPoints($round, 135, 180);
// Draw the corners - upper left, upper right, lower right,
// lower left.
* @author Michael J. Rubinsky <mrubinsk@horde.org>
* @package Horde_Image
*/
-class Horde_Image_Im extends Horde_Image
+class Horde_Image_Im extends Horde_Image_Base
{
/**
* Capabilites of this driver.
// If filled, draw the outline.
if (!empty($fill)) {
- list($x1, $y1) = $this->_circlePoint($start, $r * 2);
- list($x2, $y2) = $this->_circlePoint($mid, $r * 2);
- list($x3, $y3) = $this->_circlePoint($end, $r * 2);
+ list($x1, $y1) = Horde_Image::circlePoint($start, $r * 2);
+ list($x2, $y2) = Horde_Image::circlePoint($mid, $r * 2);
+ list($x3, $y3) = Horde_Image::circlePoint($end, $r * 2);
// This seems to result in slightly better placement of
// pie slices.
* @author Michael J. Rubinsky <mrubinsk@horde.org>
* @package Horde_Image
*/
-class Horde_Image_Imagick extends Horde_Image
+class Horde_Image_Imagick extends Horde_Image_Base
{
protected $_imagick;
* @author Mike Cochrane <mike@graftonhall.co.nz>
* @package Horde_Image
*/
-class Horde_Image_Png extends Horde_Image {
+class Horde_Image_Png extends Horde_Image_Base {
/**
* The array of pixel data.
* @author Chuck Hagenbuch <chuck@horde.org>
* @package Horde_Image
*/
-class Horde_Image_Svg extends Horde_Image
+class Horde_Image_Svg extends Horde_Image_Base
{
protected $_svg;
$path .= "M $x,$y ";
// Draw out to ellipse edge.
- list($arcX, $arcY) = $this->_circlePoint($start, $r * 2);
+ list($arcX, $arcY) = Horde_Image::circlePoint($start, $r * 2);
$path .= 'L ' . round($x + $arcX) . ',' .
round($y + $arcY) . ' ';
}
// Draw arcs.
- list($arcX, $arcY) = $this->_circlePoint($mid, $r * 2);
+ list($arcX, $arcY) = Horde_Image::circlePoint($mid, $r * 2);
$path .= "A $r,$r 0 0 1 " .
round($x + $arcX) . ',' .
round($y + $arcY) . ' ';
- list($arcX, $arcY) = $this->_circlePoint($end, $r * 2);
+ list($arcX, $arcY) = Horde_Image::circlePoint($end, $r * 2);
$path .= "A $r,$r 0 0 1 " .
round($x + $arcX) . ',' .
round($y + $arcY) . ' ';
* @author Chuck Hagenbuch <chuck@horde.org>
* @package Horde_Image
*/
-class Horde_Image_Swf extends Horde_Image {
+class Horde_Image_Swf extends Horde_Image_Base {
/**
* Capabilites of this driver.
$y4 = $y + $height - $round;
// Start in the upper left.
- $p1 = $this->_arcPoints($round, 180, 225);
- $p2 = $this->_arcPoints($round, 225, 270);
+ $p1 = Horde_Image::arcPoints($round, 180, 225);
+ $p2 = Horde_Image::arcPoints($round, 225, 270);
// Start at the lower left corner of the top left curve.
$s->movePenTo($x1 + $p1['x1'], $y1 + $p1['y1']);
$s->drawCurveTo($x1 + $p2['x3'], $y1 + $p2['y3'], $x1 + $p2['x2'], $y1 + $p2['y2']);
// Calculate the upper right points.
- $p3 = $this->_arcPoints($round, 270, 315);
- $p4 = $this->_arcPoints($round, 315, 360);
+ $p3 = Horde_Image::arcPoints($round, 270, 315);
+ $p4 = Horde_Image::arcPoints($round, 315, 360);
// Connect the top left and right curves.
$s->drawLineTo($x2 + $p3['x1'], $y2 + $p3['y1']);
$s->drawCurveTo($x2 + $p4['x3'], $y2 + $p4['y3'], $x2 + $p4['x2'], $y2 + $p4['y2']);
// Calculate the lower right points.
- $p5 = $this->_arcPoints($round, 0, 45);
- $p6 = $this->_arcPoints($round, 45, 90);
+ $p5 = Horde_Image::arcPoints($round, 0, 45);
+ $p6 = Horde_Image::arcPoints($round, 45, 90);
// Connect the top right and lower right curves.
$s->drawLineTo($x3 + $p5['x1'], $y3 + $p5['y1']);
$s->drawCurveTo($x3 + $p6['x3'], $y3 + $p6['y3'], $x3 + $p6['x2'], $y3 + $p6['y2']);
// Calculate the lower left points.
- $p7 = $this->_arcPoints($round, 90, 135);
- $p8 = $this->_arcPoints($round, 135, 180);
+ $p7 = Horde_Image::arcPoints($round, 90, 135);
+ $p8 = Horde_Image::arcPoints($round, 135, 180);
// Connect the bottom right and bottom left curves.
$s->drawLineTo($x4 + $p7['x1'], $y4 + $p7['y1']);
}
if ($end - $start <= 45) {
- $pts = $this->_arcPoints($r, $start, $end);
+ $pts = Horde_Image::arcPoints($r, $start, $end);
$s->movePenTo($x, $y);
$s->drawLineTo($pts['x1'] + $x, $pts['y1'] + $y);
$s->drawCurveTo($pts['x3'] + $x, $pts['y3'] + $y, $pts['x2'] + $x, $pts['y2'] + $y);
} else {
$sections = ceil(($end - $start) / 45);
for ($i = 0; $i < $sections; $i++) {
- $pts = $this->_arcPoints($r, $start + ($i * 45), ($start + (($i + 1) * 45) > $end)
+ $pts = Horde_Image::arcPoints($r, $start + ($i * 45), ($start + (($i + 1) * 45) > $end)
? $end
: ($start + (($i + 1) * 45)));
<file name="Swf.php" role="php" />
<file name="Exif.php" role="php" />
<file name="Exception.php" role="php" />
+ <file name="Base.php" role="php" />
</dir> <!-- /Horde/Image -->
<file name="Image.php" role="php" />
</dir> <!-- /Horde -->
<install name="lib/Horde/Image/Svg.php" as="Horde/Image/Svg.php" />
<install name="lib/Horde/Image/Swf.php" as="Horde/Image/Swf.php" />
<install name="lib/Horde/Image/Exception.php" as="Horde/Image/Exception.php" />
+ <install name="lib/Horde/Image/Base.php" as="Horde/Image/Base.php" />
<install name="lib/Horde/Image.php" as="Horde/Image.php" />
</filelist>
</phprelease>