/**
  * @param string $key
  * @param array $options
  *
  * @return string
  */
 public function generate(array &$options)
 {
     $this->builder->setDistortion($options['distortion']);
     $this->builder->setMaxFrontLines($options['max_front_lines']);
     $this->builder->setMaxBehindLines($options['max_behind_lines']);
     if (isset($options['text_color']) && $options['text_color']) {
         if (count($options['text_color']) !== 3) {
             throw new \RuntimeException('text_color should be an array of r, g and b');
         }
         $color = $options['text_color'];
         $this->builder->setTextColor($color[0], $color[1], $color[2]);
     }
     if (isset($options['background_color']) && $options['background_color']) {
         if (count($options['background_color']) !== 3) {
             throw new \RuntimeException('background_color should be an array of r, g and b');
         }
         $color = $options['background_color'];
         $this->builder->setBackgroundColor($color[0], $color[1], $color[2]);
     }
     $this->builder->setInterpolation($options['interpolation']);
     $fingerprint = isset($options['fingerprint']) ? $options['fingerprint'] : null;
     $content = $this->builder->build($options['width'], $options['height'], $options['font'], $fingerprint)->getGd();
     if ($options['keep_value']) {
         $options['fingerprint'] = $this->builder->getFingerprint();
     }
     if (!$options['as_file']) {
         ob_start();
         imagejpeg($content, null, $options['quality']);
         return ob_get_clean();
     }
     return $this->imageFileHandler->saveAsFile($content);
 }
function getCaptchaBuilder($paramArr)
{
    $options = array('width' => 80, 'height' => 20, 'numCnt' => 4, 'text' => 'ABCD', 'plex' => 5);
    if (is_array($paramArr)) {
        $options = array_merge($options, $paramArr);
    }
    extract($options);
    $textColorArr = array(0 => array(0, 0, 0), 1 => array(8, 46, 84), 2 => array(61, 145, 64), 3 => array(0, 0, 255), 4 => array(11, 23, 70), 5 => array(135, 38, 87));
    $randNum = rand(1, 4);
    $textColor = $textColorArr[$randNum];
    $randStart = 250 - 4 * $plex;
    $angle = 3 * $plex;
    $lines = 3 * $plex;
    $fontNum = rand(1, 5);
    if (!$fontNum) {
        $fontNum = 1;
    }
    $font = LJL_API_ROOT . '/Config/Fonts/captcha' . $fontNum . '.ttf';
    $backgroudColorArr = array(rand($randStart, 255), rand($randStart, 255), rand($randStart, 255));
    $distort = false;
    if (6 < $plex) {
        $distort = true;
    }
    header('Content-type: image/jpeg');
    CaptchaBuilder::create($text)->setTextColor($textColor[0], $textColor[1], $textColor[2])->setBackgroundColor($backgroudColorArr[0], $backgroudColorArr[1], $backgroudColorArr[2])->setMaxBehindLines($lines)->setMaxFrontLines($lines)->setMaxAngle($angle)->setDistortion($distort)->setMaxOffset($plex)->build($width, $height, $font)->output();
    exit;
}