Module bus.extra

Class CaptchaBuilder

java.lang.Object
org.miaixz.bus.extra.captcha.CaptchaBuilder

public class CaptchaBuilder extends Object
Utility class for graphic CAPTCHA generation.
Since:
Java 17+
Author:
Kimi Liu
  • Constructor Summary

    Constructors
    Constructor
    Description
     
  • Method Summary

    Modifier and Type
    Method
    Description
    ofCircle(int width, int height)
    Creates a CAPTCHA with circle interference, default 5 characters, 15 interference circles.
    ofCircle(int width, int height, int codeCount, int circleCount)
    Creates a CAPTCHA with circle interference.
    ofCircle(int width, int height, int codeCount, int circleCount, float size)
    Creates a CAPTCHA with circle interference.
    ofGif(int width, int height)
    Creates a GIF CAPTCHA.
    ofGif(int width, int height, int codeCount)
    Creates a GIF CAPTCHA.
    ofGif(int width, int height, int codeCount, int thickness, float sizeBaseHeight)
    Creates a GIF CAPTCHA with circle interference.
    ofLine(int width, int height)
    Creates a CAPTCHA with line interference, default 5 characters, 150 interference lines.
    ofLine(int width, int height, int codeCount, int lineCount)
    Creates a CAPTCHA with line interference.
    ofLine(int width, int height, int codeCount, int lineCount, float sizeBaseHeight)
    Creates a CAPTCHA with line interference.
    ofShear(int width, int height)
    Creates a CAPTCHA with shear interference, default 5 characters.
    ofShear(int width, int height, int codeCount, int thickness)
    Creates a CAPTCHA with shear interference.
    ofShear(int width, int height, int codeCount, int thickness, float sizeBaseHeight)
    Creates a CAPTCHA with shear interference.

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Constructor Details

    • CaptchaBuilder

      public CaptchaBuilder()
  • Method Details

    • ofLine

      public static LineProvider ofLine(int width, int height)
      Creates a CAPTCHA with line interference, default 5 characters, 150 interference lines.
      Parameters:
      width - Image width.
      height - Image height.
      Returns:
      LineProvider
    • ofLine

      public static LineProvider ofLine(int width, int height, int codeCount, int lineCount)
      Creates a CAPTCHA with line interference.
      Parameters:
      width - Image width.
      height - Image height.
      codeCount - Number of characters.
      lineCount - Number of interference lines.
      Returns:
      LineProvider
    • ofLine

      public static LineProvider ofLine(int width, int height, int codeCount, int lineCount, float sizeBaseHeight)
      Creates a CAPTCHA with line interference.
      Parameters:
      width - Image width.
      height - Image height.
      codeCount - Number of characters.
      lineCount - Number of interference lines.
      sizeBaseHeight - Font size, a multiple of height.
      Returns:
      LineProvider
    • ofCircle

      public static CircleProvider ofCircle(int width, int height)
      Creates a CAPTCHA with circle interference, default 5 characters, 15 interference circles.
      Parameters:
      width - Image width.
      height - Image height.
      Returns:
      CircleProvider
    • ofCircle

      public static CircleProvider ofCircle(int width, int height, int codeCount, int circleCount)
      Creates a CAPTCHA with circle interference.
      Parameters:
      width - Image width.
      height - Image height.
      codeCount - Number of characters.
      circleCount - Number of interference circles.
      Returns:
      CircleProvider
    • ofCircle

      public static CircleProvider ofCircle(int width, int height, int codeCount, int circleCount, float size)
      Creates a CAPTCHA with circle interference.
      Parameters:
      width - Image width.
      height - Image height.
      codeCount - Number of characters.
      circleCount - Number of interference circles.
      size - Font size, a multiple of height.
      Returns:
      CircleProvider
    • ofShear

      public static ShearProvider ofShear(int width, int height)
      Creates a CAPTCHA with shear interference, default 5 characters.
      Parameters:
      width - Image width.
      height - Image height.
      Returns:
      ShearProvider
    • ofShear

      public static ShearProvider ofShear(int width, int height, int codeCount, int thickness)
      Creates a CAPTCHA with shear interference.
      Parameters:
      width - Image width.
      height - Image height.
      codeCount - Number of characters.
      thickness - Interference line thickness.
      Returns:
      ShearProvider
    • ofShear

      public static ShearProvider ofShear(int width, int height, int codeCount, int thickness, float sizeBaseHeight)
      Creates a CAPTCHA with shear interference.
      Parameters:
      width - Image width.
      height - Image height.
      codeCount - Number of characters.
      thickness - Interference line thickness.
      sizeBaseHeight - Font size, a multiple of height.
      Returns:
      ShearProvider
    • ofGif

      public static GifProvider ofGif(int width, int height)
      Creates a GIF CAPTCHA.
      Parameters:
      width - Image width.
      height - Image height.
      Returns:
      GifProvider
    • ofGif

      public static GifProvider ofGif(int width, int height, int codeCount)
      Creates a GIF CAPTCHA.
      Parameters:
      width - Image width.
      height - Image height.
      codeCount - Number of characters.
      Returns:
      GifProvider
    • ofGif

      public static GifProvider ofGif(int width, int height, int codeCount, int thickness, float sizeBaseHeight)
      Creates a GIF CAPTCHA with circle interference.
      Parameters:
      width - Image width.
      height - Image height.
      codeCount - Number of characters.
      thickness - Number of CAPTCHA interference elements.
      sizeBaseHeight - Font size, a multiple of height.
      Returns:
      GifProvider