1
2
3
4
5
6
7 package com.octo.captcha.component.image.fontgenerator;
8
9 import java.awt.*;
10 import java.awt.geom.AffineTransform;
11
12 /***
13 * <p>Description: </p>
14 *
15 * @author <a href="mailto:mag@jcaptcha.net">Marc-Antoine Garrigue</a>
16 * @version 1.0
17 */
18 public class TwistedAndShearedRandomFontGenerator
19 extends TwistedRandomFontGenerator {
20
21 public TwistedAndShearedRandomFontGenerator(Integer minFontSize,
22 Integer maxFontSize) {
23 super(minFontSize, maxFontSize);
24 }
25
26
27 /***
28 * Provides a way for children class to customize the generated font array
29 *
30 * @param font
31 * @return a customized font
32 */
33 protected Font applyCustomDeformationOnGeneratedFont(Font font) {
34 font = super.applyCustomDeformationOnGeneratedFont(font);
35 double rx = myRandom.nextDouble() / 3;
36 double ry = myRandom.nextDouble() / 3;
37 AffineTransform at = AffineTransform.getShearInstance(rx, ry);
38 return font.deriveFont(at);
39 }
40
41 }