You are here

function _image_captcha_image_generator_add_dots in CAPTCHA 7

Same name and namespace in other branches
  1. 5.3 image_captcha/image_captcha.user.inc \_image_captcha_image_generator_add_dots()
  2. 6.2 image_captcha/image_captcha.user.inc \_image_captcha_image_generator_add_dots()
  3. 6 image_captcha/image_captcha.user.inc \_image_captcha_image_generator_add_dots()

Add dots.

1 call to _image_captcha_image_generator_add_dots()
_image_captcha_generate_image in image_captcha/image_captcha.user.inc
Base function for generating a image CAPTCHA.

File

image_captcha/image_captcha.user.inc, line 237
Functions for the generation of the CAPTCHA image.

Code

function _image_captcha_image_generator_add_dots(&$image, $width, $height, $colors) {
  $noise_quantity = $width * $height * (int) variable_get('image_captcha_noise_level', 5) / 10.0;
  for ($i = 0; $i < $noise_quantity; $i++) {
    imagesetpixel($image, mt_rand(0, $width), mt_rand(0, $height), $colors[array_rand($colors)]);
  }
}