Documentation ¶
Index ¶
- Constants
- func CheckPointDist(cds []CheckDots, dots map[int]CharDot, paddings ...int64) bool
- type AreaPoint
- type CharDot
- type CheckDots
- type ClickCaptcha
- type ClickCaptchaConfig
- type ClickCaptchaConfigOption
- func InjectCompleteGB2312CharsConfig(v bool) ClickCaptchaConfigOption
- func InjectFontConfig(fonts []string, args ...bool) ClickCaptchaConfigOption
- func InjectImageSizeConfig(width, height int) ClickCaptchaConfigOption
- func InjectRangCheckTextLenConfig(min, max int) ClickCaptchaConfigOption
- func InjectTextRangLenConfig(min, max int) ClickCaptchaConfigOption
- type CustomCompleteGB2312Chars
- type CustomImageSize
- type CustomRangCheckTextLen
- type CustomRangFont
- type CustomTextRangLen
- type DrawCanvas
- type DrawDot
- type Drawing
- func (cd *Drawing) CreateCanvas(params DrawCanvas, isAlpha bool) (img *image.NRGBA)
- func (cd *Drawing) CreateCanvasWithPalette(params DrawCanvas, colorArr []color.RGBA) *Palette
- func (cd *Drawing) Draw(params DrawCanvas) (image.Image, error)
- func (cd *Drawing) DrawStrImg(dot DrawDot, colorArr []color.RGBA, fc color.Color) *Palette
- func (cd *Drawing) DrawTextImg(dot DrawDot, params DrawCanvas) (*Palette, *AreaPoint, error)
- func (cd *Drawing) DrawWithPalette(params DrawCanvas, colorA []color.Color, colorB []color.Color) (image.Image, error)
- type Palette
- type Point
- type RangeVal
- type Size
Constants ¶
const ( //DistortNone 无扭曲 DistortNone = iota //DistortLevel1 扭曲程度 1级别 DistortLevel1 //DistortLevel2 扭曲程度 2级别 DistortLevel2 //DistortLevel3 扭曲程度 3级别 DistortLevel3 //DistortLevel4 扭曲程度 4级别 DistortLevel4 //DistortLevel5 扭曲程度 5级别 DistortLevel5 )
const ( //QualityCompressNone 无压缩质量,原图 QualityCompressNone = iota //QualityCompressLevel1 质量压缩程度 1-5 级别,压缩级别越低图像越清晰 QualityCompressLevel1 = 100 //QualityCompressLevel2 质量压缩程度 1-5 级别,压缩级别越低图像越清晰 QualityCompressLevel2 = 80 //QualityCompressLevel3 质量压缩程度 1-5 级别,压缩级别越低图像越清晰 QualityCompressLevel3 = 60 //QualityCompressLevel4 质量压缩程度 1-5 级别,压缩级别越低图像越清晰 QualityCompressLevel4 = 40 //QualityCompressLevel5 质量压缩程度 1-5 级别,压缩级别越低图像越清晰 QualityCompressLevel5 = 20 )
Variables ¶
This section is empty.
Functions ¶
Types ¶
type CharDot ¶
type CharDot struct { // 顺序索引 Index int // x,y位置 Dx int Dy int // 字体大小 Size int // 字体宽 Width int // 字体高 Height int // 字符文本 Text string // 字体角度 Angle int // 颜色 Color string // 颜色2 Color2 string }
CharDot 图片点数据
type ClickCaptcha ¶
type ClickCaptcha struct {
// contains filtered or unexported fields
}
ClickCaptcha 点选验证码
func NewClickCaptcha ¶
func NewClickCaptcha(opts ...ClickCaptchaConfigOption) *ClickCaptcha
NewClickCaptcha 创建点选验证码
func (*ClickCaptcha) GenerateClickCaptcha ¶
GenerateClickCaptcha 生成点选验证码
type ClickCaptchaConfig ¶
type ClickCaptchaConfig struct { //是否使用完整的GB2312汉字 HasCompleteGB2312Chars bool // contains filtered or unexported fields }
ClickCaptchaConfig 点选验证码配置
func GetClickCaptchaDefaultConfig ¶
func GetClickCaptchaDefaultConfig() *ClickCaptchaConfig
GetClickCaptchaDefaultConfig 获取点选验证码默认配置
type ClickCaptchaConfigOption ¶
type ClickCaptchaConfigOption interface {
Join(settings *ClickCaptcha) error
}
ClickCaptchaConfigOption 点选验证码配置
func InjectCompleteGB2312CharsConfig ¶
func InjectCompleteGB2312CharsConfig(v bool) ClickCaptchaConfigOption
InjectCompleteGB2312CharsConfig 设置是否使用GB2312字符集
func InjectFontConfig ¶
func InjectFontConfig(fonts []string, args ...bool) ClickCaptchaConfigOption
InjectFontConfig 设置字体配置
func InjectImageSizeConfig ¶
func InjectImageSizeConfig(width, height int) ClickCaptchaConfigOption
InjectImageSizeConfig 设置验证码图片尺寸
func InjectRangCheckTextLenConfig ¶
func InjectRangCheckTextLenConfig(min, max int) ClickCaptchaConfigOption
InjectRangCheckTextLenConfig 设置随机验证字符串长度范围
func InjectTextRangLenConfig ¶
func InjectTextRangLenConfig(min, max int) ClickCaptchaConfigOption
InjectTextRangLenConfig 设置字符随机长度范围
type CustomCompleteGB2312Chars ¶
type CustomCompleteGB2312Chars struct {
// contains filtered or unexported fields
}
CustomCompleteGB2312Chars is CustomCompleteGB2312Chars
func (CustomCompleteGB2312Chars) Join ¶
func (w CustomCompleteGB2312Chars) Join(o *ClickCaptcha) error
Join CustomCompleteGB2312Chars.Join
type CustomImageSize ¶
type CustomImageSize struct {
// contains filtered or unexported fields
}
CustomImageSize is CustomImageSize
func (CustomImageSize) Join ¶
func (w CustomImageSize) Join(o *ClickCaptcha) error
Join CustomImageSize.Join
type CustomRangCheckTextLen ¶
type CustomRangCheckTextLen struct {
// contains filtered or unexported fields
}
CustomRangCheckTextLen is CustomRangCheckTextLen
func (CustomRangCheckTextLen) Join ¶
func (w CustomRangCheckTextLen) Join(o *ClickCaptcha) error
Join CustomRangCheckTextLen.Join
type CustomRangFont ¶
type CustomRangFont struct {
// contains filtered or unexported fields
}
CustomRangFont is CustomRangFont
func (CustomRangFont) Join ¶
func (w CustomRangFont) Join(o *ClickCaptcha) error
Join CustomRangFont.Join
type CustomTextRangLen ¶
type CustomTextRangLen struct {
// contains filtered or unexported fields
}
CustomTextRangLen is CustomTextRangLen
func (CustomTextRangLen) Join ¶
func (w CustomTextRangLen) Join(o *ClickCaptcha) error
Join CustomTextRangLen.Join
type DrawCanvas ¶
type DrawCanvas struct { // 长、高 Width int Height int // 背景图片 Background string // 缩略图扭曲程度,值为 Distort..., BackgroundDistort int // 缩略图小圆点数量 BackgroundCirclesNum int // 缩略图线条数量 BackgroundSlimLineNum int // 文本透明度 TextAlpha float64 // FontHinting FontHinting font.Hinting // 点 CaptchaDrawDot []DrawDot // 文本阴影偏移位置 ShowTextShadow bool // 文本阴影颜色 TextShadowColor string // 文本阴影偏移位置 TextShadowPoint Point }
DrawCanvas 绘制画布
type DrawDot ¶
type DrawDot struct { Dx int Dy int FontDPI int Text string Size int Width int Height int Angle int Color string Color2 string Font string }
DrawDot 绘制点
type Drawing ¶
type Drawing struct{}
Drawing 绘制
func (*Drawing) CreateCanvas ¶
func (cd *Drawing) CreateCanvas(params DrawCanvas, isAlpha bool) (img *image.NRGBA)
CreateCanvas 创建画布
func (*Drawing) CreateCanvasWithPalette ¶
func (cd *Drawing) CreateCanvasWithPalette(params DrawCanvas, colorArr []color.RGBA) *Palette
CreateCanvasWithPalette 创建带调色板的画布
func (*Drawing) DrawStrImg ¶
DrawStrImg 绘制字符图片
func (*Drawing) DrawTextImg ¶
DrawTextImg 绘制文本的图片