LogoAntiRaid

@antiraid-core/plugins/img_captcha

API reference for @antiraid-core/plugins/img_captcha

@antiraid-core/plugins/img_captcha

Types

Geometry

Represents the area which contains text in a CAPTCHA.

Raw Type
--- Represents the area which contains text in a CAPTCHA.
type Geometry = {
	--- The minimum x coordinate of the area which contains text (inclusive).
	---
	--- Max size: u32
	left: number,

	--- The maximum x coordinate of the area which contains text (inclusive).
	---
	--- Max size: u32
	right: number,

	--- The minimum y coordinate of the area which contains text (inclusive).
	---
	--- Max size: u32
	top: number,

	--- The maximum y coordinate of the area which contains text (inclusive).
	--- 
	--- Max size: u32
	bottom: number
}
PropTypeDescription
left
The minimum x coordinate of the area which contains text (inclusive).Max size: u32
right
The maximum x coordinate of the area which contains text (inclusive).Max size: u32
top
The minimum y coordinate of the area which contains text (inclusive).Max size: u32
bottom
The maximum y coordinate of the area which contains text (inclusive).Max size: u32

SerdeColor

Represents a color in RGB format.

Raw Type
--- Represents a color in RGB format.
type SerdeColor = {
	--- The red component of the color (0-255)
	r: number,

	--- The green component of the color (0-255)
	g: number,

	--- The blue component of the color (0-255)
	b: number
}
PropTypeDescription
r
The red component of the color (0-255)
g
The green component of the color (0-255)
b
The blue component of the color (0-255)

ColorInvertFilter

Filter that inverts the colors of an image.

Raw Type
--- Filter that inverts the colors of an image.
type ColorInvertFilter = {
	filter: "ColorInvert"
}
PropTypeDescription
filter
'ColorInvert'
-

CowFilter

Filter that generates a CAPTCHA with a specified number of cows (circles/other curvical noise)

Raw Type
--- Filter that generates a CAPTCHA with a specified number of cows (circles/other curvical noise)
type CowFilter = {
	filter: "Cow",

	--- The minimum radius of the cows
	---
	--- Max size: u32
	min_radius: number,

	--- The maximum radius of the cows
	---
	--- Max size: u32
	max_radius: number,

	--- The number of cows to generate
	---
	--- Max size: u32
	n: number,

	--- Whether to allow duplicate cows
	allow_duplicates: boolean,

	--- The geometry of the area which contains text
	geometry: Geometry?
}
PropTypeDescription
filter
'Cow'
-
min_radius
The minimum radius of the cowsMax size: u32
max_radius
The maximum radius of the cowsMax size: u32
n
The number of cows to generateMax size: u32
allow_duplicates
Whether to allow duplicate cows
geometry?
The geometry of the area which contains text

DotFilter

Filter that creates a specified number of dots

Raw Type
--- Filter that creates a specified number of dots
type DotFilter = {
	filter: "Dot",

	--- The number of dots to generate
	---
	--- Max size: u32
	n: number,

	--- The minimum radius of the dots
	---
	--- Max size: u32
	min_radius: number,

	--- The maximum radius of the dots
	---
	--- Max size: u32
	max_radius: number
}
PropTypeDescription
filter
'Dot'
-
n
The number of dots to generateMax size: u32
min_radius
The minimum radius of the dotsMax size: u32
max_radius
The maximum radius of the dotsMax size: u32

GridFilter

Filter that creates a grid (horizontal/vertical lines with a specified gap in X and Y direction)

(think graph paper)

Raw Type
--- Filter that creates a grid (horizontal/vertical lines with a specified gap in X and Y direction)
---
--- (think graph paper)
type GridFilter = {
	filter: "Grid",

	--- The Y gap between the vertical lines
	---
	--- Max size: u32
	y_gap: number,

	--- The X gap between the horizontal linesPrimitives.u32
	---
	--- Max size: u32
	x_gap: number
}
PropTypeDescription
filter
'Grid'
-
y_gap
The Y gap between the vertical linesMax size: u32
x_gap
The X gap between the horizontal linesPrimitives.u32Max size: u32

