This commit is contained in:
Looly
2020-04-11 13:08:46 +08:00
parent 73fd3b849f
commit bc486cdac4
207 changed files with 1329 additions and 1355 deletions

View File

@@ -1,16 +1,16 @@
package cn.hutool.captcha;
import cn.hutool.core.img.GraphicsUtil;
import cn.hutool.core.img.ImgUtil;
import cn.hutool.core.util.ObjectUtil;
import cn.hutool.core.util.RandomUtil;
import java.awt.Color;
import java.awt.Graphics;
import java.awt.Graphics2D;
import java.awt.Image;
import java.awt.image.BufferedImage;
import cn.hutool.core.img.GraphicsUtil;
import cn.hutool.core.img.ImgUtil;
import cn.hutool.core.util.ObjectUtil;
import cn.hutool.core.util.RandomUtil;
/**
* 扭曲干扰验证码
*
@@ -110,18 +110,15 @@ public class ShearCaptcha extends AbstractCaptcha {
int period = RandomUtil.randomInt(this.width);
boolean borderGap = true;
int frames = 1;
int phase = RandomUtil.randomInt(2);
for (int i = 0; i < h1; i++) {
double d = (double) (period >> 1) * Math.sin((double) i / (double) period + (6.2831853071795862D * (double) phase) / (double) frames);
g.copyArea(0, i, w1, 1, (int) d, 0);
if (borderGap) {
g.setColor(color);
g.drawLine((int) d, i, 0, i);
g.drawLine((int) d + w1, i, w1, i);
}
g.setColor(color);
g.drawLine((int) d, i, 0, i);
g.drawLine((int) d + w1, i, w1, i);
}
}
@@ -162,6 +159,7 @@ public class ShearCaptcha extends AbstractCaptcha {
* @param thickness 粗细
* @param c 颜色
*/
@SuppressWarnings("SameParameterValue")
private void drawInterfere(Graphics g, int x1, int y1, int x2, int y2, int thickness, Color c) {
// The thick line is in fact a filled polygon

View File

@@ -16,7 +16,7 @@ public class MathGenerator implements CodeGenerator {
private static final String operators = "+-*";
/** 参与计算数字最大长度 */
private int numberLength;
private final int numberLength;
/**
* 构造