TeeChartPHP
[ class tree: TeeChartPHP ] [ index: TeeChartPHP ] [ all elements ]

Source for file CanvasMing.php

Documentation is available at CanvasMing.php

  1. <?php
  2.  
  3. /**
  4.  * GraphicsGD class
  5.  *
  6.  * Description: Class with all Chart drawing methods.
  7.  *
  8.  * @author
  9.  * @copyright (c) 1995-2010 by Steema Software SL. All Rights Reserved. <info@steema.com>
  10.  * @version 1.0
  11.  * @package TeeChartPHP
  12.  * @subpackage
  13.  * @link http://www.steema.com
  14.  */
  15.  
  16. class CanvasMing extends TeeBase
  17. {
  18.     // Private properties
  19.     private $tmpImg=null;
  20.     private $rectClip;
  21.     private $polygonClip;
  22.     private $is3D=false;
  23.     private $isOrtho=false;
  24.     private $iZoomText=false;
  25.     private $xCenter=0;
  26.     private $yCenter=0;
  27.     private $zCenter=0;
  28.     private $xCenterOffset=0;
  29.     private $yCenterOffset=0;
  30.     private $buffered=true;
  31.     private $rotationCenter=null;
  32.     protected $moveToX;
  33.     protected $moveToY;
  34.     private $iPoints;
  35.     private $s2;
  36.     private $c1;
  37.     private $s1;
  38.     private $c3;
  39.     private $s3;
  40.     private $c2;
  41.     private $c2s3;
  42.     private $c2c3;
  43.     private $tempXX;
  44.     private $tempYX;
  45.     private $tempXZ;
  46.     private $tempYZ;
  47.     private $iPerspec;
  48.     private $iOrthoX=0;
  49.     private $iOrthoY=0;
  50.     private $iZoomFactor=0;
  51.     private $iZoomPerspec=0;
  52.     private $pie3D;
  53.     private $colorPalette;
  54.  
  55.     private static $NUMCIRCLEPOINTS 64;
  56.     public static $DARKCOLORQUANTITY 64;
  57.     private static $DARKERCOLORQUANTITY 128;
  58.  
  59.     // Protected properties
  60.     protected $aspect;
  61.     protected $smoothingMode=false;
  62.     protected $textSmooth=false;
  63.     protected $font=null;
  64.     protected $stringFormat;
  65.     protected $bounds;
  66.     protected $brush=null;
  67.     protected $pen=null;
  68.     protected $metafiling;
  69.     protected $imageinterlace=true;
  70.     protected $imagereflection=false;
  71.     // For CanvasFlex
  72.     protected $supportsID;
  73.  
  74.     // Public properties
  75.     public $img;
  76.     public $shape;
  77.     
  78.     public $width=0;
  79.     public $height=0;
  80.     public $monochrome;
  81.     public $iPointDoubles;
  82.  
  83.  
  84.     // Interceptors
  85.     function __get$property {
  86.       $method ="get{$property}";
  87.       if method_exists$this$method ) ) {
  88.         return $this->$method();
  89.       }
  90.     }
  91.  
  92.     function __set $property,$value {
  93.       $method ="set{$property}";
  94.       if method_exists$this$method ) ) {
  95.         return $this->$method($value);
  96.       }
  97.     }
  98.  
  99.     /**
  100.     * Creates a new Graphics object
  101.     *
  102.     * @access       public
  103.     * @param IBaseChart $c 
  104.     * @param integer $width 
  105.     * @param integer $height 
  106.     */
  107.     function CanvasMing($c$width$height{
  108.  
  109.         $this->font = new ChartFont(null);
  110.         $this->stringFormat = new StringFormat();
  111.         $this->brush = new ChartBrush(null,null,null);
  112.         $this->pen = new ChartPen(null,new Color(0,0,0));
  113.         $this->colorPalette Theme::getSkyBluesPalette();
  114.         $this->rotationCenter new Point3D();
  115.  
  116.         $this->iPoints array();
  117.         $this->iPoints[0]=new TeePoint();
  118.         $this->iPoints[1]=new TeePoint();
  119.         $this->iPoints[2]=new TeePoint();
  120.         $this->iPoints[3]=new TeePoint();
  121.  
  122.         $this->iPointDoubles = Array();
  123.         $this->iPointDoubles[0]new PointDouble();
  124.         $this->iPointDoubles[1]new PointDouble();
  125.         $this->iPointDoubles[2]new PointDouble();
  126.         $this->iPointDoubles[3]new PointDouble();
  127.  
  128.         $this->width = $width;
  129.         $this->height$height;
  130.  
  131.         $this->createImage();           
  132.                 
  133.         parent::__construct($c);  // TeeBase
  134.        
  135.         if ($this->chart != null{
  136.             $this->setAspect($this->chart->getAspect());            
  137.       }      
  138.     }
  139.     
  140.     function getImg()
  141.     {
  142.        return $this->img;   
  143.     }
  144.  
  145.     /**************************************************************************
  146.     * Drawing methods............                                             *
  147.     **************************************************************************/
  148.  
  149.     /**
  150.     * Paints the image in rectangle r.
  151.     *
  152.     * @param Rectangle
  153.     * @param image Image
  154.     * @param mode ImageMode
  155.     * @param transparent boolean
  156.     */
  157.     public function draw($r$image$mode$shapeBorders$transparent{
  158.  
  159. /*        imageAlphaBlending($image, false);
  160.         imageSaveAlpha($image, true);
  161.  
  162.         //Get the sizes of both pix
  163.         $sourcefile_width=imagesx($this->img);
  164.         $sourcefile_height=imagesy($this->img);
  165.         $image_width=imagesx($image);
  166.         $image_height=imagesy($image);
  167.  
  168.  
  169.         if ($mode==ImageMode::$TILE) {
  170.           // TODO
  171.         }
  172.         elseif ($mode==ImageMode::$CENTER) {
  173.             $dest_x = ( $sourcefile_width / 2 ) - ( $image_width / 2 );
  174.             $dest_y = ( $sourcefile_height / 2 ) - ( $image_height / 2 );
  175.             imagecopy($this->img, $image, $dest_x, $dest_y, 0, 0,
  176.                $image_width, $image_height);
  177.         }
  178.         elseif ($mode==ImageMode::$NORMAL) {
  179.             $dest_x = 0;
  180.             $dest_y = 0;
  181.  
  182.             imagecopy($this->img, $image, $dest_x, $dest_y, 0, 0,
  183.                $image_width, $image_height);
  184.         }
  185.         else{
  186.           // Streched
  187.           $dest_x = 0;
  188.           $dest_y = 0;
  189.  
  190.           imagecopyresized($this->img, $image,$dest_x, $dest_y, 0, 0,
  191.               $sourcefile_width, $sourcefile_height,
  192.               $image_width, $image_height);
  193.         }
  194.  
  195.         // Check Round borders
  196.         // Top-left corner
  197.         if (($shapeBorders->getTopLeft()->getBorderRound() > 0) || ($shapeBorders->getBottomLeft()->getBorderRound() > 0) ||
  198.             ($shapeBorders->getTopRight()->getBorderRound() > 0) || ($shapeBorders->getBottomRight()->getBorderRound() > 0)) {
  199.  
  200.               $this->drawRoundedBorders($shapeBorders,null,null);
  201.         }
  202.         */
  203.     }
  204.  
  205.     /**
  206.      * Draws a line with an arrow head of ArrowWidth and ArrowHeight dimensions
  207.      * in pixels.
  208.      *
  209.      * @param filled boolean
  210.      * @param fromPoint Point
  211.      * @param toPoint Point
  212.      * @param headWidth int
  213.      * @param headHeight int
  214.      * @param int
  215.      */
  216.     public function arrow($filled$fromPoint$toPoint,
  217.                       $headWidth$headHeight$z{
  218.         /*
  219.                                      pc |\
  220.                       ph             pf | \
  221.                            |------------   \ ToPoint
  222.                       From |------------   /
  223.                       pg             pe | /
  224.                                      pd |/
  225.          */
  226.  
  227.         $dx $toPoint->getX($fromPoint->getX();
  228.         $dy $fromPoint->getY($toPoint->getY();
  229.         $l sqrt($dx $dx $dy $dy);
  230.  
  231.         if ($l 0// if at least one pixel...
  232.             $a new ArrowPoint();
  233.             $a->$z;
  234.             $a->$this;
  235.  
  236.             (int) $tmpHoriz $headWidth;
  237.             (int) $tmpVert min(MathUtils::round($l)$headHeight);
  238.             $a->sinA $dy $l;
  239.             $a->cosA $dx $l;
  240.             $xb $toPoint->getX($a->cosA $toPoint->getY($a->sinA;
  241.             $yb $toPoint->getX($a->sinA $toPoint->getY($a->cosA;
  242.             $a->$xb $tmpVert;
  243.             $a->$yb $tmpHoriz 0.5;
  244.  
  245.             $pc $a->calc();
  246.             $a->$yb $tmpHoriz 0.5;
  247.             $pd $a->calc();
  248.  
  249.             if ($filled{
  250.                 $tmpHoriz4 $tmpHoriz 0.25;
  251.                 $a->$yb $tmpHoriz4;
  252.                 $pe $a->calc();
  253.                 $a->$yb $tmpHoriz4;
  254.                 $pf $a->calc();
  255.                 $a->$fromPoint->$a->cosA $fromPoint->$a->sinA;
  256.                 $a->$yb $tmpHoriz4;
  257.                 $pg $a->calc();
  258.                 $a->$yb $tmpHoriz4;
  259.                 $ph $a->calc();
  260.                 
  261.                 $tmp Array($ph$pg$pe$pc$this->calc3DPoint($toPoint->getX(),$toPoint->getY(),
  262.                     $z)$pd$pf);
  263.                     
  264.                     /*
  265.             TODO    $this->polygon($tmp);
  266.                 */
  267.             else {
  268.                 $this->moveToZ($fromPoint$z);
  269.                 $this->lineTo($toPoint$z);
  270.                 $this->lineTo($pd$z);
  271.                 $this->moveToZ($toPoint$z);
  272.                 $this->lineTo($pc$z);
  273.             }
  274.         }
  275.     }
  276.  
  277.     /**
  278.      * Draws Bezier splines for the Point array p at displacement z
  279.      *
  280.      * @param int
  281.      * @param Point[]
  282.      */
  283.     public function drawBeziersRect($z$p{
  284.         $this->internalBezier($ztrue$p);
  285.     }
  286.         
  287.     /**
  288.      * Draws Bezier splines for the Point array p
  289.      *
  290.      * @param Point[]
  291.      */
  292.     public function drawBeziers($p{
  293.         $this->internalBezier(0false$p);
  294.     }
  295.     
  296.     private function internalBezier($z$is3D$points{
  297.         if ($is3D{
  298.             $this->moveToXYZ($points[0]->x$points[0]->y$z);
  299.         else {
  300.             $this->moveTo($points[0]);
  301.         }
  302.  
  303.         $this->drawBezier($is3D$z$points2);
  304.         $t 4;
  305.         do {
  306.             $this->drawBezier($is3D$z$points$t);
  307.             $t += 2;
  308.         while (!($t sizeof($points1));
  309.     }   
  310.     
  311.     private function drawBezier($is3D$z$points$first{
  312.  
  313.         $p1 $points[$first 2];
  314.         $p2 $points[$first 1];
  315.         $p3 $points[$first];
  316.  
  317.         for ($t 1$t 32$t++{
  318.             $mu $t 32;
  319.             $mu2 $mu $mu;
  320.             $mum1 $mu;
  321.             $mum12 $mum1 $mum1;
  322.  
  323.             $p new TeePoint((int) ($p1->$mum12 $p2->$mum1 $mu +
  324.                                        $p3->$mu2),
  325.                                 (int) ($p1->$mum12 $p2->$mum1 $mu +
  326.                                        $p3->$mu2));
  327.  
  328.             if ($is3D{
  329.                 $this->lineTo($p$z);
  330.             else {
  331.                 $this->__lineTo($p);
  332.             }
  333.         }
  334.     }
  335.      
  336.             
  337.     /**
  338.      * Calculates and returns the XY position in pixels of the XYZ 3D
  339.      * coordinate.<br>
  340.      * Can be used when custom drawing using 3D XYZ coordinates are returned
  341.      * from the axes or not.
  342.      *
  343.      * @param int
  344.      * @param int
  345.      * @param int
  346.      * @return Point 
  347.      */
  348.     public function calc3DPos($x$y$z{
  349.         if ($this->isOrtho{
  350.             return new TeePoint(($this->iZoomFactor ($x $this->xCenter +
  351.                    ($this->iOrthoX $z))) $this->xCenterOffset,
  352.                    ($this->iZoomFactor ($y $this->yCenter ($this->iOrthoY *
  353.                    $z))) $this->yCenterOffset);
  354.         else
  355.         if ($this->is3D{
  356.             $z -= $this->zCenter;
  357.             $x -= $this->xCenter;
  358.             $y -= $this->yCenter;
  359.  
  360.             $zz $z $this->c2 $x $this->s2;
  361.  
  362.             $tmp $this->iZoomFactor;
  363.  
  364.             if ($this->iPerspec{
  365.                 $tmp /= ($this->iZoomPerspec ($zz $this->c1 $y $this->s1));
  366.             }
  367.  
  368.             return new TeePoint( (($x $this->c2 $z $this->s2$tmp$this->xCenterOffset,
  369.                               (($y $this->c1 $zz $this->s1$tmp$this->yCenterOffset);
  370.         else {
  371.             return new TeePoint($x$y);
  372.         }
  373.     }
  374.  
  375.     /**
  376.      * Calculates and returns the XY position as double of the XYZ 3D
  377.      * coordinate.<br>
  378.      * Can be used when custom drawing using 3D XYZ coordinates are returned
  379.      * from the axes or not.
  380.      * Returns PointDouble
  381.      */
  382.     public function calc3DPosDouble($x$y$z$pointDouble{
  383.         if ($this->isOrtho{
  384.             return new PointDouble((int) ($this->iZoomFactor ($x $this->xCenter ($this->iOrthoX $z))) +
  385.                              $this->xCenterOffset,
  386.                              (int) ($this->iZoomFactor ($y $this->yCenter ($this->iOrthoY $z))) +
  387.                              $this->yCenterOffset);
  388.         else
  389.         if ($this->is3D{
  390.             $z -= $this->zCenter;
  391.             $x -= $this->xCenter;
  392.             $y -= $this->yCenter;
  393.  
  394.             $zz $z $this->c2 $x $this->s2;
  395.  
  396.             $tmp $this->iZoomFactor;
  397.  
  398.             if ($this->iPerspec{
  399.                 $tmp /= ($this->iZoomPerspec ($zz $this->c1 $y $this->s1));
  400.             }
  401.  
  402.             return new PointDouble((int) (($x $this->c2 $z $this->s2$tmp$this->xCenterOffset,
  403.                (int) (($y $this->c1 $zz $this->s1$tmp$this->yCenterOffset);
  404.  
  405.         else {
  406.             return new PointDouble($x$y);
  407.         }
  408.     }
  409.  
  410.     /**
  411.      * Calculates and returns the XY position in pixels of the point p Z 3D
  412.      * coordinate. <br>
  413.      * Can be used when custom drawing using 3D XYZ coordinates are returned
  414.      * from the axes or not.
  415.      *
  416.      * @param source Point3D
  417.      * @return Point 
  418.      */
  419.     public function _calc3DPos($source{
  420.         return $this->calc3DPos($source->getX()$source->getY()$source-getZ());
  421.     }
  422.  
  423.     /**
  424.      * Calculates and returns the XY position in pixels of the point p Z 3D
  425.      * coordinate.<br>
  426.      * Can be used when custom drawing using 3D XYZ coordinates are returned
  427.      * from the axes or not.
  428.      *
  429.      * @param source Point
  430.      * @param int
  431.      * @return Point 
  432.      */
  433.     public function __calc3DPos($source$z{
  434.         return $this->calc3DPos($source->getX()$source->getY()$z);
  435.     }
  436.  
  437.     /**
  438.      * Calculates and returns the XY position in pixels of the point p with
  439.      * Z = 0 3D coordinate.<br>
  440.      * Can be used when custom drawing using 3D XYZ coordinates are returned
  441.      * from the axes or not.
  442.      *
  443.      * @param source Point
  444.      * @return Point 
  445.      */
  446.     public function ___calc3DPos($source{
  447.         return $this->calc3DPos($source->x$source->y0);
  448.     }
  449.  
  450.     public function calc3DPoint($x$y$z=0{
  451.         return $this->calc3DPos($x$y$z);
  452.     }
  453.  
  454.     public function calcPerspective($r{
  455.         $PERSPECFACTOR 1.0 150.0;
  456.         $perspec $this->aspect->getPerspective();
  457.         $this->iPerspec ($perspec 0);
  458.  
  459.         if ($this->iPerspec{
  460.             $tmp $r->width;
  461.             if ($tmp 1{
  462.                 $tmp 1;
  463.             }
  464.  
  465.             $this->iZoomPerspec $this->iZoomFactor $perspec $PERSPECFACTOR $tmp;
  466.         }
  467.     }
  468.  
  469.     public function calcTrigValues({
  470.         $rx 0;
  471.         $ry 0;
  472.         $rz 0;
  473.  
  474.         if (!$this->aspect->getOrthogonal()) {
  475.             $rx = -$this->aspect->getElevation();
  476.             $ry = -$this->aspect->getRotation();
  477.             $rz $this->aspect->getTilt();
  478.         }
  479.  
  480.         $this->s1 sin($rx MathUtils::getPiStep());
  481.         $this->c1 cos($rx MathUtils::getPiStep());
  482.  
  483.         $this->s2 sin($ry MathUtils::getPiStep());
  484.         $this->c2 cos($ry MathUtils::getPiStep());
  485.         $this->s3 sin($rz MathUtils::getPiStep());
  486.         $this->c3 cos($rz MathUtils::getPiStep());
  487.  
  488.         $this->c2s3 $this->c2 $this->s3;
  489.         $this->c2c3 max(1E-5$this->c2 $this->c3);
  490.  
  491.         $this->tempXX max(1E-5$this->s1 $this->s2 $this->s3 $this->c1 $this->c3);
  492.         $this->tempYX ($this->c3 $this->s1 $this->s2 $this->c1 $this->s3);
  493.  
  494.         $this->tempXZ ($this->c1 $this->s2 $this->s3 $this->c3 $this->s1);
  495.         $this->tempYZ ($this->c1 $this->c3 $this->s2 $this->s1 $this->s3);
  496.  
  497.         $this->iPerspec false;
  498.         $this->iZoomPerspec 0;
  499.     }
  500.  
  501.     public function changed($o{}
  502.  
  503.     function unClip({
  504. /*
  505.       if (!$this->rectClip==null)
  506.       {
  507.         $x = $this->rectClip->getX();
  508.         $y = $this->rectClip->getY();
  509.         imagecopymerge($this->tmpImg, $this->img,$x,$y,$x,$y,
  510.         $this->rectClip->getWidth(),$this->rectClip->getHeight(),100);
  511.  
  512.         imagecopy($this->img,$this->tmpImg,0,0,0,0,imagesx($this->img),imagesy($this->img));
  513.         $this->rectClip=null;
  514.       }
  515.  
  516.       if (!$this->polygonClip==null)
  517.       {
  518.         // TODO polygon uniclip
  519.         $this->polygonClip=null;
  520.       }
  521.       */
  522.     }
  523.  
  524.     /**
  525.      * Creates a Windows GDI clipping region and selects it into
  526.      * TChart.<!-- -->Canvas device context handle.<br>
  527.      *
  528.      * @param left int
  529.      * @param top int
  530.      * @param right int
  531.      * @param bottom int
  532.      */
  533.     public function clipRectangle($left$top$right$bottom{
  534. /*
  535.       $top=$top-2;
  536.       $bottom++;
  537.       $right=$right+2;
  538.  
  539.       $this->rectClip=new Rectangle();
  540.       $this->rectClip->x=$left;
  541.       $this->rectClip->y=$top;
  542.       $this->rectClip->width=$right-$left;
  543.       $this->rectClip->height=$bottom-$top;
  544.  
  545.       $this->tmpImg = imagecreatetruecolor(imagesx($this->img), imagesy($this->img));
  546.  
  547.       // Converts to Transparent image
  548.       imagesavealpha($this->tmpImg, true);
  549.  
  550.       /* TODO check if required or not
  551.       $trans_colour = imagecolorallocatealpha($this->tmpImg, 0, 0, 0, 127);
  552.       imagefill($this->tmpImg, 0, 0, $trans_colour);
  553.       
  554.  
  555.       imagecopy($this->tmpImg,$this->img,0,0,0,0,imagesx($this->img),imagesy($this->img));
  556.       */
  557.     }
  558.        
  559.  
  560.     /**
  561.      * Creates a Windows GDI clipping region and selects it into
  562.      * TChart.<!-- -->Canvas device context handle.<br>
  563.      *
  564.      * @param polygonPoints - Array of TeePoints
  565.      */
  566.     public function clipPolygon($polygonPoints{
  567.  
  568. /*      $this->polygonClip=Array();
  569.       $this->polygonClip=$polygonPoiints;
  570.   */
  571.       // TODO clipPolygon
  572.     }
  573.     
  574.     
  575.     /**
  576.      * Paints a cone with Cone Percent.<br>
  577.      * Use <br>ONLY with OPENGL</b>.<br>
  578.      * This parameter varies the apex size
  579.      * as a percentage of the base.<br>
  580.      *
  581.      * @param vertical boolean
  582.      * @param Rectangle
  583.      * @param z0 int
  584.      * @param z1 int
  585.      * @param darkSides boolean
  586.      * @param conePercent int varies the apex size as a percentage of the base.
  587.      */
  588.     public function cone($vertical$r$z0$z1$darkSides$conePercent=0{
  589.         $this->internalCylinder($vertical$r$z0$z1$darkSides$conePercent);
  590.     }
  591.  
  592.     /**
  593.      * Draws cylinder toggle Boolean for vertical or horizontal cylinder.
  594.      *
  595.      * @param vertical boolean
  596.      * @param Rectangle
  597.      * @param z0 int
  598.      * @param z1 int
  599.      * @param darkSides boolean
  600.      */
  601.     public function cylinder($vertical$r$z0$z1$darkSides{
  602.         $this->internalCylinder($vertical$r$z0$z1$darkSides100);
  603.     }
  604.  
  605.     private function internalCylinder($vertical$r$z0$z1$dark3D$conePercent{
  606. /*
  607.         $NUMCYLINDERSIDES = 16;   // 256
  608.         $STEP = 2.0 * M_PI / $NUMCYLINDERSIDES; 
  609.         $STEPCOLOR = 256 / $NUMCYLINDERSIDES;         // 512
  610.         
  611.         $poly = Array();
  612.         $tmpPoly = Array();
  613.           
  614.         $oldColor = $this->brush->getColor();
  615.           
  616.         (int) $zRadius = ($z1 - $z0) / 2;
  617.         (int) $tmpMidZ = ($z1 + $z0) / 2;
  618.  
  619.         if ($vertical) {
  620.             
  621.             (int) $radius = ($r->getRight() - $r->x) / 2;
  622.             (int) $tmpMid = ($r->getRight() + $r->x) / 2;
  623.             (int) $tmpSize = abs($r->getBottom() - $r->y);
  624.  
  625.             for ($t = 0; $t < $NUMCYLINDERSIDES; $t++) {
  626.                 (double) $tmpSin = sin(($t - 3) * $STEP);
  627.                 (double) $tmpCos = cos(($t - 3) * $STEP);
  628.  
  629.                 $poly[$t] = new Point3D();
  630.  
  631.                 $poly[$t]->x = $tmpMid + MathUtils::round($tmpSin * $radius);
  632.  
  633.                 if ($r->y < $r->getBottom()) {
  634.                     $poly[$t]->y = $r->y;
  635.                 } else {
  636.                     $poly[$t]->y = $r->getBottom();
  637.                 }
  638.  
  639.                 $poly[$t]->z = $tmpMidZ - MathUtils::round($tmpCos * $zRadius);
  640.             }
  641.             $radius = MathUtils::round($radius * $conePercent * 0.01);
  642.             $zRadius = MathUtils::round($zRadius * $conePercent * 0.01);
  643.  
  644.             $tmpPoly[1] = $this->calc3DPoint($poly[0]->x, $poly[0]->y + $tmpSize, $poly[0]->z);
  645.  
  646.             $tmpSin = sin((1 - 4) * $STEP);
  647.             $tmpCos = cos((1 - 4) * $STEP);
  648.  
  649.             $poly[0]->x = $tmpMid + MathUtils::round($tmpSin * $radius);
  650.             $poly[0]->z = $tmpMidZ - MathUtils::round($tmpCos * $zRadius);
  651.  
  652.             $tmpPoly[0] = $this->calc3DPoint($poly[0]->x,$poly[0]->y,$poly[0]->z);
  653.  
  654.             $numSide = 0;
  655.  
  656.             for ($t = 1; $t < $NUMCYLINDERSIDES; $t++) {
  657.                 $tmpPoly[2] = $this->calc3DPoint($poly[$t]->x, $poly[$t]->y + $tmpSize,
  658.                                          $poly[$t]->z);
  659.  
  660.                 $tmpSin = sin(($t - 3) * $STEP);
  661.                 $tmpCos = cos(($t - 3) * $STEP);
  662.  
  663.                 $poly[$t]->x = $tmpMid + MathUtils::round($tmpSin * $radius);
  664.                 $poly[$t]->z = $tmpMidZ - MathUtils::round($tmpCos * $zRadius);
  665.  
  666.                 $tmpPoly[3] = $this->calc3DPoint($poly[$t]->x,$poly[$t]->y,$poly[$t]->z);
  667.                 $tmp = ($tmpPoly[0]->x - $tmpPoly[2]->x + $tmpPoly[1]->x -
  668.                        $tmpPoly[3]->x) < 0;
  669.                 if ($tmp) {
  670.                     if ($dark3D) {                           
  671.                         $this->internalApplyDark($oldColor, $STEPCOLOR * $numSide);
  672.                     }
  673.  
  674.                     $p = Array($tmpPoly[0], $tmpPoly[1], $tmpPoly[2], $tmpPoly[3]);                    
  675.                     $this->polygon($p);
  676.                 }
  677.                 $tmpPoly[0] = $tmpPoly[3];
  678.                 $tmpPoly[1] = $tmpPoly[2];
  679.                 $numSide++;
  680.             }
  681.         } else {
  682.             $radius = ($r->getBottom() - $r->y) / 2;
  683.             $tmpMid = ($r->getBottom() + $r->y) / 2;      
  684.            
  685.             $tmpSize = $r->getRight() - $r->X;
  686.  
  687.             for ($t = 0; $t < $NUMCYLINDERSIDES; $t++) {
  688.                 $tmpSin = sin(($t - 4) * $STEP);
  689.                 $tmpCos = cos(($t - 4) * $STEP);
  690.  
  691.                 $poly[$t] = new Point3D();
  692.                          
  693.                 if ($r->x < $r->getRight()) {
  694.                     $poly[$t]->x = $r->getRight();
  695.                 } else {
  696.                     $poly[$t]->x = $r->x;
  697.                 }
  698.             
  699.                 $poly[$t]->y = $tmpMid + MathUtils::round($tmpSin * $radius);
  700.                 $poly[$t]->z = $tmpMidZ - MathUtils::round($tmpCos * $zRadius);
  701.             }
  702.  
  703.             $radius = MathUtils::round($radius * $conePercent * 0.01);
  704.             $zRadius = MathUtils::round($zRadius * $conePercent * 0.01);
  705.             $tmpSize = abs($r->getRight() - $r->x);
  706.  
  707.             $tmpPoly[1] = $this->calc3DPoint($poly[0]->x - $tmpSize, $poly[0]->y, $poly[0]->z);
  708.  
  709.             $tmpSin = sin( -4 * $STEP);
  710.             $tmpCos = cos( -4 * $STEP);
  711.  
  712.             $poly[0]->y = $tmpMid + MathUtils::round($tmpSin * $radius);
  713.             $poly[0]->z = $tmpMidZ - MathUtils::round($tmpCos * $zRadius);
  714.                           
  715.                         
  716.             $tmpPoly[0] = $this->calc3DPoint($poly[0]->x,$poly[0]->y,$poly[0]->z);
  717.             $numSide = 0;
  718.  
  719.             for ($t = 1; $t < $NUMCYLINDERSIDES; $t++) {
  720.                 $tmpPoly[2] = $this->calc3DPoint($poly[$t]->x - $tmpSize, $poly[$t]->y,
  721.                                          $poly[$t]->z);
  722.  
  723.                 $tmpSin = sin(($t - 4) * $STEP);
  724.                 $tmpCos = cos(($t - 4) * $STEP);
  725.  
  726.                 $poly[$t]->y = $tmpMid + MathUtils::round($tmpSin * $radius);
  727.                 $poly[$t]->z = $tmpMidZ - MathUtils::round($tmpCos * $zRadius);
  728.  
  729.                 $tmpPoly[3] = $this->calc3DPoint($poly[$t]->x,$poly[$t]->y,$poly[$t]->z);
  730.                 $tmp = ($tmpPoly[0]->y - $tmpPoly[2]->y + $tmpPoly[1]->y -
  731.                        $tmpPoly[3]->y) < 0;
  732.  
  733.                 if ($tmp) {
  734.                     if ($dark3D) {                
  735.                          $this->internalApplyDark($oldColor, $STEPCOLOR * $numSide);
  736.                     }                                                                  
  737.  
  738.                     $p = Array($tmpPoly[0], $tmpPoly[1], $tmpPoly[2], $tmpPoly[3]);
  739.                     $this->polygon($p);
  740.                 }
  741.  
  742.                 $tmpPoly[0] = $tmpPoly[3];
  743.                 $tmpPoly[1] = $tmpPoly[2];
  744.                 $numSide++;
  745.             }
  746.         }
  747.  
  748.         for ($t = 0; $t < $NUMCYLINDERSIDES; $t++) {
  749.             $tmpPoly[$t] = $this->calc3DPoint($poly[$t]->x,$poly[$t]->y,$poly[$t]->z);
  750.         }
  751.  
  752.         if ($dark3D) {
  753.             $this->internalApplyDark($oldColor, $DARKCOLORQUANTITY);
  754.         }
  755.  
  756.         $this->polygon($tmpPoly);
  757.         */
  758.     }
  759.     
  760.  
  761. function imagegradientellipse($image$cx$cy$w$h$ic$oc){
  762. /*    $w = abs($w);
  763.     $h = abs($h);
  764.     $oc = array(0xFF & ($oc >> 0x10), 0xFF & ($oc >> 0x8), 0xFF & $oc);
  765.     $ic = array(0xFF & ($ic >> 0x10), 0xFF & ($ic >> 0x8), 0xFF & $ic);
  766.     $c0 = ($oc[0] - $ic[0]) / $w;
  767.     $c1 = ($oc[1] - $ic[1]) / $w;
  768.     $c2 = ($oc[2] - $ic[2]) / $w;
  769.     $i = 0;
  770.     $j = 0;
  771.     $is = ($w<$h)?($w/$h):1;
  772.     $js = ($h<$w)?($h/$w):1;
  773.     while(1){
  774.         $r = $oc[0] - floor($i * $c0);
  775.         $g = $oc[1] - floor($i * $c1);
  776.         $b = $oc[2] - floor($i * $c2);
  777.         $c = imagecolorallocate($image, $r, $g, $b);
  778.         imagefilledellipse($image, $cx, $cy, $w-$i, $h-$j, $c);
  779.         if($i < $w){
  780.             $i += $is;
  781.         }
  782.         if($j < $h){
  783.             $j += $js;
  784.         }
  785.         if($i >= $w && $j >= $h){
  786.             break;
  787.         }
  788.     }
  789.     */
  790. }
  791.  
  792. function imagegradientellipsealpha($image$cx$cy$w$h$ic$oc){
  793. /*       $w = abs($w);
  794.        $h = abs($h);
  795.        $oc = array(0xFF & ($oc >> 0x10), 0xFF & ($oc >> 0x8), 0xFF & $oc);
  796.        $ic = array(0xFF & ($ic >> 0x10), 0xFF & ($ic >> 0x8), 0xFF & $ic);
  797.        $c0 = ($oc[0] - $ic[0]) / $w;
  798.        $c1 = ($oc[1] - $ic[1]) / $w;
  799.        $c2 = ($oc[2] - $ic[2]) / $w;
  800.        $ot = $oc >> 24;
  801.        $it = $ic >> 24;
  802.        $ct = ($ot - $it) / $w;
  803.        $i = 0;
  804.        $j = 0;
  805.        $is = ($w<$h)?($w/$h):1;
  806.        $js = ($h<$w)?($h/$w):1;
  807.        while(1){
  808.            $r = $oc[0] - floor($i * $c0);
  809.            $g = $oc[1] - floor($i * $c1);
  810.            $b = $oc[2] - floor($i * $c2);
  811.            $t = $ot - floor($i * $ct);
  812.            $c = imagecolorallocatealpha($image, $r, $g, $b, $t);
  813.            imageellipse($image, $cx, $cy, $w-$i, $h-$j, $c);
  814.            if($i < $w){
  815.                $i += $is;
  816.            }
  817.            if($j < $h){
  818.                $j += $js;
  819.            }
  820.            if($i >= $w && $j >= $h){
  821.                break;
  822.            }
  823.        }
  824.        */
  825.     }
  826.     
  827.     
  828.     private function clipToRight($rect$minZ$maxZ{
  829. /*        $p = Array();
  830.         $p[0] = new TeePoint();
  831.         $p[1] = new TeePoint();
  832.         $p[2] = new TeePoint();
  833.         $p[3] = new TeePoint();
  834.         $p[4] = new TeePoint();
  835.         $p[5] = new TeePoint();
  836.  
  837.  
  838.         $p[0] = $this->calc3DPoint($rect->x, $rect->getBottom(), $minZ);
  839.         $p[1] = $this->calc3DPoint($rect->x, $rect->y, $minZ);
  840.  
  841.         {
  842.             $pa = $this->calc3DPoint($rect->x, $rect->y, $maxZ);
  843.             $pb = $this->calc3DPoint($rect->getRight(), $rect->y, $minZ);
  844.  
  845.             $p[2] = ($pb->getY() < $pa->getY()) ? $pb : $pa;
  846.         }
  847.  
  848.         $p[3] = $this->calc3DPoint($rect->getRight(), $rect->y, $maxZ);
  849.  
  850.         $pc = $this->calc3DPoint($rect->getRight(), $rect->getBottom(), $maxZ);
  851.         $pd = $this->calc3DPoint($rect->getRight(), $rect->y, $minZ);
  852.  
  853.         $p[4] = ($pd->getX() > $pc->getX()) ? $pd : $pc;
  854.  
  855.         $p[5] = $this->calc3DPoint($rect->getRight(), $rect->getBottom(), $minZ);
  856.         if ($p[5]->getX() < $p[0]->getX()) {
  857.             $p[0]->setX($p[5]->getX());
  858.             if ($pd->getY() < $p[0]->getY()) {
  859.                 $p[0]->setY($pd->getY());
  860.             }
  861.         }
  862.  
  863.         $c1 = imagecolorallocate($this->img, $this->getBrush()->getColor()->red,
  864.             $this->getBrush()->getColor()->green,
  865.             $this->getBrush()->getColor()->blue);
  866.             */
  867.     }
  868.  
  869.     private function clipToLeft($rect$minZ$maxZ{
  870. /*
  871.         $c1 = imagecolorallocate($this->img, $this->getBrush()->getColor()->red,
  872.             $this->getBrush()->getColor()->green,
  873.             $this->getBrush()->getColor()->blue);
  874.  
  875. /* TODO clippolygon        imagepolygon($this->img,  array (
  876.                     $this->calc3DPoint($rect->x, $rect->getBottom(), $minZ),
  877.                     $this->calc3DPoint($rect->x, $rect->getBottom(), $maxZ),
  878.                     $this->calc3DPoint($rect->x, $rect->y, $maxZ),
  879.                     $this->calc3DPoint($rect->getRight(), $rect->y, $maxZ),
  880.                     $this->calc3DPoint($rect->getRight(), $rect->y, $minZ),
  881.                     $this->calc3DPoint($rect->getRight(), $rect->getBottom(), $minZ)),
  882.                     3, $c1);*/
  883.                     
  884.     }
  885.  
  886.     public function cuber ($rect$z0$z1$darkSides{
  887.         $this->cube($rect->getLeft()$rect->getTop()$rect->getRight()$rect->getBottom()$z0$z1$darkSides);
  888.     }
  889.  
  890.     /**
  891.      * Draws a Cube with Dark Sides.
  892.      *
  893.      * @param left int
  894.      * @param top int
  895.      * @param right int
  896.      * @param bottom int
  897.      * @param z0 int
  898.      * @param z1 int
  899.      * @param darkSides boolean
  900.      */
  901.     public function cube($left$top$right$bottom$z0$z1$darkSides{
  902. /*        $oldColor = $this->brush->getColor();
  903.         $p0 = $this->calc3DPoint($left, $top, $z0);
  904.         $p1 = $this->calc3DPoint($right, $top, $z0);
  905.         $p2 = $this->calc3DPoint($right, $bottom, $z0);
  906.         $p3 = $this->calc3DPoint($right, $top, $z1);
  907.         $this->iPoints[0] = $p0;
  908.         $this->iPoints[1] = $p1;
  909.         $this->iPoints[2] = $p2;
  910.         $this->iPoints[3] = $this->calc3DPoint($left, $bottom, $z0);
  911.  
  912.         if ($this->culling() > 0) {
  913.             $this->polygonFour(); // front-side
  914.         } else {
  915.             $this->iPoints[0] = $this->calc3DPos($left, $top, $z1);
  916.             $this->iPoints[1] = $this->calc3DPos($right, $top, $z1);
  917.             $this->iPoints[2] = $this->calc3DPos($right, $bottom, $z1);
  918.             $this->iPoints[3] = $this->calc3DPos($left, $bottom, $z1);
  919.             $this->polygonFour(); // back-side
  920.         }
  921.  
  922.         $this->iPoints[2] = $this->calc3DPos($right, $bottom, $z1);
  923.         $this->iPoints[0] = $p1;
  924.         $this->iPoints[1] = $p3;
  925.         $this->iPoints[3] = $p2;
  926.  
  927.         if ($this->culling() > 0) {
  928.             if ($darkSides) {
  929.                 $this->internalApplyDark($oldColor, self::$DARKERCOLORQUANTITY);
  930.             }
  931.             $this->polygonFour(); // left-side
  932.         }
  933.  
  934.         $this->iPoints[0] = $p0;
  935.         $this->iPoints[1] = $this->calc3DPos($left, $top, $z1);
  936.         $this->iPoints[2] = $this->calc3DPos($left, $bottom, $z1);
  937.         $this->iPoints[3] = $this->calc3DPos($left, $bottom, $z0);
  938.  
  939.         $tmp = ($this->iPoints[3]->getX() - $this->iPoints[0]->getX()) *
  940.                      ($this->iPoints[1]->getY() - $this->iPoints[0]->getY()) -
  941.                      ($this->iPoints[1]->getX() - $this->iPoints[0]->getX()) *
  942.                      ($this->iPoints[3]->getY() - $this->iPoints[0]->getY());
  943.  
  944.         if ($tmp > 0) {
  945.             if ($darkSides) {
  946.                 $this->internalApplyDark($oldColor, self::$DARKERCOLORQUANTITY);
  947.             }
  948.             $this->polygonFour(); // right-side
  949.         }
  950.  
  951.         $this->iPoints[3] = $this->calc3DPos($left, $top, $z1);
  952.  
  953.         // culling
  954.         $tmp = ($p0->getX() - $p1->getX()) * ($p3->getY() - $p1->getY()) -
  955.             ($p3->getX() - $p1->getX()) * ($p0->getY() - $p1->getY());
  956.         if ($tmp > 0) {
  957.             $this->iPoints[0] = $p0;
  958.             $this->iPoints[1] = $p1;
  959.             $this->iPoints[2] = $p3;
  960.             if ($darkSides) {
  961.                 $this->internalApplyDark($oldColor, self::$DARKCOLORQUANTITY);
  962.             }
  963.             $this->polygonFour(); // top-side
  964.         }
  965.  
  966.         $this->iPoints[0] = $this->calc3DPos($left, $bottom, $z0);
  967.         $this->iPoints[2] = $this->calc3DPos($right, $bottom, $z1);
  968.         $this->iPoints[1] = $this->calc3DPos($left, $bottom, $z1);
  969.  
  970.         $this->iPoints[3] = $p2;
  971.         if ($this->culling() < 0) {
  972.             if ($darkSides) {
  973.                 $this->internalApplyDark($oldColor, self::$DARKCOLORQUANTITY);
  974.             }
  975.             $this->polygonFour();
  976.         }
  977.  
  978.         $this->brush->setColor($oldColor);
  979.         */
  980.     }
  981.  
  982.     /**
  983.      * Creates a cubic Windows GDI clipping region.
  984.      *
  985.      * @param rect Rectangle
  986.      * @param minZ int
  987.      * @param maxZ int
  988.      */
  989.     public function clipCube($rect$minZ$maxZ{
  990. /*
  991.         if ($this->is3D) {
  992.             if ($this->aspect->getElevation() == 270) {
  993.                 if (($this->aspect->getRotation() == 270) ||
  994.                     ($this->aspect->getRotation() == 360)) {
  995.                     $tmpLT = $this->calc3DPoint($rect->x, $rect->y, $minZ);
  996.                     $tmpRB = $this->calc3DPoint($rect->getRight(), $rect->y, $maxZ);
  997.                     $this->clipRectangle($tmpLT->x, $tmpLT->y, $tmpRB->x, $tmpRB->y);
  998.                     return;
  999.                 }
  1000.             }
  1001.  
  1002.             if ($this->isOrtho) {
  1003.                 if ($this->aspect->getOrthoAngle() > 90) {
  1004.                     $this->clipToLeft($rect, $minZ, $maxZ);
  1005.                 } else {
  1006.                     $this->clipToRight($rect, $minZ, $maxZ);
  1007.                 }
  1008.             } else
  1009.             if ($this->aspect->getRotation() >= 270) {
  1010.                 $this->clipToRight($rect, $minZ, $maxZ);
  1011.             }
  1012.         } else {
  1013.             $this->clipRectangle($rect->x + 1, $rect->y + 1, $rect->getRight() - 1,
  1014.                           $rect->getBottom() - 1);
  1015.         }
  1016.         */
  1017.     }
  1018.  
  1019.     private function culling({
  1020.         return (($this->iPoints[3]->getX($this->iPoints[2]->getX()) ($this->iPoints[1]->getY(-
  1021.             $this->iPoints[2]->getY())) (($this->iPoints[1]->getX($this->iPoints[2]->getX()) *
  1022.             ($this->iPoints[3]->getY($this->iPoints[2]->getY()));
  1023.     }
  1024.  
  1025.     /**
  1026.     * Creates and initialize the image
  1027.     * @access       protected
  1028.     */
  1029.     function createImage()
  1030.     {
  1031.        Ming_setScale(20.0000000);
  1032.        ming_useswfversion(6);
  1033.        $m new SWFMovie();
  1034.        $m->setRate(31);
  1035.        
  1036.        $m->setDimension($this->width,$this->height)
  1037.        $m->setBackground(220,220,220);
  1038.  
  1039.        //$i->setDepth(3);       
  1040.        
  1041.        $this->shape = new SWFShape()
  1042.        $sqfill $this->shape->addFill(000xff);
  1043.        //$this->shape->setRightFill($sqfill);       
  1044.        $m->add($this->shape);
  1045.        
  1046.        $this->img = $m;
  1047.        
  1048.  
  1049. /*    
  1050. $square = new SWFShape();
  1051.  
  1052. $sqfill = $square->addFill(0, 0, 0xff);
  1053. $square->setRightFill($sqfill);
  1054.  
  1055. $square->movePenTo(-250,-250);
  1056. $square->drawLineTo(250,-250);
  1057. $square->drawLineTo(250,250);
  1058. $square->drawLineTo(-250,250);
  1059. $square->drawLineTo(-250,-250);
  1060.  
  1061. //Now we can use that shape in a movie clip and define some actions:
  1062. $sqclip = new SWFSprite();
  1063. $i = $sqclip->add($square);
  1064. $i->setDepth(1);
  1065. $sqclip->setframes(25);
  1066. $sqclip->add(new SWFAction("stop();"));
  1067.  
  1068. $sqclip->nextFrame();
  1069. $sqclip->add(new SWFAction("play();"));
  1070.  
  1071. for($n=0; $n<24; $n++) {
  1072. $i->rotate(-15);
  1073.       $sqclip->nextFrame();
  1074. }
  1075.  
  1076. //Next we'll create another shape and use it for a button. Rather than create a separate shape for each button action (over, down, up, and release), I've created a function to automate drawing the shapes:
  1077. function rect($r, $g, $b)  {
  1078. $s = new SWFShape();
  1079. $s->setRightFill($s->addFill($r, $g, $b));
  1080. $s->drawLine(500,0);
  1081. $s->drawLine(0,500);
  1082. $s->drawLine(-500,0);
  1083. $s->drawLine(0,-500);
  1084. return $s;
  1085. }
  1086.  
  1087. $b = new SWFButton();
  1088. $b->addShape(rect(0xff, 0, 0), SWFBUTTON_UP | SWFBUTTON_HIT);
  1089. $b->addShape(rect(0, 0xff, 0), SWFBUTTON_OVER);
  1090. $b->addShape(rect(0, 0, 0xff), SWFBUTTON_DOWN);
  1091.  
  1092. $b->addAction(new SWFAction("setTarget('/box'); gotoandplay(2);"), SWFBUTTON_MOUSEDOWN);
  1093.  
  1094. //Next, we define the movie and place the movie clip (sprite) and the button in the movie itself:
  1095. $m = new SWFMovie();
  1096. $m->setDimension(4000,3000);
  1097.  
  1098. $m->setBackground(255,0,0);
  1099.  
  1100. $i = $m->add($sqclip);
  1101. $i->setDepth(3);
  1102. $i->moveTo(1650, 400);
  1103. $i->setName("box");
  1104.  
  1105. $i = $m->add($b);
  1106. $i->setDepth(2);
  1107. $i->moveTo(1400,900);
  1108.     
  1109. $this->img = $m;
  1110.  
  1111. */  
  1112.         return $this->img;
  1113.     }
  1114.  
  1115.     private function doBevelRect($rect$a$b{
  1116. /*        $topRight = new TeePoint($rect->getRight() - 1, $rect->y);
  1117.         $bottomLeft = new TeePoint($rect->x, $rect->getBottom() - 1);
  1118.         $bottomRight = new TeePoint($rect->getRight() - 1, $rect->getBottom() - 1);
  1119.  
  1120.         $this->___line($a, $rect->getLocation(), $topRight);
  1121.         $this->___line($a, $rect->getLocation(), $bottomLeft);
  1122.         $this->___line($b, $bottomLeft, $bottomRight);
  1123.         $this->___line($b, $bottomRight, $topRight);
  1124.         */
  1125.     }
  1126.  
  1127.     public function doRev({
  1128.         $black imagecolorallocate($this->img150150150);
  1129.         $x imagesx($this->img);
  1130.         $y imagesy($this->img)-6;
  1131.  
  1132.         $text "EVALUATION VERSION";
  1133.         $font_file ChartFont::$DEFAULTFAMILY;
  1134.         imagefttext($this->img254525$y+3$black$font_file$text);
  1135.     }
  1136.  
  1137.     /**
  1138.      * Draws an Ellipse bounding Rectangle r.
  1139.      *
  1140.      * @param Rectangle
  1141.      */
  1142.     public function ellipseRect($r{
  1143.         $this->ellipse($r->getX()$r->getY()$r->getRight()$r->getBottom());
  1144.     }
  1145.  
  1146.     /**
  1147.      * Ellipse bounding Rectangle r at z depth.
  1148.      *
  1149.      * @param Rectangle
  1150.      * @param int
  1151.      */
  1152.     public function ellipseRectZ($r$z{
  1153.         $this->ellipse($r->getX()$r->getY()$r->getRight()$r->getBottom()$z);
  1154.     }
  1155.  
  1156.     // DrawZone
  1157.     public function transparentEllipseZ($x1$y1$x2$y2$z{
  1158.         $p1 $this->calc3DPos($x1$y1$z);
  1159.         $p2 $this->calc3DPos($x2$y2$z);
  1160.         $this->transparentEllipsePoints($p1$p2);
  1161.     }
  1162.  
  1163.     protected function transparentEllipsePoints($p0$p1{
  1164.         $this->transparentEllipse($p0->getX()$p0->getY()$p1->getX()$p1->getY());
  1165.     }
  1166.  
  1167.     /**
  1168.      * Ellipse bounding Rect (X1,Y1,X2,Y2) at Z position at angle.
  1169.      *
  1170.      * @param x1 int
  1171.      * @param y1 int
  1172.      * @param x2 int
  1173.      * @param y2 int
  1174.      * @param int
  1175.      * @param angle double
  1176.  
  1177.      */
  1178.     public function ellipse($x1$y1$x2$y2$z=0$angle=0{
  1179. /*      if($z>0) {
  1180.         $p1 = $this->calc3DPos($x1, $y1, $z);
  1181.         $p2 = $this->calc3DPos($x2, $y2, $z);
  1182.         $this->ellipsePoints($p1,$p2);
  1183.        //  todo here draw directly the ellipse with p1 and p2 $this->ellipsePoints($p1, $p2);
  1184.       }
  1185.       else
  1186.       {
  1187.         if ($angle>0) {
  1188.         //  todo remove Point[] p = new Point[NUMCIRCLEPOINTS]; //       : Array[0..NumCirclePoints-1] of TPoint;
  1189.         $p = Array();
  1190.  
  1191.         $points = Array();
  1192.         for ($t = 0; $t < 3; $t++) {
  1193.             $points[$t] = new TeePoint();
  1194.         }
  1195.  
  1196.         $xCenter = ($x2 + $x1) * 0.5;
  1197.         $yCenter = ($y2 + $y1) * 0.5;
  1198.         $xRadius = ($x2 - $x1) * 0.5;
  1199.         $yRadius = ($y2 - $y1) * 0.5;
  1200.  
  1201.         $angle *= M_PI / 180.0;
  1202.  
  1203.         $tmpPiStep = 2 * M_PI / (self::$NUMCIRCLEPOINTS - 1);
  1204.  
  1205.         // initial rotation (rotation matrix elements)
  1206.         $tmpSinAngle = sin($angle);
  1207.         $tmpCosAngle = cos($angle);
  1208.  
  1209.         for ($t = 0; $t < self::$NUMCIRCLEPOINTS; $t++) {
  1210.             $tmpSin = sin($t * $tmpPiStep);
  1211.             $tmpCos = cos($t * $tmpPiStep);
  1212.             $tmpX = $xRadius * $tmpSin;
  1213.             $tmpY = $yRadius * $tmpCos;
  1214.  
  1215.             $p[$t] = new TeePoint(
  1216.                     MathUtils::round($xCenter +
  1217.                                           ($tmpX * $tmpCosAngle +
  1218.                                            $tmpY * $tmpSinAngle)),
  1219.                     MathUtils::round($yCenter +
  1220.                                           ( -$tmpX * $tmpSinAngle +
  1221.                                            $tmpY * $tmpCosAngle))
  1222.                    );
  1223.         }
  1224.  
  1225.         if ($this->getBrush()->getVisible()) {
  1226.             $old = $this->getPen()->getVisible();
  1227.             $this->getPen()->setVisible(false);
  1228.  
  1229.             $xc = MathUtils::round($xCenter);
  1230.             $yc = MathUtils::round($yCenter);
  1231.  
  1232.             for ($t = 1; $t < self::$NUMCIRCLEPOINTS; $t++) {
  1233.                 // has to be in loop because the Polygon
  1234.                 // transforms the positions from 3d to 2d in each pass
  1235.                 $points[0]->setX($xc);
  1236.                 $points[0]->setY($yc);
  1237.                 $points[1] = $p[$t - 1];
  1238.                 $points[2] = $p[$t];
  1239.                 $this->polygonz($z, $points);
  1240.             }
  1241.             // close it up with polygon from last to first
  1242.             $points[0]->setX($xc);
  1243.             $points[0]->setY($yc);
  1244.             $points[1] = $p[self::$NUMCIRCLEPOINTS - 1];
  1245.             $points[2] = $p[0];
  1246.             $this->polygonz($z, $points);
  1247.  
  1248.             $this->getPen()->setVisible($old);
  1249.         }
  1250.         if ($this->getPen()->getVisible()) {
  1251.             $this->polyLine($z, $p);
  1252.         }
  1253.         }
  1254.         else
  1255.         {
  1256.           $color = imagecolorallocate($this->img, $this->getBrush()->getColor()->red,
  1257.                                                   $this->getBrush()->getColor()->green,
  1258.                                                   $this->getBrush()->getColor()->blue);
  1259.  
  1260.           // updates x,y,width,height to be used in imagefilledellipse correctly
  1261.           $x1=$x1+(($x2-$x1) / 2);
  1262.           $y1=$y1+(($y2-$y1) / 2);
  1263.           $tmpWidth=($x2-$x1)*2;
  1264.           $tmpHeight=($y2-$y1)*2;
  1265.  
  1266.           if ($this->brush->getVisible()) {
  1267.             imagefilledellipse($this->img,$x1,$y1,$tmpWidth,$tmpHeight,$color);
  1268.           }
  1269.  
  1270.          if ($this->getPen()->getVisible()) {
  1271.             // Gets the pen color and style (dot , dashed, ...)
  1272.             $penColorStyle = $this->getPenColorStyle();
  1273.             imagesetstyle($this->img, $penColorStyle);
  1274.  
  1275.             // Assign the pen width for the image
  1276.             imagesetthickness ( $this->img, $this->pen->getWidth());
  1277.                         
  1278.             for ($i=0;$i<=$this->pen->getWidth();$i++)
  1279.               imageellipse($this->img,$x1,$y1,$tmpWidth+$i,$tmpHeight+$i,IMG_COLOR_STYLED);
  1280.           }
  1281.         }
  1282.       }
  1283.       */
  1284.     }
  1285.  
  1286.     public function ellipsePoints($p0$p1{
  1287.         $this->ellipse($p0->getX()$p0->getY()$p1->getX()$p1->getY());
  1288.     }
  1289.  
  1290.     /**
  1291.      * Ellipse bounding rectangle r with Z offset at angle.
  1292.      *
  1293.      * @param Rectangle
  1294.      * @param int
  1295.      * @param angle double
  1296.      */
  1297.     public function ellipseRectZAngle($r$z$angle=0{
  1298.         $this->ellipse($r->getX()$r->getY()$r->getWidth(),
  1299.             $r->getHeight()$z$angle)// $r->getRight(), $r->getBottom(), $z, $angle);
  1300.     }
  1301.  
  1302.     /**
  1303.      * Determines the Font Height to be used for outputted text when using the
  1304.      * Drawing.
  1305.      *
  1306.      * @param ChartFont
  1307.      * @return int 
  1308.      */
  1309.     public function fontTextHeight($f{
  1310.         return $this->textHeight($f"W");
  1311.     }
  1312.  
  1313.     public function initWindow($a$r$maxDepth{
  1314.         $this->bounds = new Rectangle($r->x,$r->y,$r->width,$r->height);
  1315.         $this->setAspect($a);
  1316.         $this->iZoomFactor 1;
  1317.  
  1318.         if ($this->is3D{
  1319.             if ($this->isOrtho{
  1320.                 $tmpAngle $this->aspect->getOrthoAngle();
  1321.                 if ($tmpAngle 90{
  1322.                     $this->iOrthoX = -1;
  1323.                     $tmpAngle 180 $tmpAngle;
  1324.                 else {
  1325.                     $this->iOrthoX 1;
  1326.                 }
  1327.  
  1328.                 $tmpSin sin($this->aspect->getOrthoAngle(*
  1329.                                          MathUtils::getPiStep());
  1330.                 $tmpCos cos($this->aspect->getOrthoAngle(*
  1331.                                          MathUtils::getPiStep());
  1332.                 $this->iOrthoY ($tmpCos 0.01$tmpSin $tmpCos;
  1333.             }
  1334.             $this->iZoomFactor 0.01 $this->aspect->getZoom();
  1335.             $this->iZoomText $this->aspect->getZoomText();
  1336.         }
  1337.  
  1338.         $this->calcTrigValues();
  1339.     }
  1340.  
  1341.     public function internalApplyDark($c$quantity{
  1342.         $this->brush->_applyDark($c$quantity);
  1343.     }
  1344.  
  1345.     /**
  1346.     * Draws a straight line
  1347.     *
  1348.     * @access       public
  1349.     * @param        integer         line start (X)
  1350.     * @param        integer         line start (Y)
  1351.     * @param        integer         line end (X)
  1352.     * @param        integer         line end (Y)
  1353.     * @param        Color           line color
  1354.     * @param        integer         line width
  1355.     */
  1356.  
  1357.     function line($x1$y1$x2$y2$color=null$width = -1)
  1358.     {
  1359.         /*if ($color==null)
  1360.         {
  1361.           $color = imagecolorallocate($this->img, $this->pen->getColor()->red,
  1362.           $this->pen->getColor()->green,
  1363.           $this->pen->getColor()->blue);
  1364.         }
  1365.         */
  1366. /*
  1367.         imageantialias($this->img,false);          
  1368.         // Gets the pen color and style (dot , dashed, ...)
  1369.         $penColorStyle = $this->getPenColorStyle();
  1370.         imagesetstyle($this->img, $penColorStyle);
  1371.       
  1372.         // Assign the pen width for the image
  1373.         // Set thickness. 
  1374.         if ($width==-1) {
  1375.           $width = $this->pen->getWidth();
  1376. //          if ($width < 2)
  1377. //            imageantialias($this->img,true);
  1378.  
  1379.           imagesetthickness ($this->img, $width);
  1380.         }
  1381.         else
  1382.         {
  1383. //          if ($width < 2)
  1384. //            imageantialias($this->img,true);
  1385.  
  1386.           imagesetthickness ($this->img, $width);
  1387.         }
  1388.                
  1389.         imageline($this->img, $x1, $y1, $x2, $y2, IMG_COLOR_STYLED);
  1390.   //      if ($width < 2)
  1391. //          imageantialias($this->img,false);
  1392.  
  1393.         imageantialias($this->img,true);
  1394.         */
  1395.         
  1396.  
  1397.         $this->shape->setLine($this->getPen()->getWidth(),
  1398.                     $this->pen->getColor()->red,
  1399.                     $this->pen->getColor()->green,
  1400.                     $this->pen->getColor()->blue);
  1401.  
  1402.         //$this->shape->setRightFill($this->shape->addFill(0xff, 0, 0));
  1403.                     
  1404.         $this->shape->movePenTo($x1,$y1);
  1405.         $this->shape->drawLineTo($x2,$y2);
  1406.         
  1407.     }
  1408.  
  1409.     /**
  1410.     * Draws a Line between co-ordinates with z depth offset.
  1411.     *
  1412.     * @param x0 int
  1413.     * @param y0 int
  1414.     * @param x1 int
  1415.     * @param y1 int
  1416.     * @param int
  1417.     */
  1418.     public function _line($x0$y0$x1$y1$z=0{
  1419.         $this->__line($this->calc3DPos($x0$y0$z)$this->calc3DPos($x1$y1$z));
  1420.     }
  1421.  
  1422.     /**
  1423.     * Draws a Line between point p0 and point p1.
  1424.     *
  1425.     * @param p0 Point is origin xy
  1426.     * @param p1 Point is destination xy
  1427.     */
  1428.     public function __line($p0$p1{
  1429.         $this->line($p0->getX()$p0->getY()$p1->getX()$p1->getY());
  1430.         // Move the mouse point
  1431.         $this->moveToXY($p1->getX(),$p1->getY());     // review
  1432.     }
  1433.  
  1434.     /**
  1435.     * Draws a Line between point p0 and point p1 using specific pen.
  1436.     *
  1437.     * @param pen ChartPen id the pen used
  1438.     * @param p0 Point is origin xy
  1439.     * @param p1 Point is destination xy
  1440.     */
  1441.     public function ___line($pen$p0$p1{
  1442.  
  1443.         $oldPen $this->getPen();
  1444.         $this->setPen($pen);
  1445.  
  1446.         // Gets the pen color and style (dot , dashed, ...)
  1447.         $penColorStyle $this->getPenColorStyle();
  1448.         // imagesetstyle($this->img, $penColorStyle);
  1449.  
  1450.         // Assign the pen width for the image
  1451.         // imagesetthickness ( $this->img, $this->pen->getWidth());
  1452.         
  1453.         $this->shape->setLine($this->getPen()->getWidth(),
  1454.                     $this->pen->getColor()->red,
  1455.                     $this->pen->getColor()->green,
  1456.                     $this->pen->getColor()->blue);
  1457.  
  1458.         //$this->shape->setRightFill($this->shape->addFill(0xff, 0, 0));
  1459.                     
  1460.         $this->shape->movePenTo($p0->getX(),$p0->getY());
  1461.         $this->shape->drawLineTo($p1->getX(),$p1->getY());
  1462.                 
  1463.         $this->setPen($oldPen);
  1464.     }
  1465.  
  1466.     /**
  1467.      * Draws a line to Point with z depth offset.
  1468.      *
  1469.      * @param Point
  1470.      * @param int
  1471.      */
  1472.     public function lineTo($p$z{
  1473.         $this->___lineTo($p->getX()$p->getY()$z);
  1474.     }
  1475.  
  1476.     /**
  1477.      * Draws a line to Point with z = 0 depth offset.
  1478.      *
  1479.      * @param Point
  1480.      */
  1481.     public function __lineTo($p{
  1482.         $this->line($this->moveToX$this->moveToY ,$p->getX()$p->getY());
  1483.  
  1484.         // Move the mouse point
  1485.         $this->moveToXY($p->getX(),$p->getY());
  1486.     }
  1487.  
  1488.     /**
  1489.      * Draws line from present position to end co-ordinates with z depth offset.
  1490.      *
  1491.      * @param int
  1492.      * @param int
  1493.      * @param int
  1494.      */
  1495.     public function ___lineTo($x$y$z=0{
  1496.         $this->__lineTo($this->calc3DPos($x$y$z));
  1497.     }
  1498.  
  1499.     /**
  1500.      * Draws a Line to 3D Point.
  1501.      *
  1502.      * @param Point3D
  1503.      */
  1504.     public function ____lineTo($p{
  1505.         $this->__lineTo($this->calc3DPos($p->getX()$p->getY()$p->getZ()));
  1506.     }
  1507.  
  1508.     /**
  1509.      * Draws line from present position to end co-ordinates with z depth offset.
  1510.      *
  1511.      * @param int
  1512.      * @param int
  1513.      */
  1514.     public function _____lineTo($x$y{
  1515.         $this->line($this->moveToX$this->moveToY ,$x$y);
  1516.         // Move the mouse point
  1517.         $this->moveToXY($x,$y);   // review
  1518.     }
  1519.  
  1520.     /**
  1521.      * Sets the value of PenPos to x and y co-ordinates  before calling LineTo.
  1522.      *
  1523.      * @param int
  1524.      * @param int
  1525.      */
  1526.     public function moveToXY($x$y{
  1527.         $this->moveToX=$x;
  1528.         $this->moveToY=$y;
  1529.     }
  1530.  
  1531.     /**
  1532.      * Sets the value of PenPos to Point p before calling LineTo.
  1533.      *
  1534.      * @param Point
  1535.      */
  1536.     public function moveTo($p{
  1537.         $this->moveToXY($p->getX()$p->getY());
  1538.     }
  1539.  
  1540.     /**
  1541.      * Sets the value of PenPos to x, y and z co-ordinates before calling
  1542.      * LineTo.
  1543.      *
  1544.      * @param int
  1545.      * @param int
  1546.      * @param int
  1547.      */
  1548.     public function moveToXYZ($x$y$z{
  1549.         $p $this->calc3DPos($x$y$z);
  1550.         $this->moveTo($p);
  1551.     }
  1552.  
  1553.     /**
  1554.      * Sets the value of PenPos to Point p  with z depth offset before calling
  1555.      * LineTo.
  1556.      *
  1557.      * @param Point
  1558.      * @param int
  1559.      */
  1560.     public function moveToZ($p$z{
  1561.         $p2 $this->calc3DPos($p->getX()$p->getY()$z);
  1562.         $this->moveTo($p2);
  1563.     }
  1564.  
  1565.     /**
  1566.      * Sets the value of PenPos  to 3D Point p before calling LineTo.
  1567.      *
  1568.      * @param Point3D
  1569.      */
  1570.     public function moveTo3D($p{
  1571.         $this->moveTo($this->calc3DPos($p->getX(),$p->getY()0));
  1572.     }
  1573.  
  1574.     /**
  1575.     * Draws a Line from (X,Y,Z0) to (X,Y,Z1).
  1576.     *
  1577.     * @param int
  1578.     * @param int
  1579.     * @param z0 int
  1580.     * @param z1 int
  1581.     */
  1582.     public function zLine($x$y$z0$z1{
  1583.         /*
  1584.         $c1 = imagecolorallocatealpha($this->img, $this->pen->getColor()->red,
  1585.             $this->pen->getColor()->green,
  1586.             $this->pen->getColor()->blue,
  1587.             $this->pen->getColor()->alpha);
  1588.         */
  1589.         $p1=$this->calc3DPos($x$y$z0);
  1590.         $p2=$this->calc3DPos($x$y$z1);
  1591.  
  1592.         /*
  1593.         imagesetthickness ( $this->img, $this->pen->getWidth());
  1594.         */
  1595.         
  1596.         $this->shape->setLine($this->getPen()->getWidth(),
  1597.                     $this->pen->getColor()->red,
  1598.                     $this->pen->getColor()->green,
  1599.                     $this->pen->getColor()->blue);
  1600.  
  1601.         //$this->shape->setRightFill($this->shape->addFill(0xff, 0, 0));                    
  1602.         
  1603.         $this->shape->movePenTo($p1->getX(),$p1->getY());
  1604.         $this->shape->drawLineTo($p2->getX(),$p2->getY());
  1605.         
  1606.     }
  1607.  
  1608.     /**
  1609.      * Draws a Horizontal at z depth position.
  1610.      *
  1611.      * @param left int
  1612.      * @param right int
  1613.      * @param int
  1614.      * @param int
  1615.      */
  1616.     public function horizontalLine($left$right$y$z=0{
  1617.         
  1618.         $p1=$this->calc3DPos($left$y$z);
  1619.         $p2=$this->calc3DPos($right$y$z);
  1620.                 
  1621.         $this->shape->setLine($this->getPen()->getWidth(),
  1622.                     $this->pen->getColor()->red,
  1623.                     $this->pen->getColor()->green,
  1624.                     $this->pen->getColor()->blue);
  1625.        
  1626.         //$this->shape->setRightFill($this->shape->addFill(0xff, 0, 0));       
  1627.         
  1628.         $this->shape->movePenTo($p1->getX(),$p1->getY());
  1629.         $this->shape->drawLineTo($p2->getX(),$p2->getY());                          
  1630.     }
  1631.  
  1632.     /**
  1633.      * Draws a Vertical Line from (X,Top) to (X,Bottom) at z depth position.
  1634.      *
  1635.      * @param int
  1636.      * @param top int
  1637.      * @param bottom int
  1638.      * @param int
  1639.      */
  1640.     public function verticalLine($x$top$bottom$z=0{        
  1641.         
  1642.         $p1=$this->calc3DPos($x$top$z);
  1643.         $p2=$this->calc3DPos($x$bottom$z);
  1644.  
  1645.         $this->shape->setLine($this->getPen()->getWidth(),
  1646.                     $this->pen->getColor()->red,
  1647.                     $this->pen->getColor()->green,
  1648.                     $this->pen->getColor()->blue);
  1649.        
  1650.         //$this->shape->setRightFill($this->shape->addFill(0xff, 0, 0));       
  1651.         
  1652.         $this->shape->movePenTo($p1->getX(),$p1->getY());
  1653.         $this->shape->drawLineTo($p2->getX(),$p2->getY());
  1654.     }
  1655.  
  1656.     /**
  1657.     * Draw a filled gray box with thick borders and darker corners.
  1658.     *
  1659.     * @param integer top left coordinate (x)
  1660.     * @param integer top left coordinate (y)
  1661.     * @param integer bottom right coordinate (x)
  1662.     * @param integer bottom right coordinate (y)
  1663.     * @param Color edge color
  1664.     * @param Color corner color
  1665.     */
  1666.     public function outlinedBox($x1$y1$x2$y2$color0$color1{
  1667. /*        if ($this->brush->getVisible()) {
  1668.             
  1669.             if ($this->getBrush()->getGradient()->getVisible()==true) {
  1670.             
  1671.                  $colA = array($this->getBrush()->getGradient()->getStartColor()->getRed(),
  1672.                    $this->getBrush()->getGradient()->getStartColor()->getGreen(),
  1673.                    $this->getBrush()->getGradient()->getStartColor()->getBlue());   
  1674.                  $colB = array($this->getBrush()->getGradient()->getEndColor()->getRed(),
  1675.                    $this->getBrush()->getGradient()->getEndColor()->getGreen(),
  1676.                    $this->getBrush()->getGradient()->getEndColor()->getBlue());
  1677.                        
  1678.                  $penWidth=$this->getPen()->getWidth();
  1679.                  Gradient::imagecolorgradient(
  1680.                    $this->img,
  1681.                    $x1+$penWidth, $y1+$penWidth, 
  1682.                    $x2-$penWidth, $y2,
  1683.                     $colA,$colB
  1684.                  );            
  1685.             }   
  1686.             else
  1687.             {                                         
  1688.               imagefilledrectangle($this->img, $x1, $y1, $x2, $y2, $color0->getColor($this->img));
  1689.             }
  1690.             imagerectangle($this->img, $x1, $y1, $x1 + 1, $y1 + 1, $color1->getColor($this->img));
  1691.             imagerectangle($this->img, $x2 - 1, $y1, $x2, $y1 + 1, $color1->getColor($this->img));
  1692.             imagerectangle($this->img, $x1, $y2 - 1, $x1 + 1, $y2, $color1->getColor($this->img));
  1693.             imagerectangle($this->img, $x2 - 1, $y2 - 1, $x2, $y2, $color1->getColor($this->img));            
  1694.         }
  1695.         */
  1696.     }
  1697.  
  1698.     public function paintBevel($bevel$rect$width$one$two{
  1699.         if ($bevel == BevelStyle::$RAISED{
  1700.             $a new ChartPen(null,$one);
  1701.             $b new ChartPen(null,$two);
  1702.         else {
  1703.             $a new ChartPen(null,$two);
  1704.             $b new ChartPen(null,$one);
  1705.         }
  1706.  
  1707.         $tmp $width;
  1708.         while ($tmp 0{
  1709.             $tmp--;
  1710.  
  1711.             $this->doBevelRect($rect$a$b);
  1712.             $rect->grow-1-1);
  1713.         }
  1714.     }
  1715.  
  1716.     /**
  1717.     * Draws a 3D Pie slice using start Angle and end Angle and donut percent.
  1718.     *
  1719.     * @param xCenter int
  1720.     * @param yCenter int
  1721.     * @param xRadius int
  1722.     * @param yRadius int
  1723.     * @param z0 int
  1724.     * @param z1 int
  1725.     * @param startAngle double
  1726.     * @param endAngle double
  1727.     * @param darkSides boolean
  1728.     * @param drawSides boolean
  1729.     * @param donutPercent int
  1730.     */
  1731. /*    public function pie($xCenter, $yCenter, $xRadius, $yRadius, $z0,
  1732.         $z1, $startAngle, $endAngle, $darkSides, $drawSides, $donutPercent=0) {
  1733.  
  1734.         if ($this->pie3D == null) {
  1735.             $this->pie3D = new Pie3D($this);
  1736.         }
  1737.         $this->pie3D->pie($xCenter, $yCenter, $xRadius, $yRadius, $z0, $z1, $startAngle,
  1738.                   $endAngle, $darkSides, $drawSides, $donutPercent);
  1739.     }
  1740. */
  1741.  
  1742.     public function pie($xCenter$yCenter$xOffset$yOffset$xRadius,
  1743.                     $yRadius$z0$z1$startAngle$endAngle,
  1744.                     $darkSides$drawSides$donutPercent,
  1745.                     $bevelPercent$edgeStyle$last/*, Shadow shadow*/)
  1746.     {
  1747.       if ($this->pie3D == null{
  1748.             $this->pie3D new Pie3D($this);
  1749.         }
  1750.       $this->pie3D->pie$xCenter $xOffset$yCenter $yOffset$xRadius,  $yRadius,  $z0,  $z1,
  1751.                  $startAngle,  $endAngle,  $darkSides,  $drawSides,
  1752.                  $donutPercent,  $bevelPercent$edgeStyle$last);
  1753.     }
  1754.  
  1755.  
  1756.     /**
  1757.      * Draws a vertical or horizontal Pyramid with optional dark shaded sides.
  1758.      *
  1759.      * @param vertical boolean
  1760.      * @param Rectangle
  1761.      * @param z0 int
  1762.      * @param z1 int
  1763.      * @param darkSides boolean
  1764.      */
  1765.     public function pyramidRect($vertical$r$z0$z1$darkSides{
  1766.         $this->pyramid($vertical$r->x$r->y$r->getRight()$r->getBottom()$z0$z1,
  1767.                 $darkSides);
  1768.     }
  1769.  
  1770.     /**
  1771.      * Draws a vertical or horizontal Pyramid with optional dark shaded sides.
  1772.      *
  1773.      * @param vertical boolean
  1774.      * @param left int
  1775.      * @param top int
  1776.      * @param right int
  1777.      * @param bottom int
  1778.      * @param z0 int
  1779.      * @param z1 int
  1780.      * @param darkSides boolean
  1781.      */
  1782.     public function pyramid($vertical$left$top$right$bottom$z0$z1$darkSides{
  1783. /*
  1784.         $oldColor = $this->brush->getSolid() ? $this->brush->getColor() : $this->getBackColor();
  1785.  
  1786.         if ($vertical) {
  1787.             if ($top != $bottom) {
  1788.                 $p0 = $this->calc3DPoint($left, $bottom, $z0);
  1789.                 $p1 = $this->calc3DPoint($right, $bottom, $z0);
  1790.                 $pTop = $this->calc3DPoint(($left + $right) / 2, $top, ($z0 + $z1) / 2);
  1791.                 $tmpArray = Array($p0, $pTop, $p1);
  1792.                 $this->polygon($tmpArray);
  1793.                 $p2 = $this->calc3DPoint($left, $bottom, $z1);
  1794.  
  1795.                 if ($top < $bottom) {
  1796.                     if ($p2->y < $pTop->y) {
  1797.                         $tmpArray = Array($p0, $pTop, $p2);
  1798.                         $this->polygon($tmpArray);                        
  1799.                     }
  1800.                 }
  1801.                 if ($darkSides) {
  1802.                     $this->internalApplyDark($oldColor, self::$DARKERCOLORQUANTITY);
  1803.                 }
  1804.  
  1805.                 $p3 = $this->calc3DPoint($right, $bottom, $z1);
  1806.                 $tmpArray = Array($p1, $pTop, $p3);
  1807.                 $this->polygon($tmpArray);                        
  1808.  
  1809.                 if (($top < $bottom) && ($p2->y < $pTop->y)) {
  1810.                     $tmpArray = Array($pTop, $p2, $p3);
  1811.                     $this->polygon($tmpArray);                        
  1812.                 }
  1813.             }
  1814.             if ($top >= $bottom) {
  1815.                 if ($darkSides) {
  1816.                     $this->internalApplyDark($oldColor, self::$DARKCOLORQUANTITY);
  1817.                 }
  1818.                 $this->rectangleY($left, $bottom, $right, $z0, $z1);
  1819.             }
  1820.         } else {
  1821.             if ($left != $right) {
  1822.                 $p0 = $this->calc3DPoint($left, $top, $z0);
  1823.                 $p1 = $this->calc3DPoint($left, $bottom, $z0);
  1824.                 $pTop = $this->calc3DPoint($right, ($top + $bottom) / 2, ($z0 + $z1) / 2);
  1825.                 $tmpArray = Array($p0, $pTop, $p1);
  1826.                 $this->polygon($tmpArray);                        
  1827.  
  1828.                 if ($darkSides) {
  1829.                     $this->internalApplyDark($oldColor, self::$DARKCOLORQUANTITY);
  1830.                 }
  1831.                 $p2 = $this->calc3DPoint($left, $top, $z1);
  1832.                 $tmpArray = Array($p0, $pTop, $p2);
  1833.                 $this->polygon($tmpArray);                        
  1834.             }
  1835.             if ($left >= $right) {
  1836.                 if ($darkSides) {
  1837.                     $this->internalApplyDark($oldColor, self::$DARKERCOLORQUANTITY);
  1838.                 }
  1839.                 $this->rectangleZ($left, $top, $bottom, $z0, $z1);
  1840.             }
  1841.         }
  1842.         */
  1843.     }
  1844.  
  1845.     /**
  1846.      * Sets / returns the color used to fill spaces when displaying text
  1847.      * or filling with brushes of different style other than bsSolid.<br>
  1848.      * Brush.Visible must be set to true.
  1849.      *
  1850.      * @return Color 
  1851.      */
  1852.     public function getBackColor({
  1853.         return $this->brush->getColor();
  1854.     }
  1855.  
  1856.     public function setBackColor($value{
  1857.         $this->brush->setColor($value);
  1858.     }
  1859.     
  1860.     /**
  1861.     * Draws a pyramid with a truncated apex of variable thickness.
  1862.     *
  1863.     * @param Rectangle $r 
  1864.     * @param int $startZ 
  1865.     * @param int $endZ 
  1866.     * @param int $truncX 
  1867.     * @param int $truncZ 
  1868.     */
  1869.  
  1870.     public function pyramidTrunc($r$startZ$endZ$truncX$truncZ{
  1871.         $p new InternalPyramidTrunc();
  1872.         $p->$r;
  1873.         $p->startZ $startZ;
  1874.         $p->endZ $endZ;
  1875.         $p->truncX $truncX;
  1876.         $p->truncZ $truncZ;
  1877.         $p->draw($this);
  1878.     }
  1879.  
  1880.     /**
  1881.     * Draws a polygon (Point p1, Point p2) at Z depth offset.
  1882.     *
  1883.     * @param p1 Point
  1884.     * @param p2 Point
  1885.     * @param z0 int
  1886.     * @param z1 int
  1887.     */
  1888.     public function plane($p1$p2$z0$z1{
  1889.         $this->iPoints[0$this->calc3DPos($p1->getX()$p1->getY()$z0);
  1890.         $this->iPoints[1$this->calc3DPos($p2->getX()$p2->getY()$z0);
  1891.         $this->iPoints[2$this->calc3DPos($p2->getX()$p2->getY()$z1);
  1892.         $this->iPoints[3$this->calc3DPos($p1->getX()$p1->getY()$z1);
  1893.         $this->polygonFour();
  1894.     }
  1895.  
  1896.     /**
  1897.     * Draws a polygon (Point p1, Point p2, Point p3, Point p4) at Z depth
  1898.     * offset.
  1899.     *
  1900.     * @param p1 Point
  1901.     * @param p2 Point
  1902.     * @param p3 Point
  1903.     * @param p4 Point
  1904.     * @param int
  1905.     */
  1906.     public function _plane($p1$p2$p3$p4$z{
  1907.         $this->iPoints[0$this->calc3DPos($p1->getX()$p1->getY()$z);
  1908.         $this->iPoints[1$this->calc3DPos($p2->getX()$p2->getY()$z);
  1909.         $this->iPoints[2$this->calc3DPos($p3->getX()$p3->getY()$z);
  1910.         $this->iPoints[3$this->calc3DPos($p4->getX()$p4->getY()$z);
  1911.         $this->polygonFour();
  1912.     }
  1913.  
  1914.     /**
  1915.     * Draws a polygon of  four points.
  1916.     *
  1917.     * @param z0 int
  1918.     * @param z1 int
  1919.     * @param Point[]
  1920.     */
  1921.     public function planeFour3D($z0$z1$p{
  1922.         $this->iPoints[0$this->calc3DPoint($p[0]->x$p[0]->y$z0);
  1923.         $this->iPoints[1$this->calc3DPoint($p[1]->x$p[1]->y$z0);
  1924.         $this->iPoints[2$this->calc3DPoint($p[2]->x$p[2]->y$z1);
  1925.         $this->iPoints[3$this->calc3DPoint($p[3]->x$p[3]->y$z1);
  1926.         $this->polygonFour();
  1927.     }
  1928.        
  1929.     public function polygon($points{
  1930.         if ($this->brush->getVisible()) {
  1931.                        
  1932.            $rfill=0;
  1933.            $gfill=0;
  1934.            $bfill=0;
  1935.            $afill=255;
  1936.  
  1937.            $routline=0;
  1938.            $goutline=0;
  1939.            $boutline=0;
  1940.            $width=0;
  1941.            $aoutline=255;
  1942.  
  1943.            $shape new SWFShape()
  1944.            $sqfill $shape->addFill(000xff);
  1945.            //$shape->setRightFill($sqfill);       
  1946.            $shape->movePenTo($points[0]->x,$points[0]->y);
  1947.        
  1948.            for($ipt=0;$ipt<sizeof($points);$ipt++)
  1949.               $shape->drawLineTo($points[$ipt]->x$points[$ipt]->y);
  1950.          
  1951.            $shape->drawLineTo($points[0]->x$points[0]->y);
  1952.  
  1953.            $this->img->add($shape);
  1954.         }
  1955.                        
  1956. /*                        
  1957.             $c1 = imagecolorallocatealpha($this->img, $this->getBrush()->getColor()->red,
  1958.               $this->getBrush()->getColor()->green,
  1959.               $this->getBrush()->getColor()->blue,
  1960.               $this->getBrush()->getTransparency());
  1961.  
  1962.              
  1963.             $p1 = imagecolorallocatealpha($this->img, $this->getPen()->getColor()->red,
  1964.               $this->getPen()->getColor()->green,
  1965.               $this->getPen()->getColor()->blue,
  1966.               $this->getPen()->getTransparency());
  1967.              
  1968.             $tmpArray2= Array();
  1969.  
  1970.             for ($tt=0;$tt < sizeof($points); $tt++) {
  1971.                  $tmpTeePointDouble =$points[$tt];
  1972.                  $tmpX=$tmpTeePointDouble->getX();
  1973.                  $tmpY=$tmpTeePointDouble->getY();
  1974.                  $tmpArray2[]=$tmpX;
  1975.                  $tmpArray2[]=$tmpY;
  1976.             }
  1977.                 
  1978.             if (count($tmpArray2) >= 3) {
  1979.                 imageantialias($this->img,true);
  1980.                 imagefilledpolygon($this->img, $tmpArray2, count($tmpArray2)/2, $c1);
  1981.                 imageantialias($this->img,false);
  1982.             }
  1983.             
  1984.             if ($this->getPen()->getVisible()) {
  1985.                 // Gets the pen color and style (dot , dashed, ...)
  1986.                 $penColorStyle = $this->getPenColorStyle();
  1987.                 imagesetstyle($this->img, $penColorStyle);
  1988.  
  1989.                 // Assign the pen width for the image
  1990.                 imagesetthickness ( $this->img, $this->pen->getWidth());
  1991.  
  1992.                 if (count($tmpArray2) >= 3) {
  1993.                    imageantialias($this->img,true);
  1994.                    imagepolygon($this->img, $tmpArray2, count($tmpArray2)/2, $p1);                   
  1995.                   imageantialias($this->img,false);
  1996.                 }
  1997.             }            
  1998.         }
  1999.         */
  2000.     }
  2001.  
  2002.     /**
  2003.      * Draws a polygon with z position offset.
  2004.      *
  2005.      * @param int
  2006.      * @param Point[]
  2007.      */
  2008.     public function polygonZ($z$p{
  2009.         for ($t 0$t sizeof($p)$t++{
  2010.             $p[$t$this->calc3DPoint($p[$t]->getX(),$p[$t]->getY()$z);
  2011.         }
  2012.         $this->polygon($p);
  2013.     }
  2014.  
  2015.     public function polygonPoints($p0$p1$p2{
  2016.         $p Array($p0$p1$p2);
  2017.         $this->polygon($p);
  2018.     }
  2019.  
  2020.  
  2021.     public function polygonFourDouble()
  2022.     {
  2023.         /*
  2024.         if ($this->brush->getVisible()) {
  2025.           $c1 = imagecolorallocatealpha($this->img, $this->getBrush()->getColor()->red,
  2026.               $this->getBrush()->getColor()->green,
  2027.               $this->getBrush()->getColor()->blue,
  2028.               $this->getBrush()->getTransparency());
  2029.  
  2030.             $p1 = imagecolorallocatealpha($this->img, $this->getPen()->getColor()->red,
  2031.               $this->getPen()->getColor()->green,
  2032.               $this->getPen()->getColor()->blue,
  2033.               $this->getPen()->getTransparency());
  2034.  
  2035.             $tmpArray2= Array();
  2036.  
  2037.             for ($tt=0;$tt < count($this->iPointDoubles); $tt++) {
  2038.                $tmpTeePoint =$this->iPointDoubles[$tt];
  2039.                  $tmpX=$tmpTeePoint->getX();
  2040.                  $tmpY=$tmpTeePoint->getY();
  2041.                  $tmpArray2[]=$tmpX;
  2042.                  $tmpArray2[]=$tmpY;
  2043.             }
  2044.  
  2045.             if (count($tmpArray2) >= 3) {
  2046.                 imageantialias($this->img,true);
  2047.                 imagefilledpolygon($this->img, $tmpArray2, count($tmpArray2)/2, $c1);
  2048.                 imageantialias($this->img,false);
  2049.             }
  2050.         }
  2051.  
  2052.         if ($this->getPen()->getVisible()) {
  2053.           // Gets the pen color and style (dot , dashed, ...)
  2054.           $penColorStyle = $this->getPenColorStyle();
  2055.           imagesetstyle($this->img, $penColorStyle);
  2056.  
  2057.           // Assign the pen width for the image
  2058.           imagesetthickness ( $this->img, $this->pen->getWidth());
  2059.  
  2060.             if (count($tmpArray2) >= 3) {
  2061.                 imageantialias($this->img,true);
  2062.                 imagepolygon($this->img, $tmpArray2, count($tmpArray2)/2, $p1);
  2063.                 imageantialias($this->img,false);
  2064.             }
  2065.         }
  2066.         */
  2067.     }
  2068.  
  2069.     private function polygonFour({
  2070.         /*
  2071.         $tmpArray2= Array();
  2072.         if ($this->brush->getVisible()) {
  2073.  
  2074.           $c1 = imagecolorallocatealpha($this->img, $this->getBrush()->getColor()->red,
  2075.               $this->getBrush()->getColor()->green,
  2076.               $this->getBrush()->getColor()->blue,
  2077.               $this->getBrush()->getTransparency());
  2078.  
  2079.             $p1 = imagecolorallocatealpha($this->img, $this->getPen()->getColor()->red,
  2080.               $this->getPen()->getColor()->green,
  2081.               $this->getPen()->getColor()->blue,
  2082.               $this->getPen()->getTransparency());              
  2083.  
  2084.  
  2085.             for ($tt=0;$tt < count($this->iPoints); $tt++) {
  2086.                  $tmpTeePoint =$this->iPoints[$tt];
  2087.                  $tmpX=$tmpTeePoint->getX();
  2088.                  $tmpY=$tmpTeePoint->getY();
  2089.                  $tmpArray2[]=$tmpX;
  2090.                  $tmpArray2[]=$tmpY;
  2091.             }
  2092.  
  2093.             if (count($tmpArray2) >= 3) {
  2094.                 imageantialias($this->img,true);
  2095.                 imagefilledpolygon($this->img, $tmpArray2, count($tmpArray2)/2, $c1);
  2096.                 imageantialias($this->img,false);
  2097.             }
  2098.         }
  2099.  
  2100.         if ($this->getPen()->getVisible()) {
  2101.           // Gets the pen color and style (dot , dashed, ...)
  2102.           $penColorStyle = $this->getPenColorStyle();
  2103.           imagesetstyle($this->img, $penColorStyle);
  2104.  
  2105.           // Assign the pen width for the image
  2106.           imagesetthickness ( $this->img, $this->pen->getWidth());
  2107.  
  2108.             if (count($tmpArray2) >= 3) {
  2109.                 imageantialias($this->img,true);
  2110.                 imagepolygon($this->img, $tmpArray2, count($tmpArray2)/2, $p1);
  2111.                 imageantialias($this->img,false);
  2112.             }
  2113.         }
  2114.         */
  2115.     }
  2116.  
  2117.     /**
  2118.      * Draws a series of line segments to join point array p at z displacement.
  2119.      *
  2120.      * @param int
  2121.      * @param Point[]
  2122.      */
  2123.     public function polyLine($z$p{
  2124.         $l sizeof($p);
  2125.         $tmpP Array()//new Point[l];
  2126.         for ($t 0$t $l$t++{
  2127.             $tmpP[$t$this->calc3DPoint($p[$t]->getX(),$p[$t]->getY()$z);
  2128.         }
  2129.         for ($t 1$t $l$t++{
  2130.             $this->line($tmpP[$t 1]->getX(),$tmpP[$t 1]->getY(),
  2131.                 $tmpP[$t]->getX(),$tmpP[$t]->getY());
  2132.         }
  2133.     }
  2134.  
  2135.     /**
  2136.     * Print text.
  2137.     *
  2138.     * @param Image GD image
  2139.     * @param integer text coordinate (x)
  2140.     * @param integer text coordinate (y)
  2141.     * @param Color text color
  2142.     * @param string text value
  2143.     * @param string font file name
  2144.     * @param bitfield text alignment
  2145.     */
  2146.     public function printText($img$px$py$text$align = -1{
  2147.  
  2148.         
  2149.         $font=$this->getFont();
  2150.         $color $font->getBrush()->getColor();
  2151.  
  2152.         $fontFileName $font->getName();
  2153.  
  2154.         if ($align==-1{
  2155.            $align $this->getTextAlign();
  2156.         }
  2157.  
  2158.         $fontSize $font->getFontSize();
  2159.         $lineSpacing 1;
  2160.  
  2161.         $textWidth =  $this->textWidth($text)//  $lrx - $llx;
  2162.         $textHeight $this->textHeight($text)//  $fontSize; // $lry - $ury;
  2163.         $angle 0;
  2164.         
  2165.         if (in_array(StringAlignment::$HORIZONTAL_CENTER_ALIGN$align)) {
  2166.             $px -= $textWidth 2;
  2167.         }
  2168.         else
  2169.         if (in_array (StringAlignment::$HORIZONTAL_RIGHT_ALIGN$align)) {
  2170.             $px -= $textWidth;
  2171.         }
  2172.         /*
  2173.         if (in_array (StringAlignment::$VERTICAL_CENTER_ALIGN, $align)) {
  2174.             $py += $textHeight - 3;
  2175.         }
  2176.         */
  2177.         /*if (in_array (StringAlignment::$VERTICAL_TOP_ALIGN, $align)) {
  2178.             $py += $textHeight;
  2179.         }*/
  2180.  
  2181.         /*
  2182.         else
  2183.         if (in_array (StringAlignment::$VERTICAL_BOTTOM_ALIGN, $align)) {
  2184.             $py += $textHeight + 3;
  2185.         }
  2186.  
  2187.         imagettftext($img, $fontSize, $angle, $px, $py, $color->getColor($img),
  2188.             $fontFileName, $text);
  2189.             */
  2190.             
  2191. //        $f = new SWFFont($fontFileName); 
  2192.         $f new SWFFont('Arial')
  2193.         $t new SWFTextField()
  2194.         $t->setFont($f)
  2195.         $t->addString($text)
  2196.         $t->setColor($font->getBrush()->getColor()->getRed(),$font->getBrush()->getColor()->getGreen(),
  2197.            $font->getBrush()->getColor()->getBlue()$font->getBrush()->getColor()->getAlpha());
  2198.         //$t->setHeight($fontSize);
  2199.         //$p -> remove($i); 
  2200.  
  2201.         $text $this->img->add($t)
  2202.         $text->moveTo($px$py);
  2203.     }
  2204.  
  2205.     /**
  2206.     * Print text centered horizontally on the image.
  2207.     *
  2208.     * @param Image GD image
  2209.     * @param integer text coordinate (y)
  2210.     * @param Color text color
  2211.     * @param string text value
  2212.     * @param string font file name
  2213.     */
  2214.     public function printCentered($img$py$color$text$fontFileName{
  2215.           $tmpAlign Array(StringAlignment::$HORIZONTAL_CENTER_ALIGN,StringAlignment::$VERTICAL_CENTER_ALIGN);
  2216.           $this->printText($imgimagesx($img2$py$color$text$fontFileName,
  2217.               $tmpAlign);
  2218.     }
  2219.  
  2220.     /**
  2221.     * Print text in diagonal.
  2222.     *
  2223.     * @param Image GD image
  2224.     * @param integer text coordinate (x)
  2225.     * @param integer text coordinate (y)
  2226.     * @param Color text color
  2227.     * @param string text value
  2228.     */
  2229.     public function printDiagonal($img$px$py$text$angle{
  2230. /*
  2231.         $font=$this->getFont();
  2232.         $fontSize = $font->getFontSize();
  2233.         $fontFileName = $font->getName();
  2234.         $color = $font->getBrush()->getColor(); //  $this->textColor;
  2235.         $lineSpacing = 1;
  2236.  
  2237.         list ($lx, $ly, $rx, $ry) = imageftbbox($fontSize, 0, $fontFileName,
  2238.             strtoupper($text), array("linespacing" => $lineSpacing));
  2239.  
  2240.         $textWidth = $rx - $lx;
  2241.  
  2242.         imagettftext($img, $fontSize, $angle, $px, $py, $color->getColor($img),
  2243.             $fontFileName, $text);
  2244.             */
  2245.     }
  2246.  
  2247.     /**
  2248.      * Internal use. Calculates the projection co-ordinates for rectangle
  2249.      * Bounds.<br>
  2250.      *
  2251.      * @param maxDepth int is the max shape depth
  2252.      * @param Rectangle is the projected shape rectangle
  2253.      */
  2254.     public function projection($maxDepth$r{
  2255.         $this->xCenter ($r->($r->width 0.5$this->getRotationCenter()->x);
  2256.         $this->yCenter ($r->($r->height 0.5$this->getRotationCenter()->y);
  2257.         $this->zCenter (($maxDepth 0.5$this->getRotationCenter()->z);
  2258.         $this->xCenterOffset $this->xCenter $this->aspect->getHorizOffset();
  2259.         $this->yCenterOffset $this->yCenter $this->aspect->getVertOffset();
  2260.  
  2261.         $this->calcPerspective($r);
  2262.     }
  2263.  
  2264.     public function rectangle($rect,$animations=null{
  2265.         
  2266.         if ($this->getBrush()->getVisible()) {
  2267.             
  2268.           /*  $c1 = imagecolorallocatealpha($this->img, $this->getBrush()->getColor()->red,
  2269.               $this->getBrush()->getColor()->green,
  2270.               $this->getBrush()->getColor()->blue,
  2271.               $this->getBrush()->getTransparency());
  2272.           */   
  2273.             if ($this->getBrush()->getGradient()->getVisible()==true{
  2274.                  /*
  2275.                  $colA = array($this->getBrush()->getGradient()->getStartColor()->getRed(),
  2276.                    $this->getBrush()->getGradient()->getStartColor()->getGreen(),
  2277.                    $this->getBrush()->getGradient()->getStartColor()->getBlue());   
  2278.                  $colB = array($this->getBrush()->getGradient()->getEndColor()->getRed(),
  2279.                    $this->getBrush()->getGradient()->getEndColor()->getGreen(),
  2280.                    $this->getBrush()->getGradient()->getEndColor()->getBlue());
  2281.                        
  2282.                  $penWidth=$this->getPen()->getWidth();
  2283.                  Gradient::imagecolorgradient(
  2284.                    $this->img,
  2285.                    $rect->getX()+$penWidth, $rect->getY()+$penWidth, 
  2286.                    $rect->getRight()-$penWidth, $rect->getHeight()-$penWidth+$rect->getY(),
  2287.                    $colA,
  2288.                    $colB
  2289.                  );  */          
  2290.             }   
  2291.             else
  2292.             
  2293.               $shape new SWFShape();
  2294.               $penColor $this->getPen()->getColor();
  2295.               $shape->setLine($this->getPen()->getWidth(),$penColor->getRed()$penColor->getGreen()$penColor->getBlue());
  2296.               
  2297.               $brush $this->getBrush()->getColor();
  2298.               //$shape->setRightFill($shape->addFill($brush->getRed(),$brush->getGreen(),$brush->getBlue()));
  2299.               
  2300.               $shape->movePenTo($rect->x,$rect->y);                            
  2301.               $shape->drawLineTo($rect->getRight(),$rect->y);
  2302.               $shape->drawLineTo($rect->getRight(),$rect->getBottom());
  2303.               $shape->drawLineTo($rect->x,$rect->getBottom());
  2304.               $shape->drawLineTo($rect->x,$rect->y);                            
  2305.                             
  2306.               if (sizeof($animations)>0)
  2307.               {
  2308.                  for ($i=0;$i<sizeof($animations);$i++)   
  2309.                  {
  2310.                     //Now we can use that shape in a movie clip and define some actions:
  2311.                     $sqclip new SWFSprite();
  2312.                     $i $sqclip->add($shape);
  2313.                     $i->setDepth(1);
  2314.                     $sqclip->setframes(155);
  2315.                     $sqclip->add(new SWFAction("stop();"));
  2316.  
  2317.                     $sqclip->nextFrame();
  2318.                     $sqclip->add(new SWFAction("play();"));
  2319.  
  2320.                     for($n=0$n<24$n++{
  2321.                         $i->rotate(-1);
  2322.                         $sqclip->nextFrame();
  2323.                     }
  2324.  
  2325.                     //Next we'll create another shape and use it for a button. Rather than create a separate shape for each button action (over, down, up, and release), I've created a function to automate drawing the shapes:
  2326.                     function rect($r$g$b)  {
  2327.                         $s new SWFShape();
  2328.                         $s->setRightFill($s->addFill($r$g$b));
  2329.                         $s->drawLine(50,0);
  2330.                         $s->drawLine(0,50);
  2331.                         $s->drawLine(-50,0);
  2332.                         $s->drawLine(0,-50);
  2333.                         return $s;
  2334.                     }
  2335.  
  2336.                     $b new SWFButton();
  2337.                     $b->addShape(rect(0xff00)SWFBUTTON_UP SWFBUTTON_HIT);
  2338.                     $b->addShape(rect(00xff0)SWFBUTTON_OVER);
  2339.                     $b->addShape(rect(000xff)SWFBUTTON_DOWN);
  2340.  
  2341.                     $b->addAction(new SWFAction("setTarget('/box'); gotoandplay(2);")SWFBUTTON_MOUSEDOWN);
  2342.  
  2343.                     //Next, we define the movie and place the movie clip (sprite) and the button in the movie itself:
  2344.                     //$m = new SWFMovie();
  2345.                     //$m->setDimension(4000,3000);
  2346.  
  2347.                     //$m->setBackground(255,0,0);
  2348.  
  2349.                     $i $this->img->add($sqclip);
  2350.                     $i->setDepth(3);
  2351.                     //$i->moveTo(10, 10);
  2352.                     $i->setName("box");
  2353.  
  2354.                     $i $this->img->add($b);
  2355.                     $i->setDepth(2);
  2356.                    // $i->moveTo(10,10);
  2357.                  }
  2358.               }
  2359.  
  2360.               //$this->img->add($shape);
  2361.             }
  2362.         }
  2363.  
  2364.         // Gradient  // TODO post the code into the shape..
  2365. /*        if ($this->getBrush()->getGradient()->getVisible()==true) {
  2366.             $this->getBrush()->getGradient()->fill($this->img,
  2367.             $this->getBrush()->getGradient()->getDirection(),
  2368.             $this->getBrush()->getGradient()->getStartColor(),
  2369.             $this->getBrush()->getGradient()->getEndColor());
  2370.             
  2371.         }   */
  2372.  
  2373.         
  2374.         /*
  2375.         if ($this->getPen()->getVisible()) {
  2376.           // Gets the pen color and style (dot , dashed, ...)
  2377.           $penColorStyle = $this->getPenColorStyle();
  2378.           imagesetstyle($this->img, $penColorStyle);
  2379.  
  2380.           // Assign the pen width for the image
  2381.           imagesetthickness ( $this->img, $this->pen->getWidth());
  2382.           imagerectangle($this->img, $rect->x, $rect->y, $rect->getRight(),
  2383.               $rect->getBottom(), IMG_COLOR_STYLED); 
  2384.           }      
  2385.           */  
  2386.     }
  2387.  
  2388.     public function _rectangle($x$y$width$height{
  2389.         $this->rectangle(new Rectangle($x,$y,$width.$height));
  2390.     }
  2391.  
  2392.     /**
  2393.      * Horizontal Rectangle from Left to Right, from Z0 to Z1 position,
  2394.      * at Top Y.<br>
  2395.      *
  2396.      * @param left int
  2397.      * @param top int
  2398.      * @param bottom int
  2399.      * @param z0 int
  2400.      * @param z1 int
  2401.      */
  2402.     public function rectangleZ($left$top$bottom$z0$z1{
  2403.         $this->iPoints[0$this->calc3DPos($left$top$z0);
  2404.         $this->iPoints[1$this->calc3DPos($left$top$z1);
  2405.         $this->iPoints[2$this->calc3DPos($left$bottom$z1);
  2406.         $this->iPoints[3$this->calc3DPos($left$bottom$z0);
  2407.         $this->polygonFour();
  2408.     }
  2409.  
  2410.     public function rectangleWithZ($r$z{
  2411.         $this->iPoints[0$this->calc3DPos($r->x$r->y$z);
  2412.         $this->iPoints[1$this->calc3DPos($r->getRight()$r->y$z);
  2413.         $this->iPoints[2$this->calc3DPos($r->getRight()$r->getBottom()$z);
  2414.         $this->iPoints[3$this->calc3DPos($r->x$r->getBottom()$z);
  2415.         $this->polygonFour();
  2416.     }
  2417.  
  2418.     /**
  2419.      * Horizontal Rectangle from Left to Right, from Z0 to Z1 position,
  2420.      * at Top Y.<br>
  2421.      *
  2422.      * @param left int
  2423.      * @param top int
  2424.      * @param right int
  2425.      * @param z0 int
  2426.      * @param z1 int
  2427.      */
  2428.     public function rectangleY($left$top$right$z0$z1{
  2429.         $this->iPoints[0$this->calc3DPos($left$top$z0);
  2430.         $this->iPoints[1$this->calc3DPos($right$top$z0);
  2431.         $this->iPoints[2$this->calc3DPos($right$top$z1);
  2432.         $this->iPoints[3$this->calc3DPos($left$top$z1);
  2433.         $this->polygonFour();
  2434.     }
  2435.  
  2436.     // With this function you will draw rounded corners rectangles with transparent colors.
  2437.     // Empty (not filled) figures are allowed too!!
  2438.  
  2439.     function roundrectangle($x1$y1$x2$y2$radius$filled=1{
  2440.     /*
  2441.       $color = imagecolorallocate($this->img, $this->getBrush()->getColor()->red,
  2442.             $this->getBrush()->getColor()->green,
  2443.             $this->getBrush()->getColor()->blue);
  2444.  
  2445.       if ($filled==1){
  2446.         if ($this->getBrush()->getVisible()) {
  2447.           imagefilledrectangle($this->img, $x1+$radius, $y1, $x2-$radius, $y2, $color);
  2448.           imagefilledrectangle($this->img, $x1, $y1+$radius, $x1+$radius-1, $y2-$radius, $color);
  2449.           imagefilledrectangle($this->img, $x2-$radius+1, $y1+$radius, $x2, $y2-$radius, $color);
  2450.  
  2451.           imagefilledarc($this->img,$x1+$radius, $y1+$radius, $radius*2, $radius*2, 180 , 270, $color, IMG_ARC_PIE);
  2452.           imagefilledarc($this->img,$x2-$radius, $y1+$radius, $radius*2, $radius*2, 270 , 360, $color, IMG_ARC_PIE);
  2453.           imagefilledarc($this->img,$x1+$radius, $y2-$radius, $radius*2, $radius*2, 90 , 180, $color, IMG_ARC_PIE);
  2454.           imagefilledarc($this->img,$x2-$radius, $y2-$radius, $radius*2, $radius*2, 360 , 90, $color, IMG_ARC_PIE);
  2455.         }
  2456.       }else{
  2457.         imageline($this->img, $x1+$radius, $y1, $x2-$radius, $y1, $color);
  2458.         imageline($this->img, $x1+$radius, $y2, $x2-$radius, $y2, $color);
  2459.         imageline($this->img, $x1, $y1+$radius, $x1, $y2-$radius, $color);
  2460.         imageline($this->img, $x2, $y1+$radius, $x2, $y2-$radius, $color);
  2461.  
  2462.         imagearc($this->img,$x1+$radius, $y1+$radius, $radius*2, $radius*2, 180 , 270, $color);
  2463.         imagearc($this->img,$x2-$radius, $y1+$radius, $radius*2, $radius*2, 270 , 360, $color);
  2464.         imagearc($this->img,$x1+$radius, $y2-$radius, $radius*2, $radius*2, 90 , 180, $color);
  2465.         imagearc($this->img,$x2-$radius, $y2-$radius, $radius*2, $radius*2, 360 , 90, $color);
  2466.       }
  2467.       */
  2468.     }
  2469.  
  2470.     function drawRoundedBorders($shapeBorders,$backcolor,$forecolor{        
  2471.       /*
  2472.             $sourcefile_width=imagesx($this->img);
  2473.             $sourcefile_height=imagesy($this->img);
  2474.             $background = imagecreatetruecolor($sourcefile_width,$sourcefile_height);
  2475.  
  2476.             if ($backcolor==null) {
  2477.                 $backcolor = new Color(0,0,0,127);  //  transparent
  2478.             }
  2479.             if ($forecolor==null) {
  2480.                 $forecolor = new Color(0,0,0,127);  // transparent
  2481.             }
  2482.  
  2483.             if ($shapeBorders->getTopLeft()->getBorderRound() > 0) {
  2484.  
  2485.                 $endsize=$shapeBorders->getTopLeft()->getBorderRound();;
  2486.                 $startsize=$endsize*3-1;
  2487.                 $arcsize=$startsize*2+1;
  2488.  
  2489.                 imagecopymerge($background, $this->img, 0, 0, 0, 0, $sourcefile_width, $sourcefile_height, 100);
  2490.                 $startx=$sourcefile_width*2-1;
  2491.                 $starty=$sourcefile_height*2-1;
  2492.                 $im_temp = imagecreatetruecolor($startx,$starty);
  2493.                 imagecopyresampled($im_temp, $background, 0, 0, 0, 0, $startx, $starty, $sourcefile_width, $sourcefile_height);
  2494.                 $bg = imagecolorallocate($im_temp,$backcolor->red,$backcolor->green, $backcolor->blue);
  2495.                 $fg = imagecolorallocate($im_temp,$forecolor->red,$forecolor->green, $forecolor->blue);
  2496.  
  2497.                 imagearc($im_temp, $startsize, $startsize, $arcsize, $arcsize, 180,270,$fg);
  2498.                 imagefilltoborder($im_temp,0,0,$fg,$bg);
  2499.                 imagecopyresampled($this->img, $im_temp, 0, 0, 0, 0, $sourcefile_width,$sourcefile_height,$startx, $starty);
  2500.                 imagedestroy($im_temp);
  2501.             }
  2502.  
  2503.             if ($shapeBorders->getBottomLeft()->getBorderRound() > 0) {
  2504.  
  2505.                 $endsize=$shapeBorders->getBottomLeft()->getBorderRound();;
  2506.                 $startsize=$endsize*3-1;
  2507.                 $arcsize=$startsize*2+1;
  2508.  
  2509.                 imagecopymerge($background, $this->img, 0, 0, 0, 0, $sourcefile_width, $sourcefile_height, 100);
  2510.                 $startx=$sourcefile_width*2-1;
  2511.                 $starty=$sourcefile_height*2-1;
  2512.                 $im_temp = imagecreatetruecolor($startx,$starty);
  2513.                 imagecopyresampled($im_temp, $background, 0, 0, 0, 0, $startx, $starty, $sourcefile_width, $sourcefile_height);
  2514.                 $bg = imagecolorallocate($im_temp,$backcolor->red,$backcolor->green, $backcolor->blue);
  2515.                 $fg = imagecolorallocate($im_temp,$forecolor->red,$forecolor->green, $forecolor->blue);
  2516.  
  2517.                 imagearc($im_temp, $startsize, $starty-$startsize,$arcsize, $arcsize, 90,180,$fg);
  2518.                 imagefilltoborder($im_temp,0,$starty,$fg,$bg);
  2519.                 imagecopyresampled($this->img, $im_temp, 0, 0, 0, 0, $sourcefile_width,$sourcefile_height,$startx, $starty);
  2520.                 imagedestroy($im_temp);
  2521.             }
  2522.  
  2523.             if ($shapeBorders->getTopRight()->getBorderRound() > 0) {
  2524.  
  2525.                 $endsize=$shapeBorders->getTopRight()->getBorderRound();;
  2526.                 $startsize=$endsize*3-1;
  2527.                 $arcsize=$startsize*2+1;
  2528.  
  2529.                 imagecopymerge($background, $this->img, 0, 0, 0, 0, $sourcefile_width, $sourcefile_height, 100);
  2530.                 $startx=$sourcefile_width*2-1;
  2531.                 $starty=$sourcefile_height*2-1;
  2532.                 $im_temp = imagecreatetruecolor($startx,$starty);
  2533.                 imagecopyresampled($im_temp, $background, 0, 0, 0, 0, $startx, $starty, $sourcefile_width, $sourcefile_height);
  2534.                 $bg = imagecolorallocate($im_temp,$backcolor->red,$backcolor->green, $backcolor->blue);
  2535.                 $fg = imagecolorallocate($im_temp,$forecolor->red,$forecolor->green, $forecolor->blue);
  2536.  
  2537.                 imagearc($im_temp, $startx-$startsize, $startsize,$arcsize, $arcsize, 270,360,$fg);
  2538.                 imagefilltoborder($im_temp,$startx,0,$fg,$bg);
  2539.                 imagecopyresampled($this->img, $im_temp, 0, 0, 0, 0, $sourcefile_width,$sourcefile_height,$startx, $starty);
  2540.                 imagedestroy($im_temp);
  2541.             }
  2542.  
  2543.             if ($shapeBorders->getBottomRight()->getBorderRound() > 0) {
  2544.  
  2545.                 $endsize=$shapeBorders->getBottomRight()->getBorderRound();;
  2546.                 $startsize=$endsize*3-1;
  2547.                 $arcsize=$startsize*2+1;
  2548.  
  2549.                 imagecopymerge($background, $this->img, 0, 0, 0, 0, $sourcefile_width, $sourcefile_height, 100);
  2550.                 $startx=$sourcefile_width*2-1;
  2551.                 $starty=$sourcefile_height*2-1;
  2552.                 $im_temp = imagecreatetruecolor($startx,$starty);
  2553.                 imagecopyresampled($im_temp, $background, 0, 0, 0, 0, $startx, $starty, $sourcefile_width, $sourcefile_height);
  2554.                 $bg = imagecolorallocate($im_temp,$backcolor->red,$backcolor->green, $backcolor->blue);
  2555.                 $fg = imagecolorallocate($im_temp,$forecolor->red,$forecolor->green, $forecolor->blue);
  2556.  
  2557.                 imagearc($im_temp, $startx-$startsize, $starty-$startsize,$arcsize, $arcsize, 0,90,$fg);
  2558.                 imagefilltoborder($im_temp,$startx,$starty,$fg,$bg);
  2559.                 imagecopyresampled($this->img, $im_temp, 0, 0, 0, 0, $sourcefile_width,$sourcefile_height,$startx, $starty);
  2560.                 imagedestroy($im_temp);
  2561.             }
  2562.  
  2563.             imagedestroy($background);
  2564.             */
  2565.     }
  2566.  
  2567.     /**
  2568.      * Draws a triangle (point p0, pointp1, pointp2) at Z position.
  2569.      *
  2570.      * @param p0 Point
  2571.      * @param p1 Point
  2572.      * @param p2 Point
  2573.      * @param int
  2574.      */
  2575.     public function triangle($p0$p1$p2$z=0{
  2576.         $p0 $this->calc3DPoint($p0->getX()$p0->getY()$z);
  2577.         $p1 $this->calc3DPoint($p1->getX()$p1->getY()$z);
  2578.         $p2 $this->calc3DPoint($p2->getX()$p2->getY()$z);
  2579.         $this->polygonPoints($p0$p1$p2);
  2580.     }
  2581.     
  2582.     public function arc($x1,$y1,$x2,$y2,$startAngle$sweepAngle,$filled=0{
  2583.         /*
  2584.       $color = imagecolorallocate($this->img, $this->getBrush()->getColor()->red,
  2585.             $this->getBrush()->getColor()->green,
  2586.             $this->getBrush()->getColor()->blue);
  2587.  
  2588.             
  2589.       if ($filled==1){
  2590.         if ($this->getBrush()->getVisible()) {
  2591.           imagefilledarc($this->img,$x1, $y1, $x2-$x1, $y2-$y1, $startAngle , $endAngle, $color, IMG_ARC_PIE);
  2592.         }
  2593.       }else{
  2594.         imagearc($this->img,$x1, $y1, $x2-$x1, $y2-$y1, $startAngle, $endAngle, $color);
  2595.       }
  2596.       */
  2597.     }
  2598.  
  2599.  
  2600.     /**
  2601.      * Draws a triangle (Triangle3D p).
  2602.      *
  2603.      * @param Triangle3D
  2604.      *   Todo
  2605.     public void triangle(Triangle3D p) {
  2606.         Point[] tmp = {calc3DPoint(p.p0), calc3DPoint(p.p1), calc3DPoint(p.p2)};
  2607.         polygon(tmp);
  2608.     }       */
  2609.  
  2610.  
  2611.     /**
  2612.      * Draws a rotated text String at the specified x,y and z coordinates with
  2613.      * the RotDegree rotation angle.<br>
  2614.      * RotDegree values must be between 0 and 360.<br>
  2615.      * The string is drawn on the Chart Drawing Canvas.
  2616.      *
  2617.      * @param int
  2618.      * @param int
  2619.      * @param int
  2620.      * @param text String
  2621.      * @param rotDegree double
  2622.      */
  2623.     public function rotateLabel($x$y$z$text$rotDegree{
  2624.         // TODO z param is not considred for the moment
  2625.         $this->printDiagonal($this->img,$x,$y,$text,$rotDegree);
  2626.     }
  2627.  
  2628.     /**
  2629.      * Draws a rotated text String at the specified Point x,y coordinates with
  2630.      * the RotDegree rotation angle.<br>
  2631.      * RotDegree values must be between 0 and 360.<br>
  2632.      * The string is drawn on the Chart Drawing Canvas.
  2633.      *
  2634.      * @param Point
  2635.      * @param text String
  2636.      * @param rotDegree double
  2637.      */
  2638.     public function _rotateLabel($p$text$rotDegree{
  2639.         $this->rotateLabel($p->getX()$p->getY()$text$rotDegree);
  2640.     }
  2641.  
  2642.     public function rotateRectangle($r$angle{
  2643.          $tmpCenter $r->center();
  2644.          $tmpMathUtils new MathUtils();
  2645.          $tmp $angle MathUtils::getPiStep();
  2646.          $tmpSin sin($tmp);
  2647.          $tmpCos cos($tmp);
  2648.  
  2649.          $tmpRect $r;
  2650.          $tmpRect->offset-$tmpCenter->x-$tmpCenter->y);
  2651.  
  2652.          $result Array();
  2653.          $result[0$this->rotatePoint($tmpRect->x$tmpRect->y$tmpCenter$tmpCos$tmpSin);
  2654.          $result[1$this->rotatePoint($tmpRect->getRight()$tmpRect->y$tmpCenter,
  2655.                                 $tmpCos,
  2656.                                 $tmpSin);
  2657.          $result[2$this->rotatePoint($tmpRect->getRight()$tmpRect->getBottom(),
  2658.                                 $tmpCenter,
  2659.                                 $tmpCos$tmpSin);
  2660.          $result[3$this->rotatePoint($tmpRect->x$tmpRect->getBottom()$tmpCenter,
  2661.                                 $tmpCos,
  2662.                                 $tmpSin);
  2663.  
  2664.         return $result;
  2665.     }
  2666.  
  2667.     private function rotatePoint($ax$ay$tmpCenter$tmpCos$tmpSin{
  2668.          $p new TeePoint();
  2669.          $p->$tmpCenter->+ (int)($ax $tmpCos $ay $tmpSin);
  2670.          $p->$tmpCenter->+ (int)-$ax $tmpSin $ay $tmpCos);
  2671.  
  2672.          return $p;
  2673.     }
  2674.  
  2675.     public function sliceArray($source$length{
  2676.         $result Array();
  2677.         for ($t 0$t $length$t++{
  2678.             $result[$t$source[$t];
  2679.         }
  2680.         return $result;
  2681.     }
  2682.  
  2683.     /**
  2684.      * Displays the 2D non-rotated label at the specified X Y screen
  2685.      * coordinates.<br>
  2686.      * Text is outputted to the correct internal drawing Graphics2D. <br>
  2687.      * The X and Y coordinates must be valid and fit inside the Chart
  2688.      * rectangle. It uses the current drawing Font attributes. <br>
  2689.      * Writes text at the named x and y co-ordinates.
  2690.      *
  2691.      * @param int
  2692.      * @param int
  2693.      * @param int
  2694.      * @param text String
  2695.      */
  2696.     public function textOut($x$y$z$text$align=-1{
  2697.         $f $this->getFont();
  2698.  
  2699.         if ($z <> 0{
  2700.             $p $this->calc3DPos($x$y$z);
  2701.  
  2702.             /* TODO style of font
  2703.             if (($this->iZoomText) && ($this->iZoomFactor != -1)) {
  2704.                 (double) $old = $this->font->getDrawingFont()->getSize();
  2705.                 (int) $tmp = (int) max(1, $this->iZoomFactor * $old);
  2706.                 if ($old != $tmp) {
  2707.                     $this->font->setSize($tmp);
  2708.                 }
  2709.             }
  2710.             */
  2711.  
  2712.             $x $p->getX();
  2713.             $y $p->getY();
  2714.         }
  2715.  
  2716.         /* TODO text shadow
  2717.         if ($f->shouldDrawShadow()) {
  2718.             $s = $f->getShadow();
  2719.             $this->drawString(x + s.getWidth(), y + s.getHeight(), text, s.getBrush());
  2720.         }
  2721.         */
  2722.         if ($align==-1{
  2723.            $align $this->getTextAlign();
  2724.         }
  2725.  
  2726.         $this->printText($this->img$x$y$text$align)//, $f->getBrush());
  2727.     }
  2728.  
  2729.     /**
  2730.      * Returns the vertical text size in pixels of ChartFont f.
  2731.      *
  2732.      * @param ChartFont
  2733.      * @param text String
  2734.      * @return int Height in pixels of ChartFont f.
  2735.      */
  2736.     public function _textHeight($f$text{
  2737.         return imagefontheight($f->getFontSize());
  2738.     }
  2739.  
  2740.     /**
  2741.      * Returns the horizontal text size in pixels of ChartFont f.
  2742.      *
  2743.      * @param ChartFont
  2744.      * @param text String
  2745.      * @return int Width in pixels of ChartFont f.
  2746.      */
  2747.     public function textWidth($text$f=null{
  2748.        if ($f==null)
  2749.            $f=$this->font;
  2750.  
  2751.        $lineSpacing 1;
  2752.  
  2753.        list ($llx$lly$lrx$lry$urx$ury$ulx$ulyimageftbbox($f->getFontSize(),
  2754.                0$f->getName()strtoupper($text)array("linespacing" => $lineSpacing));
  2755.  
  2756.        $width $lrx $llx;
  2757.  
  2758.        return round($width);
  2759.     }
  2760.  
  2761.     /**
  2762.      * Returns the vertical size in pixels of the text String.
  2763.      *
  2764.      * @param text String
  2765.      * @return int Height in pixels of the text String.
  2766.      */
  2767.     public function textHeight($text{
  2768.         return $this->_textHeight($this->font$text);
  2769.     }
  2770.  
  2771.     /**
  2772.      * Calculates the boundary points of the convex hull of a set of 2D xy
  2773.      * points.&nbsp;Original
  2774.      *
  2775.      * @param Point[]
  2776.      * @return int 
  2777.      */
  2778.     public function convexHull($p{
  2779.         if (sizeof($p== 3{
  2780.             return 3;
  2781.         else if (sizeof($p3{
  2782.             return 0;
  2783.         else {
  2784.             // find pivot point, which is known to be on the hull
  2785.             // point with lowest y - if there are multiple, point with highest x
  2786.             $lminY 10000000;
  2787.             $lmaxX 10000000;
  2788.             $lpivotIndex 0;
  2789.  
  2790.             $lbound 0;
  2791.  
  2792.             $ubound sizeof($p1;
  2793.             $tmpubound $ubound 1;
  2794.  
  2795.             for ($lIndex $lbound$lIndex <= $ubound$lIndex++{
  2796.                 if ($p[$lIndex]->getY(== $lminY{
  2797.                     if ($p[$lIndex]->getX($lmaxX{
  2798.                         $lmaxX $p[$lIndex]->getX();
  2799.                         $lpivotIndex $lIndex;
  2800.                     }
  2801.                 else if ($p[$lIndex]->getY($lminY{
  2802.                     $lminY $p[$lIndex]->getY();
  2803.                     $lmaxX $p[$lIndex]->getX();
  2804.                     $lpivotIndex $lIndex;
  2805.                 }
  2806.             }
  2807.  
  2808.             // put pivot into seperate variable and remove from array
  2809.             $lPivot $p[$lpivotIndex];
  2810.             $p[$lpivotIndex$p[$ubound];
  2811.  
  2812.             // calculate angle to pivot for each point in the array
  2813.             // quicker to calculate dot product of point with a horizontal comparison vector
  2814.             $langles Array();  // Array of doubles
  2815.             //double[] langles = new double[tmpubound + 1];
  2816.  
  2817.             for ($lindex 0$lindex <= $tmpubound$lindex++{
  2818.                 $lvx $lPivot->getX($p[$lindex]->getX();
  2819.                 $lvy $lPivot->getY($p[$lindex]->getY();
  2820.  
  2821.                 // reduce to a unit-vector - length 1
  2822.                 $tmp sqrt($lvx $lvx $lvy $lvy);
  2823.                 $langles[$lindex($tmp == 00.0 $lvx $tmp;
  2824.             }
  2825.  
  2826.             // sort the points by angle
  2827.             self::quickSortAngle($p$langles0$tmpubound);
  2828.  
  2829.             // step through array to remove points that are not part of the convex hull
  2830.             $t 1;
  2831.             $lrightturn true;
  2832.  
  2833.             do {
  2834.                 // assign points behind and infront of current point
  2835.                 if ($t == 0{
  2836.                     $lrightturn true;
  2837.                 else {
  2838.                     $lBehind $p[$t 1];
  2839.                     $lInFront ($t == $tmpubound$lPivot $p[$t 1];
  2840.  
  2841.                     // work out if we are making a right or left turn using vector product
  2842.                     $lrightturn (($lBehind->getX($p[$t]->getX()) ($lInFront->getY($p[$t]->getY())) -
  2843.                                  (($lInFront->getX($p[$t]->getX()) ($lBehind->getY($p[$t]->getY())) 0;
  2844.                 }
  2845.  
  2846.                 if ($lrightturn{
  2847.                     $t++;
  2848.                 else {
  2849.                     $tmphigh $tmpubound;
  2850.                     // remove point from convex hull
  2851.                     if ($t != $tmphigh{
  2852.                         for ($i $t$i $tmphigh$i++{
  2853.                             $p[$i$p[$i 1];
  2854.                         }
  2855.                     }
  2856.                     $tmpubound $tmphigh 1;
  2857.                     $t--// backtrack to previous point
  2858.                 }
  2859.             while ($t != $tmpubound);
  2860.  
  2861.             // add pivot back into points array
  2862.             $tmpubound++;
  2863.             $p[$tmpubound$lPivot;
  2864.             return $tmpubound 1;
  2865.         }
  2866.     }
  2867.  
  2868.     /**
  2869.      * Sort an array of points by angles.
  2870.      *
  2871.      * @param Point[]
  2872.      * @param angles double[]
  2873.      * @param low int
  2874.      * @param high int
  2875.      */
  2876.     static private function quickSortAngle($p$angles$low$high{
  2877.         $lo $low;
  2878.         $hi $high;
  2879.         $midangle $angles[($lo $hi2];
  2880.  
  2881.         do {
  2882.             while ($angles[$lo$midangle{
  2883.                 $lo++;
  2884.             while ($angles[$hi$midangle{
  2885.                 $hi--;
  2886.             }
  2887.             if ($lo <= $hi{
  2888.                 // swap points
  2889.                 $tpoint $p[$lo];
  2890.                 $p[$lo$p[$hi];
  2891.                 $p[$hi$tpoint;
  2892.                 // swap angles
  2893.                 $tangle $angles[$lo];
  2894.                 $angles[$lo$angles[$hi];
  2895.                 $angles[$hi$tangle;
  2896.                 $lo++;
  2897.                 $hi--;
  2898.             }
  2899.         while ($lo <= $hi);
  2900.  
  2901.         // perform quicksorts on subsections
  2902.         if ($hi $low{
  2903.             self::quickSortAngle($p$angles$low$hi);
  2904.         }
  2905.         if ($lo $high{
  2906.             self::quickSortAngle($p$angles$lo$high);
  2907.         }
  2908.     }
  2909.  
  2910.  
  2911.     /**************************************************************************
  2912.     * Gets and Sets methods.....                                              *
  2913.     **************************************************************************/
  2914.  
  2915.     private function setAspect($value{
  2916.         $this->aspect = $value;
  2917.         $this->is3D $this->aspect->getView3D();
  2918.         $this->isOrtho $this->aspect->getOrthogonal();
  2919.     }
  2920.  
  2921.     /**
  2922.      * Determines the kind of brush used to fill the Canvas draw rectangle
  2923.      * background.<BR>
  2924.      * The Brush.Visible method must be set to true.
  2925.      *
  2926.      * @return ChartBrush 
  2927.      */
  2928.     public function getBrush({
  2929.         if ($this->brush==null)
  2930.            $this->brush=new ChartBrush(null);
  2931.  
  2932.         return $this->brush;
  2933.     }
  2934.  
  2935.     /**
  2936.      * Determines the kind of brush used to fill the Canvas draw rectangle
  2937.      * background.<BR>
  2938.      * The Brush.Visible method must be set to true.
  2939.      *
  2940.      * @param value ChartBrush
  2941.      */
  2942.     public function setBrush($value{
  2943.         if ($value!=null)
  2944.           $this->getBrush()->assign($value);
  2945.         else
  2946.           $this->brush=null;
  2947.     }
  2948.  
  2949.     /**
  2950.      * Returns a color from global ColorPalette array variable.
  2951.      *
  2952.      * @param index int
  2953.      * @return Color 
  2954.      */
  2955.     public function getDefaultColor($index{
  2956.         return $this->colorPalette[$index sizeof($this->colorPalette)];
  2957.     }
  2958.  
  2959.     /**
  2960.      * Specifies a color from global ColorPalette array variable.
  2961.      *
  2962.      * @param palette Color[]
  2963.      */
  2964.     public function setColorPalette($palette{
  2965.         $this->colorPalette=$palette;
  2966.         
  2967.         //$colorPalette = Array(); //sizeof($palette.length)];
  2968. /*        for ($t = 0; $t < sizeof($palette); $t++) {
  2969.             $this->colorPalette[$t] = $palette[$t];                        
  2970.         }
  2971.         
  2972.         $this->getChart()->doBaseInvalidate();
  2973.   */    
  2974.         $this->getChart()->doBaseInvalidate();                                             
  2975.     }
  2976.     
  2977.     // Return integer
  2978.     public function getColorPaletteLength({
  2979.         return sizeof($this->colorPalette);
  2980.     }
  2981.  
  2982.     public function getDirty({
  2983.         return false;
  2984.     }
  2985.  
  2986.     public function setDirty($value{}
  2987.  
  2988.     /**
  2989.      * Determines the Font for outputted text when using the Drawing Canvas.
  2990.      *
  2991.      * @return ChartFont 
  2992.      */
  2993.     public function getFont({
  2994.         return $this->font;
  2995.     }
  2996.  
  2997.     /**
  2998.      * Determines the Font for outputted text when using the Drawing Canvas.
  2999.      *
  3000.      * @param value ChartFont
  3001.      */
  3002.     public function setFont($value{
  3003.         $this->font->assign($value);
  3004.     }
  3005.  
  3006.     /**
  3007.      * Defines the Height of the Font in pixels.
  3008.      *
  3009.      * @return int 
  3010.      */
  3011.     public function getFontHeight({
  3012.         return $this->textHeight("W");
  3013.     }
  3014.  
  3015.     public function setGraphics($value{
  3016.        $this->GraphicsGD=$value;
  3017.     }
  3018.  
  3019.     public function getMetafiling({
  3020.         return $this->metafiling;
  3021.     }
  3022.  
  3023.     public function setMetafiling($value{
  3024.         $this->metafiling = $value;
  3025.     }
  3026.  
  3027.     public function getMonochrome({
  3028.         return $this->monochrome;
  3029.     }
  3030.  
  3031.     /**
  3032.      * Gets / Sets the alignment used when displaying text using TextOut or TextOut3D.
  3033.      * <br>
  3034.      * Default value: Near
  3035.      *
  3036.      * @param value StringAlignment
  3037.      */
  3038.  
  3039.     public function getTextAlign({
  3040.         return $this->stringFormat->alignment;
  3041.     }
  3042.  
  3043.     public function setTextAlign($value{
  3044.           if (is_array($value)){
  3045.             $this->stringFormat->alignment=$value;
  3046.           }
  3047.           else {
  3048.            $this->stringFormat->alignment=Array($value);
  3049.           }
  3050.     }
  3051.  
  3052.     /**
  3053.      * Indicates the kind of pen used to draw Canvas lines.
  3054.      *
  3055.      * @return ChartPen 
  3056.      */
  3057.     public function getPen({
  3058.         return $this->pen;
  3059.     }
  3060.  
  3061.     /**
  3062.      * Determines the kind of pen used to draw Canvas lines.
  3063.      *
  3064.      * @param value ChartPen
  3065.      */
  3066.     public function setPen($value{
  3067.         if ($value!=null)
  3068.           $this->pen->assign($value);
  3069.     }
  3070.  
  3071.     private function getPenColorStyle({
  3072.         
  3073.         $penColor imagecolorallocatealpha($this->img,
  3074.                     $this->pen->getColor()->red,
  3075.                     $this->pen->getColor()->green,
  3076.                     $this->pen->getColor()->blue,
  3077.                     $this->pen->getColor()->alpha);
  3078.                                 
  3079.         switch ($this->pen->getStyle()) {
  3080.             case 1// DOT
  3081.                 return array($penColor,IMG_COLOR_TRANSPARENT);
  3082.                 break;
  3083.             case 2// DASH
  3084.                 return array($penColor,$penColor,IMG_COLOR_TRANSPARENT,IMG_COLOR_TRANSPARENT,IMG_COLOR_TRANSPARENT);
  3085.                 break;
  3086.             case 3// DASHDOT
  3087.                 return array($penColor,$penColor,IMG_COLOR_TRANSPARENT,$penColor);
  3088.                 break;
  3089.             case 4// DASHDOTDOT
  3090.                 return array($penColor,$penColor,IMG_COLOR_TRANSPARENT,$penColor,IMG_COLOR_TRANSPARENT,$penColor);
  3091.                 break;            
  3092.             default:  // SOLID value 0
  3093.                 return array($penColor);
  3094.                 break;
  3095.         }
  3096.     }
  3097.  
  3098.     /**
  3099.      * Sets the Pixel location (using X,Y,Z) of the centre of rotation for use
  3100.      * with the Aspect Rotation and Elevation properties.<br>
  3101.      *
  3102.      * @return Point3D 
  3103.      */
  3104.     public function getRotationCenter({
  3105.         return $this->rotationCenter;
  3106.     }
  3107.  
  3108.  
  3109.     /**
  3110.      * Returns the bounding rectangle for a given array of XY points.
  3111.      *
  3112.      * @param num int
  3113.      * @param Point[]
  3114.      * @return Rectangle 
  3115.      */
  3116.     public function rectFromPolygon($num$p{
  3117.         $r new Rectangle($p[0]->getX()$p[0]->getY()00);
  3118.  
  3119.         for ($t 1$t $num$t++{
  3120.             if ($p[$t]->getX($r->getX()) {
  3121.                 $r->setX($p[$t]->getX());
  3122.             else
  3123.             if ($p[$t]->getX($r->getRight()) {
  3124.                 $r->setWidth($p[$t]->getX($r->getX());
  3125.             }
  3126.  
  3127.             if ($p[$t]->getY($r->getY()) {
  3128.                 $r->setY($p[$t]->getY());
  3129.             else
  3130.             if ($p[$t]->getY($r->getBottom()) {
  3131.                 $r->setHeight($p[$t]->getY($r->getY());
  3132.             }
  3133.         }
  3134.  
  3135.         $r->width++;
  3136.         $r->height++;
  3137.  
  3138.         return $r;
  3139.     }
  3140.  
  3141.     /**
  3142.      * Obsolete.&nbsp;Please use Rectangle.<!-- -->Contains method.
  3143.      *
  3144.      * @param rect Rectangle
  3145.      * @param int
  3146.      * @param int
  3147.      * @return boolean 
  3148.      */
  3149.     static public function pointInRect($rect$x$y{
  3150.         return $rect->contains($x$y);
  3151.     }
  3152.  
  3153.     /**
  3154.      * Returns true if point P is inside the vert triangle of x0y0, midxY1,
  3155.      * x1y0.
  3156.      *
  3157.      * @param Point
  3158.      * @param x0 int
  3159.      * @param x1 int
  3160.      * @param y0 int
  3161.      * @param y1 int
  3162.      * @return boolean 
  3163.      */
  3164.     static public function pointInTriangle($p$x0$x1$y0$y1{
  3165.         $tmp Array(new TeePoint($x0$y0)new TeePoint(($x0 $x12$y1),
  3166.                       new TeePoint($x1$y0));
  3167.  
  3168.         return $this->pointInPolygon($p$tmp);
  3169.     }
  3170.  
  3171.     /**
  3172.      * Returns true if point P is inside the horizontal triangle.
  3173.      *
  3174.      * @param Point
  3175.      * @param y0 int
  3176.      * @param y1 int
  3177.      * @param x0 int
  3178.      * @param x1 int
  3179.      * @return boolean 
  3180.      */
  3181.     static public function pointInHorizTriangle($p$y0$y1$x0$x1{
  3182.         $tmp Array(new TeePoint($x0$y0)new TeePoint($x1($y0 $y12),
  3183.                       new TeePoint($x0$y1));
  3184.         return $this->pointInPolygon($p$tmp);
  3185.     }
  3186.  
  3187.     /// <summary>
  3188.     /// Returns point "ATo" minus ADist pixels from AFrom point.
  3189.     /// </summary>
  3190.     static public function pointAtDistance($From$To$distance)
  3191.     {
  3192.       (int)$px $To->getX();
  3193.       (int)$py $To->getY();
  3194.  
  3195.       if ($To->getX(!= $From->getX())
  3196.       {
  3197.         $angle atan2($To->getY($From->getY()$To->getX($From->getX());
  3198.         $tmpsin sin($angle);
  3199.         $tmpcos cos($angle);
  3200.         $px -= MathUtils::round($distance $tmpcos);
  3201.         $py -= MathUtils::round($distance $tmpsin);
  3202.       }
  3203.       else
  3204.       {
  3205.         if ($To->getY($From->getY()) $py += $distance;
  3206.         else $py -= $distance;
  3207.       }
  3208.       return new TeePoint($px$py);
  3209.     }
  3210.  
  3211.     /**
  3212.      * Returns true if point P is inside the ellipse bounded by Left, Top,
  3213.      * Right, Bottom.
  3214.      *
  3215.      * @param Point
  3216.      * @param left int
  3217.      * @param top int
  3218.      * @param right int
  3219.      * @param bottom int
  3220.      * @return boolean 
  3221.      */
  3222.     static public function _pointInEllipse($p$left$top$right$bottom{
  3223.         return $this->pointInEllipse($pRectangle::fromLTRB($left$top$right$bottom));
  3224.     }
  3225.  
  3226.     /**
  3227.      * Returns true if point P is inside the ellipse bounded by Rect.
  3228.      *
  3229.      * @param Point
  3230.      * @param rect Rectangle
  3231.      * @return boolean 
  3232.      */
  3233.     static public function pointInEllipse($p$rect{
  3234.         $tmp $rect->center();
  3235.         $tmpWidth = (int) sqr($tmp->getX($rect->getX());
  3236.         $tmpHeight = (int) sqr($tmp->getY($rect->getY());
  3237.  
  3238.         return ($tmpWidth != 0&& ($tmpHeight != 0&&
  3239.                 ((sqr($p->getX($tmp->getX()) $tmpWidth+
  3240.                  (sqr($p->getY($tmp->getY()) $tmpHeight<= 1
  3241.                 );
  3242.     }
  3243.  
  3244.     /**
  3245.      * Returns true if point P is inside Poly polygon.
  3246.      *
  3247.      * @param Point
  3248.      * @param poly Point[]
  3249.      * @return boolean 
  3250.      */
  3251.     static public function pointInPolygon($p$poly{
  3252.         $result false;
  3253.         (int)$j sizeof($poly1;
  3254.         (int)$tmp $j;
  3255.  
  3256.         for ($i 0$i <= $tmp$i++{
  3257.             if ((((($poly[$i]->getY(<= $p->getY()) && ($p->getY($poly[$j]->getY())) ||
  3258.                   (($poly[$j]->getY(<= $p->getY()) && ($p->getY($poly[$i]->getY()))) &&
  3259.                  ($p->getX(($poly[$j]->getX($poly[$i]->getX()) ($p->getY($poly[$i]->getY())
  3260.                   / ($poly[$j]->getY($poly[$i]->getY()) $poly[$i]->getX()))) {
  3261.                 $result !$result;
  3262.             }
  3263.             $j $i;
  3264.         }
  3265.  
  3266.         return $result;
  3267.     }
  3268.  
  3269.     // Returns boolean
  3270.     protected function getIZoomfactor({
  3271.         return $this->iZoomFactor;
  3272.     }
  3273.  
  3274.     protected function setIZoomfactor($value{
  3275.         $this->iZoomFactor $value;
  3276.     }
  3277.  
  3278.     /**
  3279.      * The X coordinate of the pixel location of the center of the 3D
  3280.      * Canvas.<br>
  3281.      * The origin of the pixel coordinate system is in the top left corner of
  3282.      * the parent window.
  3283.      *
  3284.      * @return int 
  3285.      */
  3286.     public function getXCenter({
  3287.         return $this->xCenter;
  3288.     }
  3289.  
  3290.     /**
  3291.      * Specifies the X coordinate of the pixel location of the center of the 3D
  3292.      * Canvas.<br>
  3293.      * The origin of the pixel coordinate system is in the top left corner of
  3294.      * the parent window.
  3295.      *
  3296.      * @param value int
  3297.      */
  3298.     public function setXCenter($value{
  3299.         $this->xCenter $value;
  3300.     }
  3301.  
  3302.     /**
  3303.      * The Y coordinate of the pixel location of the center of the 3D
  3304.      * Canvas.<br>
  3305.      * The origin of the pixel coordinate system is in the top left corner of
  3306.      * the parent window.
  3307.      *
  3308.      * @return int 
  3309.      */
  3310.     public function getYCenter({
  3311.         return $this->yCenter;
  3312.     }
  3313.  
  3314.     /**
  3315.      * Specifies the Y coordinate of the pixel location of the center of the 3D
  3316.      * Canvas.<br>
  3317.      * The origin of the pixel coordinate system is in the top left corner of
  3318.      * the parent window.
  3319.      *
  3320.      * @param value int
  3321.      */
  3322.     public function setYCenter($value{
  3323.         $this->yCenter $value;
  3324.     }
  3325.  
  3326.     /**
  3327.      * Returns a valid Windows Brush Style from anpalette of many possible
  3328.      * Brush styles.
  3329.      *
  3330.      * @param index int
  3331.      * @return HatchStyle 
  3332.      */
  3333.     static public function getDefaultPattern($index{
  3334.         $patternPalette Array (
  3335.                                       HatchStyle::$HORIZONTAL,
  3336.                                       HatchStyle::$VERTICAL,
  3337.                                       HatchStyle::$FORWARDDIAGONAL,
  3338.                                       HatchStyle::$BACKWARDDIAGONAL,
  3339.                                       HatchStyle::$CROSS,
  3340.                                       HatchStyle::$DIAGONALCROSS,
  3341.                                       HatchStyle::$DIAGONALBRICK,
  3342.                                       HatchStyle::$DIVOT,
  3343.                                       HatchStyle::$LARGECONFETTI,
  3344.                                       HatchStyle::$OUTLINEDDIAMOND,
  3345.                                       HatchStyle::$PLAID,
  3346.                                       HatchStyle::$SHINGLE,
  3347.                                       HatchStyle::$SOLIDDIAMOND,
  3348.                                       HatchStyle::$SPHERE,
  3349.                                       HatchStyle::$TRELLIS,
  3350.                                       HatchStyle::$WAVE,
  3351.                                       HatchStyle::$WEAVE,
  3352.                                       HatchStyle::$ZIGZAG
  3353.         );
  3354.         return $patternPalette[$index sizeof($patternPalette)];
  3355.     }
  3356.  
  3357.  
  3358.     /**
  3359.      * The anti-alias mode for the Graphics Pen when Custom drawing.<br>
  3360.      * For example: <br>
  3361.      *             AntiAlias - Specifies antialiased rendering.<br>
  3362.      *             Default - Specifies the default mode.<br>
  3363.      *             HighQuality - Specifies high quality, low speed rendering.
  3364.      * <br>
  3365.      *             HighSpeed - Specifies high speed, low quality rendering.<br>
  3366.      *             Invalid - Specifies an invalid mode.  <br>
  3367.      *
  3368.      * @return boolean 
  3369.      */
  3370.     public function getSmoothingMode({
  3371.         return $this->smoothingMode;
  3372.     }
  3373.  
  3374.     /**
  3375.      * Sets the anti-alias mode for the Graphics Pen when Custom drawing.<br>
  3376.      * For example: <br>
  3377.      *             AntiAlias - Specifies antialiased rendering.<br>
  3378.      *             Default - Specifies the default mode.<br>
  3379.      *             HighQuality - Specifies high quality, low speed rendering.
  3380.      * <br>
  3381.      *             HighSpeed - Specifies high speed, low quality rendering.<br>
  3382.      *             Invalid - Specifies an invalid mode.  <br>
  3383.      *
  3384.  
  3385.      * @param value boolean
  3386.      */
  3387.     public function setSmoothingMode($value{
  3388.         $this->smoothingMode = $this->setBooleanProperty($this->smoothingMode$value);
  3389.     }
  3390.  
  3391.     static private function internalGetSupports3DText({
  3392.         return false;
  3393.     }
  3394.  
  3395.     /**
  3396.      * Returns if Canvas supports 3D Text or not.
  3397.      *
  3398.      * @return boolean 
  3399.      */
  3400.     public function getSupports3DText({
  3401.         return self::internalGetSupports3DText();
  3402.     }
  3403.  
  3404.     /**
  3405.      * Returns if Canvas can do rotation and elevation of more than 90 degree.
  3406.      *
  3407.      * @return boolean 
  3408.      */
  3409.     public function getSupportsFullRotation({
  3410.         return false;
  3411.     }
  3412.  
  3413.     // Returns TeePoint
  3414.     static public function rectCenter($r{
  3415.         return new TeePoint(
  3416.                 ($r->getX($r->getRight()) 2,
  3417.                 ($r->$r->getBottom()) 2
  3418.                 );
  3419.     }
  3420.  
  3421.     // returns PointDouble
  3422.     public function pointFromCircle($rectBounds$degrees,
  3423.                                        $zPos$clockWise=false)
  3424.     {
  3425.       $centrePoint $this->rectCenter($rectBounds);
  3426.  
  3427.       $radians (M_PI $degrees180.0;
  3428.       $radiusH $rectBounds->getWidth(2.0;
  3429.       $radiusV $rectBounds->getHeight(2.0;
  3430.  
  3431.       $tmpX $centrePoint->getX($radiusH cos($radians);
  3432.       $tmpY 0;
  3433.       if ($clockWise)
  3434.       {
  3435.         $tmpY $centrePoint->getY($radiusV sin($radians);
  3436.       }
  3437.       else
  3438.       {
  3439.         $tmpY $centrePoint->getY($radiusV sin($radians);
  3440.       }
  3441.  
  3442.       //$tmpPoint = new PointDouble();
  3443.  
  3444.       if ($zPos 0)
  3445.       {
  3446.         $tmpPoint $this->calc3DPos($tmpX,$tmpY,$zPos);
  3447.       }
  3448.       else
  3449.       {
  3450.         $tmpPoint new PointDouble($tmpX$tmpY);
  3451.       }
  3452.  
  3453.       return $tmpPoint;
  3454.     }
  3455.  
  3456.     public function getImageInterlace()
  3457.     {
  3458.         return $this->imageinterlace;
  3459.     }
  3460.  
  3461.     public function setImageInterlace($vlaue)
  3462.     {
  3463.         $this->imageinterlace=$value;
  3464.     }
  3465.  
  3466.     public function getImageReflection()
  3467.     {
  3468.         return $this->imageReflection;
  3469.     }
  3470.  
  3471.     public function setImageReflection($value)
  3472.     {
  3473.         $this->imageReflection=$value;
  3474.     }
  3475.  
  3476.     /**
  3477.      * Converts the Color parameter to a darker color.<br>
  3478.      * The HowMuch parameter indicates the quantity of dark increment.
  3479.      * It is used by Bar Series and Pie Series to calculate the right color to
  3480.      * draw Bar sides and Pie 3D zones.
  3481.      *
  3482.      * @param Color
  3483.      * @param howMuch int
  3484.      * @return Color 
  3485.      */
  3486.     static public function applyDark($c$howMuch{
  3487.         return $c->applyDark($howMuch);
  3488.     }
  3489.  
  3490.     public static function doReflection($im{
  3491. /*
  3492.         $rH = 50; // Reflection height
  3493.         $tr = 30; // Starting transparency
  3494.         $div = 1; // Size of the divider line
  3495.  
  3496.         $w=imagesx($im);
  3497.         $h=imagesy($im);
  3498.  
  3499.         $imgFinal = $im;
  3500.  
  3501.         $li = imagecreatetruecolor($w, 1);
  3502.         $bgc = imagecolorallocate($li, 255, 255, 255); // Background color
  3503.         imagefilledrectangle($li, 0, 0, $w, 1, $bgc);
  3504.         $bg = imagecreatetruecolor($w, $rH);
  3505.         $wh = imagecolorallocate($im,255,255,255);
  3506.  
  3507.         $im = imagerotate($im, -180, $wh);
  3508.         imagecopyresampled($bg, $im, 0, 0, 0, 0, $w, $h, $w, $h);
  3509.         $im = $bg;
  3510.         $bg = imagecreatetruecolor($w, $rH);
  3511.  
  3512.         for ($x = 0; $x < $w; $x++) {
  3513.           imagecopy($bg, $im, $x, 0, $w-$x, 0, 1, $rH);
  3514.         }
  3515.  
  3516.         $im = $bg;
  3517.         $in = 100/$rH;
  3518.  
  3519.         for($i=0; $i<=$rH; $i++){
  3520.           if($tr>100) $tr = 100;
  3521.             imagecopymerge($im, $li, 0, $i, 0, 0, $w, 1, $tr);
  3522.           $tr+=$in;
  3523.         }
  3524.  
  3525.         imagecopymerge($im, $li, 0, 0, 0, 0, $w, $div, 100); // Divider
  3526.  
  3527.         return $im;
  3528.         imagedestroy($li);
  3529.         */
  3530.     }
  3531.  
  3532.  
  3533.     /**
  3534.      * Returns the height, in pixels, of the Chart Panel.<br>
  3535.      * It should be used when using Canvas methods to draw relative to the
  3536.      * Panel height. <br>
  3537.      * <b>Note:</B> You should <b>NOT</b> use TChart.Height.
  3538.  
  3539.      *
  3540.      * @return int 
  3541.      */
  3542.     static public function getScreenHeight({
  3543.         return 1050;  // TODO GET SCREEN WIDTH AND HEIGHT
  3544.     }
  3545.  
  3546.     /**
  3547.      * Returns the width, in pixels, of the Chart Panel.
  3548.      *
  3549.      * @return int 
  3550.      */
  3551.     static public function getScreenWidth({
  3552.         return 1680;  // TODO GET SCREEN WIDTH AND HEIGHT
  3553.     }
  3554. }
  3555. ?>

Documentation generated on Wed, 16 Jun 2010 12:04:02 +0200 by phpDocumentor 1.4.1