protected function CaptchaImageResponse::addLines in CAPTCHA 8
Add random noise lines to image with given color.
Parameters
resource $image: Link to image stream resource.
int $width: Suggested output image width.
int $height: Suggested input image width.
array $colors: Font color.
1 call to CaptchaImageResponse::addLines()
- CaptchaImageResponse::generateImage in image_captcha/
src/ Response/ CaptchaImageResponse.php - Base function for generating a image CAPTCHA.
File
- image_captcha/
src/ Response/ CaptchaImageResponse.php, line 306
Class
- CaptchaImageResponse
- Response which is returned as the captcha for image_captcha.
Namespace
Drupal\image_captcha\ResponseCode
protected function addLines(&$image, $width, $height, array $colors) {
$line_quantity = $width * $height / 200.0 * (int) $this->config
->get('image_captcha_noise_level') / 10.0;
for ($i = 0; $i < $line_quantity; $i++) {
imageline($image, mt_rand(0, $width), mt_rand(0, $height), mt_rand(0, $width), mt_rand(0, $height), $colors[array_rand($colors)]);
}
}