HuasoFoundries /
jpgraph
| 1 | <?php |
||
| 2 | |||
| 3 | /** |
||
| 4 | * JPGraph v4.0.3 |
||
| 5 | */ |
||
| 6 | |||
| 7 | namespace Amenadiel\JpGraph\Image; |
||
| 8 | |||
| 9 | use Amenadiel\JpGraph\Util; |
||
| 10 | |||
| 11 | /** |
||
| 12 | * @class ImgData |
||
| 13 | * // Description: Base class for all image data classes that contains the |
||
| 14 | * // real image data. |
||
| 15 | */ |
||
| 16 | class ImgData |
||
| 17 | { |
||
| 18 | protected $name = ''; // Each subclass gives a name |
||
| 19 | protected $an = []; // Data array names |
||
| 20 | protected $colors = []; // Available colors |
||
| 21 | protected $index = []; // Index for colors |
||
| 22 | protected $maxidx = 0; // Max color index |
||
| 23 | protected $anchor_x = 0.5; |
||
| 24 | protected $anchor_y = 0.5; // Where is the center of the image |
||
| 25 | |||
| 26 | public function __construct() |
||
| 27 | { |
||
| 28 | // Empty |
||
| 29 | } |
||
| 30 | |||
| 31 | // Create a GD image from the data and return a GD handle |
||
| 32 | 3 | public function GetImg($aMark, $aIdx) |
|
| 33 | { |
||
| 34 | 3 | $n = $this->an[$aMark]; |
|
| 35 | 3 | if (is_string($aIdx)) { |
|
| 36 | 3 | if (!in_array($aIdx, $this->colors, true)) { |
|
| 37 | Util\JpGraphError::RaiseL(23001, $this->name, $aIdx); //('This marker "'.($this->name).'" does not exist in color: '.$aIdx); |
||
| 38 | } |
||
| 39 | 3 | $idx = $this->index[$aIdx]; |
|
| 40 | 1 | } elseif (!is_integer($aIdx) || |
|
| 41 | 1 | (is_integer($aIdx) && $aIdx > $this->maxidx)) { |
|
| 42 | Util\JpGraphError::RaiseL(23002, $this->name); //('Mark color index too large for marker "'.($this->name).'"'); |
||
| 43 | } else { |
||
| 44 | 1 | $idx = $aIdx; |
|
| 45 | } |
||
| 46 | |||
| 47 | 3 | return Image::CreateFromString(base64_decode($this->{$n}[$idx][1], true)); |
|
|
0 ignored issues
–
show
Comprehensibility
Best Practice
introduced
by
Loading history...
|
|||
| 48 | } |
||
| 49 | |||
| 50 | 3 | public function GetAnchor() |
|
| 51 | { |
||
| 52 | 3 | return [$this->anchor_x, $this->anchor_y]; |
|
| 53 | } |
||
| 54 | } |
||
| 55 |