Class CaptchaNoiseUtil

java.lang.Object
cloud.opencode.base.captcha.support.CaptchaNoiseUtil

public final class CaptchaNoiseUtil extends Object
Captcha Noise Utility - Noise generation utilities 验证码噪点工具 - 噪点生成工具

This class provides noise and distortion utilities for CAPTCHA.

此类提供验证码的噪点和干扰工具。

Features | 主要功能:

  • Noise dot generation - 噪点生成
  • Interference line drawing - 干扰线绘制
  • Curve distortion - 曲线扭曲

Usage Examples | 使用示例:

CaptchaNoiseUtil.drawNoise(graphics, config);
CaptchaNoiseUtil.drawLines(graphics, config);

Security | 安全性:

  • Thread-safe: Yes (stateless utility) - 线程安全: 是(无状态工具)
  • Null-safe: No (graphics and config must not be null) - 空值安全: 否(图形和配置不能为null)

Performance | 性能特性:

  • Time complexity: O(k) where k is the configured noise count - 时间复杂度: O(k),k 为配置的噪点数量
  • Space complexity: O(1) - no intermediate data structures - 空间复杂度: O(1) 无中间数据结构
Since:
JDK 25, opencode-base-captcha V1.0.0
Author:
Leon Soo www.LeonSoo.com
See Also:
  • Method Details

    • drawNoiseLines

      public static void drawNoiseLines(Graphics2D g, CaptchaConfig config)
      Draws noise lines on the graphics. 在图形上绘制干扰线。
      Parameters:
      g - the graphics | 图形
      config - the configuration | 配置
    • drawCurveLines

      public static void drawCurveLines(Graphics2D g, CaptchaConfig config)
      Draws curve lines on the graphics. 在图形上绘制曲线。
      Parameters:
      g - the graphics | 图形
      config - the configuration | 配置
    • drawCubicCurveLines

      public static void drawCubicCurveLines(Graphics2D g, CaptchaConfig config)
      Draws cubic curve lines on the graphics. 在图形上绘制三次曲线。
      Parameters:
      g - the graphics | 图形
      config - the configuration | 配置
    • drawNoiseDots

      public static void drawNoiseDots(Graphics2D g, CaptchaConfig config)
      Draws noise dots on the graphics. 在图形上绘制干扰点。
      Parameters:
      g - the graphics | 图形
      config - the configuration | 配置
    • drawBackgroundNoise

      public static void drawBackgroundNoise(Graphics2D g, CaptchaConfig config)
      Draws background noise. 绘制背景噪点。
      Parameters:
      g - the graphics | 图形
      config - the configuration | 配置
    • shear

      public static void shear(Graphics2D g, CaptchaConfig config)
      Draws a shear transform effect. 绘制剪切变换效果。
      Parameters:
      g - the graphics | 图形
      config - the configuration | 配置
    • drawGradientBackground

      public static void drawGradientBackground(Graphics2D g, CaptchaConfig config)
      Draws background with gradient. 绘制渐变背景。
      Parameters:
      g - the graphics | 图形
      config - the configuration | 配置
    • drawInterferencePattern

      public static void drawInterferencePattern(Graphics2D g, CaptchaConfig config)
      Draws interference pattern. 绘制干扰图案。
      Parameters:
      g - the graphics | 图形
      config - the configuration | 配置