captcha

package
v1.0.1 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Feb 18, 2022 License: MIT Imports: 16 Imported by: 0

Documentation

Index

Constants

View Source
const (
	//DistortNone 无扭曲
	DistortNone = iota
	//DistortLevel1 扭曲程度 1级别
	DistortLevel1
	//DistortLevel2 扭曲程度 2级别
	DistortLevel2
	//DistortLevel3 扭曲程度 3级别
	DistortLevel3
	//DistortLevel4 扭曲程度 4级别
	DistortLevel4
	//DistortLevel5 扭曲程度 5级别
	DistortLevel5
)
View Source
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

func CheckPointDist

func CheckPointDist(cds []CheckDots, dots map[int]CharDot, paddings ...int64) bool

CheckPointDist 验证点选数据

Types

type AreaPoint

type AreaPoint struct {
	MinX, MaxX, MinY, MaxY int
}

AreaPoint 区域点信息

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 CheckDots

type CheckDots struct {
	X int `json:"x"`
	Y int `json:"y"`
}

CheckDots 验证位置

type ClickCaptcha

type ClickCaptcha struct {
	// contains filtered or unexported fields
}

ClickCaptcha 点选验证码

func NewClickCaptcha

func NewClickCaptcha(opts ...ClickCaptchaConfigOption) *ClickCaptcha

NewClickCaptcha 创建点选验证码

func (*ClickCaptcha) GenerateClickCaptcha

func (cc *ClickCaptcha) GenerateClickCaptcha() (map[int]CharDot, string, string, string, error)

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

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

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

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) Draw

func (cd *Drawing) Draw(params DrawCanvas) (image.Image, error)

Draw 绘制

func (*Drawing) DrawStrImg

func (cd *Drawing) DrawStrImg(dot DrawDot, colorArr []color.RGBA, fc color.Color) *Palette

DrawStrImg 绘制字符图片

func (*Drawing) DrawTextImg

func (cd *Drawing) DrawTextImg(dot DrawDot, params DrawCanvas) (*Palette, *AreaPoint, error)

DrawTextImg 绘制文本的图片

func (*Drawing) DrawWithPalette

func (cd *Drawing) DrawWithPalette(params DrawCanvas, colorA []color.Color, colorB []color.Color) (image.Image, error)

DrawWithPalette 使用调色板的画布绘图

type Palette

type Palette struct {
	*image.Paletted
}

Palette 调色板

func NewPalette

func NewPalette(r image.Rectangle, p color.Palette) *Palette

NewPalette 创建调色板

func (*Palette) Rotate

func (p *Palette) Rotate(angle int)

Rotate 旋转任意角度

type Point

type Point struct {
	X, Y int
}

Point 点位置

type RangeVal

type RangeVal struct {
	Min, Max int
}

RangeVal 范围值

type Size

type Size struct {
	Width, Height int
}

Size 尺寸

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL