protected function CaptchaImageResponse::addDots in CAPTCHA 8
Add random noise dots 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::addDots()
- CaptchaImageResponse::generateImage in image_captcha/
src/ Response/ CaptchaImageResponse.php - Base function for generating a image CAPTCHA.
File
- image_captcha/
src/ Response/ CaptchaImageResponse.php, line 326
Class
- CaptchaImageResponse
- Response which is returned as the captcha for image_captcha.
Namespace
Drupal\image_captcha\ResponseCode
protected function addDots(&$image, $width, $height, array $colors) {
$noise_quantity = $width * $height * (int) $this->config
->get('image_captcha_noise_level') / 10.0;
for ($i = 0; $i < $noise_quantity; $i++) {
imagesetpixel($image, mt_rand(0, $width), mt_rand(0, $height), $colors[array_rand($colors)]);
}
}