Class CAPTCHA::ObfuscatedImage
In: lib/captcha.rb
Parent: GD::Image

An obfuscated image, which draws the letters of a key string at random offsets against a noisy background.

Methods

Public Class methods

this is the only way to create an image of this sort, since ‘new’ is private. This is because of the way the Ruby/GD module implements the GD::Image class… you can‘t override it by providing an ‘initialize’ method.

  • key: the key string to display
  • font: the font to display the key in. This should be a path to a font file.
  • font_size: the size (in points) that the key string should be displayed
  • x_spacing: how much space to insert between characters
  • max_wiggle_y: the maximum "wiggle" for each character in y
  • rotation: the maximum angle of rotation for each character.

Public Instance methods

clear the image background to white.

draw the key string on the image, randomly positioning each character.

The ‘initialize’ method for an ObfuscatedImage. The parameters are the same as for the create method, with the addition of char_height (which represents the maximum height of any character in the string).

populate the image with random noise

[Validate]