2 /* Libchart - PHP chart library
3 * Copyright (C) 2005-2008 Jean-Marc Trémeaux (jm.tremeaux at gmail.com)
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.
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.
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/>.
21 * Graphic primitives, extends GD with chart related primitives.
23 * @author Jean-Marc Trémeaux (jm.tremeaux at gmail.com)
29 * Creates a new primitive object
31 * @param resource GD image resource
33 public function Primitive($img) {
38 * Draws a straight line.
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
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));
52 * Draw a filled gray box with thick borders and darker corners.
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
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));