LineFilter

Draw lines/rectangles on the screen

Raw Type
--- Draw lines/rectangles on the screen
type LineFilter = {
	filter: "Line",

	--- Point 1, must be an array of two numbers
	---
	--- Max size: f32
	p1: {number},

	--- Point 2, must be an array of two numbers
	---
	--- Max size: f32
	p2: {number},

	--- The thickness of the line
	---
	--- Max size: u32
	thickness: number,

	--- The color of the line
	color: SerdeColor
}
PropTypeDescription
filter
'Line'
-
p1
Point 1, must be an array of two numbersMax size: f32
p2
Point 2, must be an array of two numbersMax size: f32
thickness
The thickness of the lineMax size: u32
color
The color of the line

NoiseFilter

Adds some random noise at a specified probability

Raw Type
--- Adds some random noise at a specified probability
type NoiseFilter = {
	filter: "Noise",

	--- The probability of adding noise
	---
	--- Max size: f32
	prob: number
}
PropTypeDescription
filter
'Noise'
-
prob
The probability of adding noiseMax size: f32

RandomLineFilter

Creates a random line somewhere

Raw Type
--- Creates a random line somewhere
type RandomLineFilter = {
	filter: "RandomLine"
}
PropTypeDescription
filter
'RandomLine'
-

WaveFilter

Creates a wave in a given direction (horizontal/vertical)

Raw Type
--- Creates a wave in a given direction (horizontal/vertical)
type WaveFilter = {
	filter: "Wave",

	--- The frequency of the wave
	---
	--- Max size: f32
	f: number,

	--- The amplitude of the wave
	---
	--- Max size: f32
	amp: number,

	--- The direction of the wave
	d: "horizontal" | "vertical"
}
PropTypeDescription
filter
'Wave'
-
f
The frequency of the waveMax size: f32
amp
The amplitude of the waveMax size: f32
d
('horizontal' | 'vertical')
The direction of the wave

Filter

Represents a filter that can be applied to an image.

Raw Type
--- Represents a filter that can be applied to an image.
type Filter = ColorInvertFilter | CowFilter | DotFilter | GridFilter | LineFilter | NoiseFilter | RandomLineFilter | WaveFilter

Union with variants:

Variant 1

ColorInvertFilter

Variant 2

CowFilter

Variant 3

DotFilter

Variant 4

GridFilter

Variant 5

LineFilter

Variant 6

NoiseFilter

Variant 7

RandomLineFilter

Variant 8

WaveFilter

CaptchaConfig

Captcha configuration

Raw Type
--- Captcha configuration
type CaptchaConfig = {
	--- The number of characters the CAPTCHA should have (0-255)
	char_count: number,

	--- The list of filters
	filters: {Filter},

	--- The size of the viewbox to render the CAPTCHA in.
	--- (first element is width, second element is height)
	---
	--- Max size: u32
	viewbox_size: {number},

	--- At what index of CAPTCHA generation should a viewbox be created at.
	---
	--- Max size: u32
	set_viewbox_at_idx: number
}
PropTypeDescription
char_count
The number of characters the CAPTCHA should have (0-255)
filters
The list of filters
viewbox_size
The size of the viewbox to render the CAPTCHA in.(first element is width, second element is height)Max size: u32
set_viewbox_at_idx
At what index of CAPTCHA generation should a viewbox be created at.Max size: u32

Captcha

Raw Type
type Captcha = {
	--- The text of the CAPTCHA.
	text: string,

	--- The image of the CAPTCHA (Luau buffer).
	image: buffer
}
PropTypeDescription
text
The text of the CAPTCHA.
image
The image of the CAPTCHA (Luau buffer).

Plugin

Raw Type
type Plugin = {
	--- @yields
	---
	--- Creates a new CAPTCHA with the given configuration.
	Create: (config: CaptchaConfig) -> Captcha
}
PropTypeDescription
Create
(config: CaptchaConfig) -> Captcha
@yields Creates a new CAPTCHA with the given configuration.

Last updated on