Giter Site home page Giter Site logo

jfinal-captcha's Introduction

jfinal-captcha

jfinal captcha render,查看其他插件-> Maven

maven 引用 ${jfinal-captcha.version}替换为相应的版本如:0.1

<dependency>
  <groupId>cn.dreampie</groupId>
  <artifactId>jfinal-captcha</artifactId>
  <version>${jfinal-captcha.version}</version>
</dependency>

使用

/**
   * 验证码
   */
  public void captcha() {
    int width = 0, height = 0, minnum = 0, maxnum = 0, fontsize = 0, fontmin = 0, fontmax = 0;
    CaptchaRender captcha = new CaptchaRender();
    if (isParaExists("width")) {
      width = getParaToInt("width");
    }
    if (isParaExists("height")) {
      height = getParaToInt("height");
    }
    if (width > 0 && height > 0)
      captcha.setImgSize(width, height);
    if (isParaExists("minnum")) {
      minnum = getParaToInt("minnum");
    }
    if (isParaExists("maxnum")) {
      maxnum = getParaToInt("maxnum");
    }
    if (minnum > 0 && maxnum > 0)
      captcha.setFontNum(minnum, maxnum);
    if (isParaExists("fontsize")) {
      fontsize = getParaToInt("fontsize");
    }
    if (fontsize > 0)
      captcha.setFontSize(fontsize, fontsize);
    //干扰线数量 默认0
    captcha.setLineNum(2);
    //噪点数量 默认50
    captcha.setArtifactNum(30);
    //使用字符  去掉0和o  避免难以确认
    captcha.setCode("123456789");
    //验证码在session里的名字 默认 captcha,创建时间为:名字_time
//    captcha.setCaptchaName("captcha");
    //验证码颜色 默认黑色
//    captcha.setDrawColor(new Color(255,0,0));
    //背景干扰物颜色  默认灰
//    captcha.setDrawBgColor(new Color(0,0,0));
    //背景色+透明度 前三位数字是rgb色,第四个数字是透明度  默认透明
//    captcha.setBgColor(new Color(225, 225, 0, 100));
    //滤镜特效 默认随机特效 //曲面Curves //大理石纹Marble //弯折Double //颤动Wobble //扩散Diffuse
    captcha.setFilter(CaptchaRender.FilterFactory.Curves);
    //随机色  默认黑验证码 灰背景元素
    captcha.setRandomColor(true);
    render(captcha);
  }

效果

曲面Curves

jfinal-captcha's People

Watchers

Mr Chow avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.