Go to the documentation of this file.00001 <?php
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00015 final class ErrorDrawer
00016 {
00017 const FONT_SIZE = 4;
00018
00019 private static $drawError = true;
00020
00021 public static function setDrawError($drawError = false)
00022 {
00023 self::$drawError = $drawError;
00024 }
00025
00026 public static function isDrawError()
00027 {
00028 return self::$drawError;
00029 }
00030
00031 public function __construct($turingImage)
00032 {
00033 $this->turingImage = $turingImage;
00034 }
00035
00039 public function draw($string = 'ERROR!')
00040 {
00041 if (!ErrorDrawer::isDrawError())
00042 return $this;
00043
00044 $y = round(
00045 $this->turingImage->getHeight() / 2
00046 - imagefontheight(ErrorDrawer::FONT_SIZE) / 2
00047 );
00048
00049 $textWidth = imagefontwidth(ErrorDrawer::FONT_SIZE) * strlen($string);
00050
00051 if ($this->turingImage->getWidth() > $textWidth)
00052 $x = round(($this->turingImage->getWidth() - $textWidth) / 2);
00053 else
00054 $x = 0;
00055
00056 $color = $this->turingImage->getOneCharacterColor();
00057
00058 imagestring(
00059 $this->turingImage->getImageId(),
00060 ErrorDrawer::FONT_SIZE,
00061 $x,
00062 $y,
00063 $string,
00064 $color
00065 );
00066
00067 return $this;
00068 }
00069 }
00070 ?>