Documentation
¶
Index ¶
- Variables
- func CheckPoint(sx, sy, dx, dy, padding int64) booldeprecated
- func Validate(sx, sy, dx, dy, padding int) bool
- type Block
- type Builder
- type CaptData
- type Captcha
- type CaptchaData
- type DeadZoneDirectionType
- type DrawBlock
- type DrawImage
- type DrawImageParams
- type DrawTplImageParams
- type GraphImage
- type Mode
- type Option
- func WithEnableGraphVerticalRandom(val bool) Option
- func WithGenGraphNumber(val int) Option
- func WithImageAlpha(val float32) Option
- func WithImageSize(val option.Size) Option
- func WithRangeDeadZoneDirections(val []DeadZoneDirectionType) Option
- func WithRangeGraphAnglePos(vals []option.RangeVal) Option
- func WithRangeGraphSize(val option.RangeVal) Option
- type Options
- type Resource
- type Resources
Constants ¶
This section is empty.
Variables ¶
var ( GraphImageErr = errors.New("graph image is invalid") GenerateDataErr = errors.New("data generation failed") ImageTypeErr = errors.New("tile image must be of type image.Image") ShadowImageTypeErr = errors.New("tile shadow image must be of type image.Image") MaskImageTypeErr = errors.New("tile mask image must be of type image.Image") EmptyBackgroundImageErr = errors.New("no background image") )
Functions ¶
func CheckPoint
deprecated
Deprecated: As of 2.1.0, it will be removed, please use slide.Validate
Types ¶
type Block ¶
type Block struct { X int `json:"x"` Y int `json:"y"` Width int `json:"width"` Height int `json:"height"` Angle int `json:"angle"` // Deprecated: As of 2.1.0, it will be removed, please use [Block.DX]. TileX int `json:"tile_x"` // Deprecated: As of 2.1.0, it will be removed, please use [Block.DY]. TileY int `json:"tile_y"` // Display x,y DX int `json:"dx"` DY int `json:"dy"` }
Block defines the block data for the slide CAPTCHA
type Builder ¶
type Builder interface { SetOptions(opts ...Option) SetResources(resources ...Resource) Clear() Make() Captcha MakeDragDrop() Captcha // Deprecated: As of 2.1.0, it will be removed, please use [MakeDrag]. MakeWithRegion() Captcha }
Builder defines the interface for building slide CAPTCHAs
func NewBuilder ¶
NewBuilder creates a new Builder instance params:
- opts: Optional initial options
return: Builder interface instance
type CaptData ¶
type CaptData struct {
// contains filtered or unexported fields
}
CaptData is the concrete implementation of the CaptchaData interface
func (CaptData) GetMasterImage ¶
func (c CaptData) GetMasterImage() imagedata.JPEGImageData
GetMasterImage gets the main CAPTCHA image return: Main image in JPEG format
func (CaptData) GetTileImage ¶
func (c CaptData) GetTileImage() imagedata.PNGImageData
GetTileImage gets the tile image return: Tile image in PNG format
type Captcha ¶
type Captcha interface { GetOptions() *Options Generate() (CaptchaData, error) // contains filtered or unexported methods }
Captcha defines the interface for slide CAPTCHA
type CaptchaData ¶
type CaptchaData interface { GetData() *Block GetMasterImage() imagedata.JPEGImageData GetTileImage() imagedata.PNGImageData }
CaptchaData defines the interface for slide CAPTCHA data
type DeadZoneDirectionType ¶
type DeadZoneDirectionType int
const ( DeadZoneDirectionTypeLeft DeadZoneDirectionType = iota DeadZoneDirectionTypeRight DeadZoneDirectionTypeTop DeadZoneDirectionTypeBottom )
type DrawImage ¶
type DrawImage interface { DrawWithNRGBA(params *DrawImageParams) (img image.Image, bgImg image.Image, err error) DrawWithTemplate(params *DrawTplImageParams) (image.Image, error) }
DrawImage defines the interface for drawing images
func NewDrawImage ¶
func NewDrawImage() DrawImage
NewDrawImage creates a new DrawImage instance return: DrawImage interface instance
type DrawImageParams ¶
type DrawImageParams struct { Width int Height int Background image.Image Alpha float32 CaptchaDrawBlocks []*DrawBlock }
DrawImageParams defines the parameters for drawing the main image
type DrawTplImageParams ¶
type DrawTplImageParams struct { X int Y int Width int Height int Background image.Image MaskImage image.Image Alpha float32 CaptchaDrawBlock *DrawBlock }
DrawTplImageParams defines the parameters for drawing the template image (tile)
type GraphImage ¶
GraphImage defines the graph resources for the slide CAPTCHA
type Option ¶
type Option func(*Options)
func WithEnableGraphVerticalRandom ¶
WithEnableGraphVerticalRandom .
func WithRangeDeadZoneDirections ¶
func WithRangeDeadZoneDirections(val []DeadZoneDirectionType) Option
WithRangeDeadZoneDirections .
func WithRangeGraphAnglePos ¶
WithRangeGraphAnglePos .
type Options ¶
type Options struct {
// contains filtered or unexported fields
}
Options .
func (*Options) GetRangeDeadZoneDirections ¶
func (o *Options) GetRangeDeadZoneDirections() []DeadZoneDirectionType
GetRangeDeadZoneDirections .
func (*Options) GetRangeGraphAnglePos ¶
GetRangeGraphAnglePos .
func (*Options) GetRangeGraphSize ¶
GetRangeGraphSize .
type Resource ¶
type Resource func(*Resources)
func WithBackgrounds ¶
WithBackgrounds sets the background images params:
- images: List of background images
return: Resource function
func WithGraphImages ¶
func WithGraphImages(images []*GraphImage) Resource
WithGraphImages sets the graph images params:
- images: List of graph images
return: Resource function
type Resources ¶
type Resources struct {
// contains filtered or unexported fields
}
Resources defines the resource collection for the slide CAPTCHA
func NewResources ¶
func NewResources() *Resources
NewResources creates a new Resources instance return: Pointer to a Resources instance