Source for file Renderer.php
Documentation is available at Renderer.php
// +------------------------------------------------------------------------+
// | PEAR :: Image :: GIS :: Renderer Base Class |
// +------------------------------------------------------------------------+
// | Copyright (c) 2002-2005 Jan Kneschke <jan@kneschke.de> and |
// | Sebastian Bergmann <sb@sebastian-bergmann.de>. |
// +------------------------------------------------------------------------+
// | This source file is subject to version 3.00 of the PHP License, |
// | that is available at http://www.php.net/license/3_0.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. |
// +------------------------------------------------------------------------+
require_once 'Image/Color.php';
* @author Jan Kneschke <jan@kneschke.de>
* @author Sebastian Bergmann <sb@sebastian-bergmann.de>
* @copyright Copyright © 2002-2005 Jan Kneschke <jan@kneschke.de> and Sebastian Bergmann <sb@sebastian-bergmann.de>
* @license http://www.php.net/license/3_0.txt The PHP License, Version 3.0
* Set to TRUE to enable debugging.
* @param string $renderer
public static function factory($renderer, $width, $height, $debug) {
if (@include_once('Image/GIS2/Renderer/' . $renderer . '.php')) {
$class = 'Image_GIS2_Renderer_' . $renderer;
$object = new $class($width, $height, $debug);
* Draws a clipped line from ($x1, $y1) to ($x2, $y2)
if (($x1 > $this->max['x'] ||
$y1 < $this->min['y']) &&
($x2 > $this->max['x'] ||
$y2 < $this->min['y'])) {
printf('clipped x1: %d %d %d<br />', $x1, $this->min['x'], $this->max['x']);
printf('clipped y1: %d %d %d<br />', $y1, $this->min['y'], $this->max['y']);
printf('clipped x2: %d %d %d<br />', $x2, $this->min['x'], $this->max['x']);
printf('clipped y2: %d %d %d<br />', $y2, $this->min['y'], $this->max['y']);
$color = Image_Color ::namedColor2RGB ($color);
printf('Drawing line (%s, %s) -> (%s, %s)<br />', $x1, $y1, $x2, $y2);
$this->drawLine($x1, $y1, $x2, $y2, $color[0 ], $color[1 ], $color[2 ]);
* Returns the range of the data to be rendered.
* Converts a polar coordinate to an image coordinate.
* @param float $polarCoordinate
* @param string $direction
public function polar2image($polarCoordinate, $direction) {
return ($polarCoordinate - $this->min[$direction]) *
($this->width / ($this->max[$direction] - $this->min[$direction]));
return ($polarCoordinate - $this->max[$direction]) *
($this->height / ($this->min[$direction] - $this->max[$direction]));
public function render($lineSets) {
if ($this->min == false || $this->max == false ) {
foreach ($lineSets as $lineSet) {
if ($this->min == false ) {
$this->min['x'] = $lineSet->min ['x'];
$this->min['y'] = $lineSet->min ['y'];
$this->max['x'] = $lineSet->max ['x'];
$this->max['y'] = $lineSet->max ['y'];
$this->min['x'] = min($this->min['x'], $lineSet->min ['x']);
$this->min['y'] = min($this->min['y'], $lineSet->min ['y']);
$this->max['x'] = max($this->max['x'], $lineSet->max ['x']);
$this->max['y'] = max($this->max['y'], $lineSet->max ['y']);
foreach ($lineSets as $lineSet) {
foreach ($lineSet->lines as $line) {
$this->drawClippedLine($line[0 ], $line[1 ], $line[2 ], $line[3 ], $lineSet->color );
* Sets the range of the data to be rendered.
public function setRange($x1, $x2, $y1, $y2) {
$this->min = array ('x' => $x1, 'y' => $y1);
$this->max = array ('x' => $x2, 'y' => $y2);
* Draws a line from ($x1, $y1) to ($x2, $y2)
* using the color rgb($r, $g, $b).
public abstract function drawLine($x1, $y1, $x2, $y2, $r, $g, $b);
* Saves the rendered image to a given file.
* @param string $filename
public abstract function saveImage($filename);
* Shows the rendered image.
Documentation generated on Mon, 11 Mar 2019 15:48:42 -0400 by phpDocumentor 1.4.4. PEAR Logo Copyright © PHP Group 2004.
|