Configuration options for captcha text appearance and behavior.

This interface defines all the customization options available for the captcha text, including styling, positioning, and visual effects. It supports both single-style captchas and segmented captchas where different parts can have different styles.

Example: Basic Text Configuration

const options: SetCaptchaOptions = {
text: 'HELLO',
color: 'blue',
size: 60,
font: 'Arial'
};

Example: Auto-generated Text

const options: SetCaptchaOptions = {
characters: 6, // Generate 6 random characters
colors: ['red', 'blue', 'green'],
size: 50,
rotate: 15
};

Example: Segmented Styling

const segments: SetCaptchaOptions[] = [
{ text: 'SEC', color: 'red', size: 60, start: 0, end: 3 },
{ text: 'URE', color: 'blue', size: 50, start: 3, end: 6 }
];
interface SetCaptchaOptions {
    characters?: number;
    text?: string;
    color?: string;
    font?: string;
    skew?: boolean;
    colors?: string[];
    rotate?: number;
    size?: number;
    opacity?: number;
    start?: number;
    end?: number;
}

Properties

characters?: number

Number of characters to generate (ignored if text is provided)

text?: string

Custom captcha text (auto-generated if not provided)

color?: string

Text color (CSS color string, default: '#32cf7e')

font?: string

Font family name (default: 'Sans')

skew?: boolean

Whether to apply skewing transformation (default: true)

colors?: string[]

Array of colors for random selection per character

rotate?: number

Maximum rotation angle in degrees (default: 5)

size?: number

Font size in pixels (default: 40)

opacity?: number

Text opacity from 0 to 1 (default: 0.8)

start?: number

Start index for segmented text styling

end?: number

End index for segmented text styling