1<?php
2
3/**
4 *    pChart - a PHP class to build charts!
5 *
6 *    This program is free software: you can redistribute it and/or modify
7 *    it under the terms of the GNU General Public License as published by
8 *    the Free Software Foundation, either version 1,2,3 of the License, or
9 *    (at your option) any later version.
10 *
11 *    This program is distributed in the hope that it will be useful,
12 *    but WITHOUT ANY WARRANTY; without even the implied warranty of
13 *    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14 *    GNU General Public License for more details.
15 *
16 *    You should have received a copy of the GNU General Public License
17 *    along with this program.  If not, see <http://www.gnu.org/licenses/>.
18 */
19
20class ShadowProperties {
21    private function __construct() {
22
23    }
24
25    static public function FromDefaults() {
26        $properties = new ShadowProperties;
27
28        $properties->active = false;
29
30        return $properties;
31    }
32
33    static public function FromSettings($xDistance, $yDistance, Color $color, $alpha = 50, $blur = 0) {
34        $properties = new ShadowProperties;
35
36        $properties->active    = true;
37        $properties->xDistance = $xDistance;
38        $properties->yDistance = $yDistance;
39        $properties->color     = $color;
40        $properties->alpha     = $alpha;
41        $properties->blur      = $blur;
42
43        return $properties;
44    }
45
46    /**
47     * Instantiate a new ShadowProperties with the same settings as
48     * the one passed in. Essentially this is a clone method.
49     *
50     * @todo clone appears to be a reserved word in PHP, is there
51     * actually any special clone functionality? I can't RTFM at the
52     * moment as the internet connection is down.
53     */
54    static public function Copy(ShadowProperties $other) {
55        $copy         = ShadowProperties::FromSettings(
56            $other->xDistance,
57            $other->yDistance,
58            $other->color,
59            $other->alpha,
60            $other->blur
61        );
62        $copy->active = $other->active;
63
64        return $copy;
65    }
66
67    static public function NoShadow() {
68        return self::FromDefaults();
69    }
70
71    public function __toString() {
72        return sprintf(
73            "ShadowProperties<%d, %d, %d, %s, %d, %d>",
74            $this->active, $this->xDistance, $this->yDistance,
75            $this->color, $this->alpha, $this->blur
76        );
77    }
78
79    public $active;
80    public $xDistance;
81    public $yDistance;
82    public $color;
83    public $alpha;
84    public $blur;
85}