home *** CD-ROM | disk | FTP | other *** search
/ Cricao de Sites - 650 Layouts Prontos / WebMasters.iso / Servidores / xampp-win32-1.6.7-installer.exe / php / PEAR / Image / Graph / Marker / Cross.php < prev    next >
Encoding:
PHP Script  |  2008-07-02  |  4.3 KB  |  114 lines

  1. <?php
  2.  
  3. /* vim: set expandtab tabstop=4 shiftwidth=4 softtabstop=4: */
  4.  
  5. /**
  6.  * Image_Graph - PEAR PHP OO Graph Rendering Utility.
  7.  *
  8.  * PHP versions 4 and 5
  9.  *
  10.  * LICENSE: This library is free software; you can redistribute it and/or modify
  11.  * it under the terms of the GNU Lesser General Public License as published by
  12.  * the Free Software Foundation; either version 2.1 of the License, or (at your
  13.  * option) any later version. This library is distributed in the hope that it
  14.  * will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty
  15.  * of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser
  16.  * General Public License for more details. You should have received a copy of
  17.  * the GNU Lesser General Public License along with this library; if not, write
  18.  * to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
  19.  * 02111-1307 USA
  20.  *
  21.  * @category   Images
  22.  * @package    Image_Graph
  23.  * @subpackage Marker
  24.  * @author     Jesper Veggerby <pear.nosey@veggerby.dk>
  25.  * @copyright  Copyright (C) 2003, 2004 Jesper Veggerby Hansen
  26.  * @license    http://www.gnu.org/copyleft/lesser.html  LGPL License 2.1
  27.  * @version    CVS: $Id: Cross.php,v 1.7 2005/08/03 21:21:55 nosey Exp $
  28.  * @link       http://pear.php.net/package/Image_Graph
  29.  */
  30.  
  31. /**
  32.  * Include file Image/Graph/Marker.php
  33.  */
  34. require_once 'Image/Graph/Marker.php';
  35.  
  36. /**
  37.  * Data marker as a cross.
  38.  *
  39.  * @category   Images
  40.  * @package    Image_Graph
  41.  * @subpackage Marker
  42.  * @author     Jesper Veggerby <pear.nosey@veggerby.dk>
  43.  * @copyright  Copyright (C) 2003, 2004 Jesper Veggerby Hansen
  44.  * @license    http://www.gnu.org/copyleft/lesser.html  LGPL License 2.1
  45.  * @version    Release: 0.7.2
  46.  * @link       http://pear.php.net/package/Image_Graph
  47.  */
  48. class Image_Graph_Marker_Cross extends Image_Graph_Marker
  49. {
  50.  
  51.     /**
  52.      * The thickness of the plus in pixels (thickness is actually double this)
  53.      * @var int
  54.      * @access private
  55.      */
  56.     var $_thickness = 2;
  57.     
  58.     /**
  59.      * Draw the marker on the canvas
  60.      *
  61.      * @param int $x The X (horizontal) position (in pixels) of the marker on the canvas
  62.      * @param int $y The Y (vertical) position (in pixels) of the marker on the canvas
  63.      * @param array $values The values representing the data the marker 'points' to
  64.      * @access private
  65.      */
  66.     function _drawMarker($x, $y, $values = false)
  67.     {
  68.         if ($this->_thickness > 0) {
  69.             $this->_getLineStyle();
  70.             $this->_getFillStyle();
  71.             
  72.             $d1 = round(0.7071067 * $this->_size); // cos/sin(45 de>)
  73.             $d2 = round(0.7071067 * $this->_thickness); // cos/sin(45 deg)
  74.             
  75.             $this->_canvas->addVertex(array('x' => $x - $d1 - $d2, 'y' => $y - $d1 + $d2)); 
  76.             $this->_canvas->addVertex(array('x' => $x - $d1 + $d2, 'y' => $y - $d1 - $d2)); 
  77.             $this->_canvas->addVertex(array('x' => $x, 'y' => $y - 2 * $d2)); 
  78.             $this->_canvas->addVertex(array('x' => $x + $d1 - $d2, 'y' => $y - $d1 - $d2)); 
  79.             $this->_canvas->addVertex(array('x' => $x + $d1 + $d2, 'y' => $y - $d1 + $d2)); 
  80.             $this->_canvas->addVertex(array('x' => $x + 2 * $d2, 'y' => $y)); 
  81.             $this->_canvas->addVertex(array('x' => $x + $d1 + $d2, 'y' => $y + $d1 - $d2)); 
  82.             $this->_canvas->addVertex(array('x' => $x + $d1 - $d2, 'y' => $y + $d1 + $d2)); 
  83.             $this->_canvas->addVertex(array('x' => $x, 'y' => $y + 2 * $d2)); 
  84.             $this->_canvas->addVertex(array('x' => $x - $d1 + $d2, 'y' => $y + $d1 + $d2)); 
  85.             $this->_canvas->addVertex(array('x' => $x - $d1 - $d2, 'y' => $y + $d1 - $d2)); 
  86.             $this->_canvas->addVertex(array('x' => $x - 2 * $d2, 'y' => $y)); 
  87.             $this->_canvas->polygon(array('connect' => true));
  88.         } else {        
  89.             $this->_getLineStyle();
  90.             $this->_canvas->line(
  91.                 array(
  92.                     'x0' => $x - $this->_size,
  93.                     'y0' => $y - $this->_size,
  94.                     'x1' => $x + $this->_size,
  95.                     'y1' => $y + $this->_size
  96.                 )
  97.             );
  98.     
  99.             $this->_getLineStyle();
  100.             $this->_canvas->line(
  101.                 array(
  102.                     'x0' => $x + $this->_size,
  103.                     'y0' => $y - $this->_size,
  104.                     'x1' => $x - $this->_size,
  105.                     'y1' => $y + $this->_size
  106.                 )
  107.             );
  108.         }
  109.         parent::_drawMarker($x, $y, $values);
  110.     }
  111.  
  112. }
  113.  
  114. ?>