backgroundcontroller.groovy

来自「一套用于生成各种图形验证码的库(Java)」· GROOVY 代码 · 共 55 行

GROOVY
55
字号
import java.awt.Colorimport nl.captcha.Captchaimport nl.captcha.backgrounds.*import nl.captcha.servlet.CaptchaServletUtil/** * Exercise the various background renderers.**/class BackgroundController {    def final WIDTH = 200    def final HEIGHT = 50    def simple = {        def captcha = new Captcha.Builder(WIDTH, HEIGHT)            .addText()            .addBackground()            .build()        CaptchaServletUtil.writeImage(response, captcha.image)    }    def squiggles = {        def captcha = new Captcha.Builder(WIDTH, HEIGHT)            .addText()            .addBackground(new SquigglesBackgroundProducer())            .build()        CaptchaServletUtil.writeImage(response, captcha.image)    }    def flatcolor = {        def captcha = new Captcha.Builder(WIDTH, HEIGHT)            .addText()            .addBackground(new FlatColorBackgroundProducer())            .build()        CaptchaServletUtil.writeImage(response, captcha.image)    }    def blue = {        def captcha = new Captcha.Builder(WIDTH, HEIGHT)            .addText()            .addBackground(new FlatColorBackgroundProducer(Color.BLUE))            .build()        CaptchaServletUtil.writeImage(response, captcha.image)    }    def gradiated = {        def captcha = new Captcha.Builder(WIDTH, HEIGHT)            .addText()            .addBackground(new GradiatedBackgroundProducer())            .build()        CaptchaServletUtil.writeImage(response, captcha.image)    }}

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?