Shadow.php 5.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275
  1. <?php
  2. /**
  3. * 重庆赤晓店信息科技有限公司
  4. * https://www.chixiaodian.com
  5. * Copyright (c) 2023 赤店商城 All rights reserved.
  6. */
  7. class PHPExcel_Worksheet_Drawing_Shadow implements PHPExcel_IComparable
  8. {
  9. /* Shadow alignment */
  10. const SHADOW_BOTTOM = 'b';
  11. const SHADOW_BOTTOM_LEFT = 'bl';
  12. const SHADOW_BOTTOM_RIGHT = 'br';
  13. const SHADOW_CENTER = 'ctr';
  14. const SHADOW_LEFT = 'l';
  15. const SHADOW_TOP = 't';
  16. const SHADOW_TOP_LEFT = 'tl';
  17. const SHADOW_TOP_RIGHT = 'tr';
  18. /**
  19. * Visible
  20. *
  21. * @var boolean
  22. */
  23. private $visible;
  24. /**
  25. * Blur radius
  26. *
  27. * Defaults to 6
  28. *
  29. * @var int
  30. */
  31. private $blurRadius;
  32. /**
  33. * Shadow distance
  34. *
  35. * Defaults to 2
  36. *
  37. * @var int
  38. */
  39. private $distance;
  40. /**
  41. * Shadow direction (in degrees)
  42. *
  43. * @var int
  44. */
  45. private $direction;
  46. /**
  47. * Shadow alignment
  48. *
  49. * @var int
  50. */
  51. private $alignment;
  52. /**
  53. * Color
  54. *
  55. * @var PHPExcel_Style_Color
  56. */
  57. private $color;
  58. /**
  59. * Alpha
  60. *
  61. * @var int
  62. */
  63. private $alpha;
  64. /**
  65. * Create a new PHPExcel_Worksheet_Drawing_Shadow
  66. */
  67. public function __construct()
  68. {
  69. // Initialise values
  70. $this->visible = false;
  71. $this->blurRadius = 6;
  72. $this->distance = 2;
  73. $this->direction = 0;
  74. $this->alignment = PHPExcel_Worksheet_Drawing_Shadow::SHADOW_BOTTOM_RIGHT;
  75. $this->color = new PHPExcel_Style_Color(PHPExcel_Style_Color::COLOR_BLACK);
  76. $this->alpha = 50;
  77. }
  78. /**
  79. * Get Visible
  80. *
  81. * @return boolean
  82. */
  83. public function getVisible()
  84. {
  85. return $this->visible;
  86. }
  87. /**
  88. * Set Visible
  89. *
  90. * @param boolean $pValue
  91. * @return PHPExcel_Worksheet_Drawing_Shadow
  92. */
  93. public function setVisible($pValue = false)
  94. {
  95. $this->visible = $pValue;
  96. return $this;
  97. }
  98. /**
  99. * Get Blur radius
  100. *
  101. * @return int
  102. */
  103. public function getBlurRadius()
  104. {
  105. return $this->blurRadius;
  106. }
  107. /**
  108. * Set Blur radius
  109. *
  110. * @param int $pValue
  111. * @return PHPExcel_Worksheet_Drawing_Shadow
  112. */
  113. public function setBlurRadius($pValue = 6)
  114. {
  115. $this->blurRadius = $pValue;
  116. return $this;
  117. }
  118. /**
  119. * Get Shadow distance
  120. *
  121. * @return int
  122. */
  123. public function getDistance()
  124. {
  125. return $this->distance;
  126. }
  127. /**
  128. * Set Shadow distance
  129. *
  130. * @param int $pValue
  131. * @return PHPExcel_Worksheet_Drawing_Shadow
  132. */
  133. public function setDistance($pValue = 2)
  134. {
  135. $this->distance = $pValue;
  136. return $this;
  137. }
  138. /**
  139. * Get Shadow direction (in degrees)
  140. *
  141. * @return int
  142. */
  143. public function getDirection()
  144. {
  145. return $this->direction;
  146. }
  147. /**
  148. * Set Shadow direction (in degrees)
  149. *
  150. * @param int $pValue
  151. * @return PHPExcel_Worksheet_Drawing_Shadow
  152. */
  153. public function setDirection($pValue = 0)
  154. {
  155. $this->direction = $pValue;
  156. return $this;
  157. }
  158. /**
  159. * Get Shadow alignment
  160. *
  161. * @return int
  162. */
  163. public function getAlignment()
  164. {
  165. return $this->alignment;
  166. }
  167. /**
  168. * Set Shadow alignment
  169. *
  170. * @param int $pValue
  171. * @return PHPExcel_Worksheet_Drawing_Shadow
  172. */
  173. public function setAlignment($pValue = 0)
  174. {
  175. $this->alignment = $pValue;
  176. return $this;
  177. }
  178. /**
  179. * Get Color
  180. *
  181. * @return PHPExcel_Style_Color
  182. */
  183. public function getColor()
  184. {
  185. return $this->color;
  186. }
  187. /**
  188. * Set Color
  189. *
  190. * @param PHPExcel_Style_Color $pValue
  191. * @throws PHPExcel_Exception
  192. * @return PHPExcel_Worksheet_Drawing_Shadow
  193. */
  194. public function setColor(PHPExcel_Style_Color $pValue = null)
  195. {
  196. $this->color = $pValue;
  197. return $this;
  198. }
  199. /**
  200. * Get Alpha
  201. *
  202. * @return int
  203. */
  204. public function getAlpha()
  205. {
  206. return $this->alpha;
  207. }
  208. /**
  209. * Set Alpha
  210. *
  211. * @param int $pValue
  212. * @return PHPExcel_Worksheet_Drawing_Shadow
  213. */
  214. public function setAlpha($pValue = 0)
  215. {
  216. $this->alpha = $pValue;
  217. return $this;
  218. }
  219. /**
  220. * Get hash code
  221. *
  222. * @return string Hash code
  223. */
  224. public function getHashCode()
  225. {
  226. return md5(
  227. ($this->visible ? 't' : 'f') .
  228. $this->blurRadius .
  229. $this->distance .
  230. $this->direction .
  231. $this->alignment .
  232. $this->color->getHashCode() .
  233. $this->alpha .
  234. __CLASS__
  235. );
  236. }
  237. /**
  238. * Implement PHP __clone to create a deep clone, not just a shallow copy.
  239. */
  240. public function __clone()
  241. {
  242. $vars = get_object_vars($this);
  243. foreach ($vars as $key => $value) {
  244. if (is_object($value)) {
  245. $this->$key = clone $value;
  246. } else {
  247. $this->$key = $value;
  248. }
  249. }
  250. }
  251. }