protected function drawText()
    {
        /**
         * 0 Numbers
         * 1 Pure English letters
         * 2 English letters & Numbers mixed
         * 3 chinese characters
         * 4 All mixed
         */

        switch($this->randomType)
        {
            case 0:
                $this->randomNumbers();
                break;

            case 1:
                $this->randomPureLetters();
                break;

            case 3:
                $this->randomChinese();
                break;

            case 4:
                $this->randomMixed();
                break;

            case 2:
            default:
                $this->randomLetters();
                break;
        }

        if (!$this->fontFile)
        {
            $this->fontFile = __DIR__ . '../../Fonts/verdana.ttf';
        }

        if (!file_exists($this->fontFile))
        {
            throw new \InvalidArgumentException('Font file ' . $this->fontFile . ' not found.');
        }

        $textColor = imagecolorallocate($this->image, mt_rand(0, 255), mt_rand(0, 255), mt_rand(0, 255));

        $x = ($this->width - ($this->fontSize * $this->length)) / 2;
        $y = $this->fontSize + ($this->height - $this->fontSize) / 2;
        $fontFile = (is_array($this->fontFile)) ? $this->fontFile[array_rand($this->fontFile)] : $this->fontFile;

        imagettftext($this->image, $this->fontSize , mt_rand(-8, 8), $x, $y, $textColor, $fontFile, $this->code);
    }
protected function drawText()
    {
        /**
         * 0 Numbers
         * 1 Pure English letters
         * 2 English letters & Numbers mixed
         * 3 chinese characters
         * 4 All mixed
         */

        switch($this->randomType)
        {
            case 0:
                $this->randomNumbers();
                break;

            case 1:
                $this->randomPureLetters();
                break;

            case 3:
                $this->randomChinese();
                break;

            case 4:
                $this->randomMixed();
                break;

            case 2:
            default:
                $this->randomLetters();
                break;
        }

        if (!$this->fontFile)
        {
            $this->fontFile = __DIR__ . '../../Fonts/verdana.ttf';
        }

        if (!file_exists($this->fontFile))
        {
            throw new \InvalidArgumentException('Font file ' . $this->fontFile . ' not found.');
        }

        $textColor = imagecolorallocate($this->image, mt_rand(0, 255), mt_rand(0, 255), mt_rand(0, 255));

        $x = ($this->width - ($this->fontSize * $this->length)) / 2;
        $y = $this->fontSize + ($this->height - $this->fontSize) / 2;
        $fontFile = (is_array($this->fontFile)) ? $this->fontFile[array_rand($this->fontFile)] : $this->fontFile;

        imagettftext($this->image, $this->fontSize , mt_rand(-8, 8), $x, $y, $textColor, $fontFile, $this->code);
    }
protected function drawText ( ) { /**
         * 0 Numbers
         * 1 Pure English letters
         * 2 English letters & Numbers mixed
         * 3 chinese characters
         * 4 All mixed
         */ switch ( $ this -> randomType ) { case 0 : $ this -> randomNumbers ( ) ; break ; case 1 : $ this -> randomPureLetters ( ) ; break ; case 3 : $ this -> randomChinese ( ) ; break ; case 4 : $ this -> randomMixed ( ) ; break ; case 2 : default : $ this -> randomLetters ( ) ; break ; } if ( ! $ this -> fontFile ) { $ this -> fontFile = __DIR__ . '../../Fonts/verdana.ttf' ; } if ( ! file_exists ( $ this -> fontFile ) ) { throw new \ InvalidArgumentException ( 'Font file ' . $ this -> fontFile . ' not found.' ) ; } $ textColor = imagecolorallocate ( $ this -> image , mt_rand ( 0 , 255 ) , mt_rand ( 0 , 255 ) , mt_rand ( 0 , 255 ) ) ; $ x = ( $ this -> width - ( $ this -> fontSize * $ this -> length ) ) / 2 ; $ y = $ this -> fontSize + ( $ this -> height - $ this -> fontSize ) / 2 ; $ fontFile = ( is_array ( $ this -> fontFile ) ) ? $ this -> fontFile [ array_rand ( $ this -> fontFile ) ] : $ this -> fontFile ; imagettftext ( $ this -> image , $ this -> fontSize , mt_rand ( - 8 , 8 ) , $ x , $ y , $ textColor , $ fontFile , $ this -> code ) ; }
Draw text characters to image

@return void
Draw text characters to image