Documentation
¶
Index ¶
- Variables
- func CheckPoint(sx, sy, dx, dy, width, height, padding int64) booldeprecated
- func Validate(sx, sy, dx, dy, width, height, padding int) bool
- type Builder
- type CaptData
- type Captcha
- type CaptchaData
- type Dot
- type DrawDot
- type DrawImage
- type DrawImageParams
- type DrawType
- type Mode
- type Option
- func WithDisabledRangeVerifyLen(disabled bool) Option
- func WithDisplayShadow(val bool) Option
- func WithFontHinting(val font.Hinting) Option
- func WithImageAlpha(val float32) Option
- func WithImageSize(val option.Size) Option
- func WithIsThumbNonDeformAbility(val bool) Option
- func WithRangeAnglePos(vals []option.RangeVal) Option
- func WithRangeColors(colors []string) Option
- func WithRangeLen(val option.RangeVal) Option
- func WithRangeSize(val option.RangeVal) Option
- func WithRangeThumbBgCirclesNum(val int) Option
- func WithRangeThumbBgColors(val []string) Option
- func WithRangeThumbBgDistort(val int) Option
- func WithRangeThumbBgSlimLineNum(val int) Option
- func WithRangeThumbColors(val []string) Option
- func WithRangeThumbImageSize(val option.Size) Option
- func WithRangeThumbSize(val option.RangeVal) Option
- func WithRangeVerifyLen(val option.RangeVal) Option
- func WithShadowColor(val string) Option
- func WithShadowPoint(val option.Point) Option
- func WithThumbDisturbAlpha(val float32) Option
- func WithUseShapeOriginalColor(val bool) Option
- type Options
- func (o *Options) GetDisabledRangeVerifyLen() bool
- func (o *Options) GetDisplayShadow() bool
- func (o *Options) GetImageAlpha() float32
- func (o *Options) GetImageSize() *option.Size
- func (o *Options) GetIsThumbNonDeformAbility() bool
- func (o *Options) GetRangeAnglePos() []*option.RangeVal
- func (o *Options) GetRangeColors() []string
- func (o *Options) GetRangeLen() *option.RangeVal
- func (o *Options) GetRangeSize() *option.RangeVal
- func (o *Options) GetRangeThumbBgColors() []string
- func (o *Options) GetRangeThumbColors() []string
- func (o *Options) GetRangeThumbSize() *option.RangeVal
- func (o *Options) GetRangeVerifyLen() *option.RangeVal
- func (o *Options) GetShadowColor() string
- func (o *Options) GetShadowPoint() *option.Point
- func (o *Options) GetThumbBgCirclesNum() int
- func (o *Options) GetThumbBgDistort() int
- func (o *Options) GetThumbBgSlimLineNum() int
- func (o *Options) GetThumbDisturbAlpha() float32
- func (o *Options) GetThumbImageSize() *option.Size
- func (o *Options) GetUseShapeOriginalColor() bool
- type Resource
- type Resources
Constants ¶
This section is empty.
Variables ¶
var ( EmptyShapesErr = errors.New("no shapes provided") EmptyCharacterErr = errors.New("no character provided") CharRangeLenErr = errors.New("character length must be greater than rangeLen.Max") ShapesRangeLenErr = errors.New("total number of shapes must be greater than rangeLen.Max") ShapesTypeErr = errors.New("shape must be an image type") EmptyBackgroundImageErr = errors.New("no background image") ModeSupportErr = errors.New("mode is not supported") )
var ( ColorLenErr = errors.New("the color length must be less than or equal to 255") RangeVerifyLenErr = errors.New("the max value of 'rangeVerifyLen' must be less than or equal to the min value of 'rangeLen'") )
var ( ChineseCharLenErr = errors.New("the chinese char length must be equal to 1") CharLenErr = errors.New("the char length must be less than or equal to 2") )
Functions ¶
func CheckPoint
deprecated
Deprecated: As of 2.1.0, it will be removed, please use click.Validate
Types ¶
type Builder ¶
type Builder interface {
SetOptions(opts ...Option)
SetResources(resources ...Resource)
Clear()
Make() Captcha
MakeShape() Captcha
// Deprecated: As of 2.1.0, it will be removed, please use [MakeShape].
MakeWithShape() Captcha
}
Builder defines an interface for building captcha
func NewBuilder ¶
NewBuilder creates a new Builder instance 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) GetThumbImage ¶
func (c CaptData) GetThumbImage() imagedata.PNGImageData
GetThumbImage gets the thumbnail image return: Thumbnail image in PNG format
type Captcha ¶
type Captcha interface {
GetOptions() *Options
Generate(group string) (CaptchaData, error)
// contains filtered or unexported methods
}
Captcha defines the interface for captcha
type CaptchaData ¶
type CaptchaData interface {
GetData() map[int]*Dot
GetMasterImage() imagedata.JPEGImageData
GetThumbImage() imagedata.PNGImageData
}
CaptchaData defines the interface for captcha data
type Dot ¶
type Dot struct {
Index int `json:"index"`
X int `json:"x"`
Y int `json:"y"`
Size int `json:"size"`
Width int `json:"width"`
Height int `json:"height"`
Text string `json:"text"`
Shape string `json:"shape"`
Angle int `json:"angle"`
Color string `json:"color"`
Color2 string `json:"color2"`
}
Dot represents a single point (character or shape) in the captcha
type DrawDot ¶
type DrawDot struct {
Dot *Dot
X int
Y int
FontDPI int
Text string
Image image.Image
UseOriginalColor bool
Size int
Width int
Height int
Angle int
Color string
Color2 string
Font *truetype.Font
DrawType DrawType
}
DrawDot represents the dot data used for drawing
type DrawImage ¶
type DrawImage interface {
DrawWithNRGBA(params *DrawImageParams) (image.Image, error)
DrawWithPalette(params *DrawImageParams, textColors []color.Color, bgColors []color.Color) (image.Image, error)
DrawWithNRGBA2(params *DrawImageParams, textColors []color.Color, bgColors []color.Color) (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
BackgroundDistort int
BackgroundCirclesNum int
BackgroundSlimLineNum int
Alpha float32
FontHinting font.Hinting
CaptchaDrawDot []*DrawDot
ShowShadow bool
ShadowColor string
ShadowPoint *option.Point
ThumbDisturbAlpha float32
}
DrawImageParams defines the parameters for drawing images
type Option ¶
type Option func(*Options)
func WithDisabledRangeVerifyLen ¶
WithDisabledRangeVerifyLen .
func WithIsThumbNonDeformAbility ¶
WithIsThumbNonDeformAbility .
func WithRangeThumbBgCirclesNum ¶
WithRangeThumbBgCirclesNum .
func WithRangeThumbBgColors ¶
WithRangeThumbBgColors .
func WithRangeThumbBgDistort ¶
WithRangeThumbBgDistort .
func WithRangeThumbBgSlimLineNum ¶
WithRangeThumbBgSlimLineNum .
func WithRangeThumbImageSize ¶
WithRangeThumbImageSize .
func WithUseShapeOriginalColor ¶
WithUseShapeOriginalColor .
type Options ¶
type Options struct {
// contains filtered or unexported fields
}
Options defines the configuration options for the captcha
func (*Options) GetDisabledRangeVerifyLen ¶
GetDisabledRangeVerifyLen .
func (*Options) GetIsThumbNonDeformAbility ¶
GetIsThumbNonDeformAbility .
func (*Options) GetRangeAnglePos ¶
GetRangeAnglePos .
func (*Options) GetRangeThumbBgColors ¶
GetRangeThumbBgColors .
func (*Options) GetRangeThumbColors ¶
GetRangeThumbColors .
func (*Options) GetRangeThumbSize ¶
GetRangeThumbSize .
func (*Options) GetRangeVerifyLen ¶
GetRangeVerifyLen .
func (*Options) GetThumbBgCirclesNum ¶
GetThumbBgCirclesNum .
func (*Options) GetThumbBgSlimLineNum ¶
GetThumbBgSlimLineNum .
func (*Options) GetThumbDisturbAlpha ¶
GetThumbDisturbAlpha .
func (*Options) GetThumbImageSize ¶
GetThumbImageSize .
func (*Options) GetUseShapeOriginalColor ¶
GetUseShapeOriginalColor .
type Resource ¶
type Resource func(*Resources)
func WithBackgrounds ¶
WithBackgrounds is to set background image
func WithShapes ¶
WithShapes is to set shape
func WithThumbBackgrounds ¶
WithThumbBackgrounds is to set thumbnail background image