Random Noise turing test
Generates random black noise, then text, then random white noise.
Methods
Public Instance methods
contract method - generate the challenge
[ show source ]
# File lib/turing/image_plugins/random_noise.rb, line 15 15: def generate(img, word, bg = nil) # {{{ 16: fg = GD2::Color[255, 255, 255] 17: bg = GD2::Color[0, 0, 0] 18: 19: 0.upto(img.width * img.height * 0.4) do |i| 20: img[rand(img.width), rand(img.height)] = bg 21: end 22: 23: write_string(img, 'georgiai.ttf', bg, word, 48) 24: 25: quant = word.size > 7 ? 0.1 : 0.2 26: 0.upto(img.width * img.height * quant) do |i| 27: img[rand(img.width), rand(img.height)] = fg 28: end 29: end