Initial repo created
[timetracker.git] / WEB-INF / lib / libchart / classes / view / primitive / Primitive.php
1 <?php
2         /* Libchart - PHP chart library
3          * Copyright (C) 2005-2008 Jean-Marc Trémeaux (jm.tremeaux at gmail.com)
4          * 
5          * This program is free software: you can redistribute it and/or modify
6          * it under the terms of the GNU General Public License as published by
7          * the Free Software Foundation, either version 3 of the License, or
8          * (at your option) any later version.
9          * 
10          * This program is distributed in the hope that it will be useful,
11          * but WITHOUT ANY WARRANTY; without even the implied warranty of
12          * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
13          * GNU General Public License for more details.
14          *
15          * You should have received a copy of the GNU General Public License
16          * along with this program.  If not, see <http://www.gnu.org/licenses/>.
17          * 
18          */
19         
20         /**
21          * Graphic primitives, extends GD with chart related primitives.
22          *
23          * @author Jean-Marc Trémeaux (jm.tremeaux at gmail.com)
24          */
25         class Primitive {
26                 private $img;
27         
28                 /**
29                  * Creates a new primitive object
30                  *
31                  * @param       resource        GD image resource
32                  */
33                 public function Primitive($img) {
34                         $this->img = $img;
35                 }
36                 
37                 /**
38                  * Draws a straight line.
39                  *
40                  * @param integer line start (X)
41                  * @param integer line start (Y)
42                  * @param integer line end (X)
43                  * @param integer line end (Y)
44                  * @param Color line color
45                  */
46                 public function line($x1, $y1, $x2, $y2, $color, $width = 1) {
47                         imagefilledpolygon($this->img, array($x1, $y1 - $width / 2, $x1, $y1 + $width / 2, $x2, $y2 + $width / 2, $x2, $y2 - $width / 2), 4, $color->getColor($this->img));
48                         // imageline($this->img, $x1, $y1, $x2, $y2, $color->getColor($this->img));
49                 }
50
51                 /**
52                  * Draw a filled gray box with thick borders and darker corners.
53                  *
54                  * @param integer top left coordinate (x)
55                  * @param integer top left coordinate (y)
56                  * @param integer bottom right coordinate (x)
57                  * @param integer bottom right coordinate (y)
58                  * @param Color edge color
59                  * @param Color corner color
60                  */
61                 public function outlinedBox($x1, $y1, $x2, $y2, $color0, $color1) {
62                         imagefilledrectangle($this->img, $x1, $y1, $x2, $y2, $color0->getColor($this->img));
63                         imagerectangle($this->img, $x1, $y1, $x1 + 1, $y1 + 1, $color1->getColor($this->img));
64                         imagerectangle($this->img, $x2 - 1, $y1, $x2, $y1 + 1, $color1->getColor($this->img));
65                         imagerectangle($this->img, $x1, $y2 - 1, $x1 + 1, $y2, $color1->getColor($this->img));
66                         imagerectangle($this->img, $x2 - 1, $y2 - 1, $x2, $y2, $color1->getColor($this->img));
67                 }
68
69         }
70 ?>