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($other->xDistance, 56 $other->yDistance, 57 $other->color, 58 $other->alpha, 59 $other->blur); 60 $copy->active = $other->active; 61 62 return $copy; 63 } 64 65 static public function NoShadow() { 66 return self::FromDefaults(); 67 } 68 69 public function __toString() { 70 return sprintf("ShadowProperties<%d, %d, %d, %s, %d, %d>", 71 $this->active, $this->xDistance, $this->yDistance, 72 $this->color, $this->alpha, $this->blur); 73 } 74 75 public $active; 76 public $xDistance; 77 public $yDistance; 78 public $color; 79 public $alpha; 80 public $blur; 81}