File indexing completed on 2025-01-26 05:29:15
0001 <?php 0002 0003 namespace Intervention\Image; 0004 0005 abstract class AbstractShape 0006 { 0007 /** 0008 * Background color of shape 0009 * 0010 * @var string 0011 */ 0012 public $background; 0013 0014 /** 0015 * Border color of current shape 0016 * 0017 * @var string 0018 */ 0019 public $border_color; 0020 0021 /** 0022 * Border width of shape 0023 * 0024 * @var int 0025 */ 0026 public $border_width = 0; 0027 0028 /** 0029 * Draws shape to given image on given position 0030 * 0031 * @param Image $image 0032 * @param int $posx 0033 * @param int $posy 0034 * @return boolean 0035 */ 0036 abstract public function applyToImage(Image $image, $posx = 0, $posy = 0); 0037 0038 /** 0039 * Set text to be written 0040 * 0041 * @param string $text 0042 * @return void 0043 */ 0044 public function background($color) 0045 { 0046 $this->background = $color; 0047 } 0048 0049 /** 0050 * Set border width and color of current shape 0051 * 0052 * @param int $width 0053 * @param string $color 0054 * @return void 0055 */ 0056 public function border($width, $color = null) 0057 { 0058 $this->border_width = is_numeric($width) ? intval($width) : 0; 0059 $this->border_color = is_null($color) ? '#000000' : $color; 0060 } 0061 0062 /** 0063 * Determines if current shape has border 0064 * 0065 * @return boolean 0066 */ 0067 public function hasBorder() 0068 { 0069 return ($this->border_width >= 1); 0070 } 0071 }