gimpycontroller.groovy
来自「一个为 Java/J2EE生成的最简化CAPTCHA的框架」· GROOVY 代码 · 共 86 行
GROOVY
86 行
import java.awt.Colorimport nl.captcha.Captchaimport nl.captcha.backgrounds.*import nl.captcha.gimpy.*import nl.captcha.servlet.CaptchaServletUtil/*** Exercise the different gimpy renderers.***/class GimpyController { def final WIDTH = 200 def final HEIGHT = 50 def simple = { def captcha = new Captcha.Builder(WIDTH, HEIGHT) .addText() .gimp() .build() CaptchaServletUtil.writeImage(response, captcha.image) } def fisheye = { def captcha = new Captcha.Builder(WIDTH, HEIGHT) .addText() .gimp(new FishEyeGimpyRenderer(Color.RED, Color.BLUE)) .build() CaptchaServletUtil.writeImage(response, captcha.image) } def ripple = { def captcha = new Captcha.Builder(WIDTH, HEIGHT) .addText() .gimp(new RippleGimpyRenderer()) .build() CaptchaServletUtil.writeImage(response, captcha.image) } def shear = { def captcha = new Captcha.Builder(WIDTH, HEIGHT) .addText() .gimp(new ShearGimpyRenderer()) .build() CaptchaServletUtil.writeImage(response, captcha.image) } def shadow = { def captcha = new Captcha.Builder(WIDTH, HEIGHT) .addText() .gimp(new DropShadowGimpyRenderer()) .build() CaptchaServletUtil.writeImage(response, captcha.image) } def block = { def captcha = new Captcha.Builder(WIDTH, HEIGHT) .addText() .gimp(new BlockGimpyRenderer()) .build() CaptchaServletUtil.writeImage(response, captcha.image) } def blockbig = { def captcha = new Captcha.Builder(WIDTH, HEIGHT) .addText() .gimp(new BlockGimpyRenderer(5)) .build() CaptchaServletUtil.writeImage(response, captcha.image) } def multi = { def captcha = new Captcha.Builder(WIDTH, HEIGHT) .addText() .gimp(new BlockGimpyRenderer()) .gimp(new DropShadowGimpyRenderer()) .gimp(new RippleGimpyRenderer()) .gimp(new FishEyeGimpyRenderer()) .addBackground(new GradiatedBackgroundProducer()) .addBorder() .build() CaptchaServletUtil.writeImage(response, captcha.image) }}
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?