class StupidCaptcha::Captcha

Attributes

hash[RW]
img[RW]
text[RW]

Public Instance Methods

render() click to toggle source
# File lib/stupid_captcha.rb, line 70
def render
    icon = Magick::Image.read(backgrounds.sample).first

    drawable = Magick::Draw.new
    drawable.pointsize = 32.0
    drawable.font = fonts.sample
    drawable.fill = colors.sample
    drawable.gravity = Magick::CenterGravity

    # Tweak the font to draw slightly up and left from the center
    #        drawable.annotate(icon, 0, 0, -3, -6, @order.quantity.to_s)
    drawable.annotate(icon, 0, 0, 0,0, text)

    img = icon
end
reset() click to toggle source
# File lib/stupid_captcha.rb, line 86
def reset
  @text = random_string(rand(3)+5)
  @hash = encrypt(text, salt)
  @img = render
end
to_blob() click to toggle source
# File lib/stupid_captcha.rb, line 92
def to_blob
  img.to_blob
end