drivers

package module
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Jun 17, 2020 License: BSD-3-Clause Imports: 6 Imported by: 2

README

Captchas Drivers

$ go get clevergo.tech/captchas/drivers
import "go get clevergo.tech/captchas/drivers"

Digit

// all options are optional.
opts := []drivers.DigitOption{
	drivers.DigitHeight(50),
	drivers.DigitWidth(120),
	drivers.DigitLength(6),
	drivers.DigitMaxSkew(0.8),
	drivers.DigitDotCount(80),
}
driver := drivers.NewDigit(opts...)

Audio

// all options are optional.
opts := []drivers.AudioOption{
	drivers.AudioLangauge("en"),
	drivers.AudioLength(6),
}
driver := drivers.NewAudio(opts...)

Math

// all options are optional.
opts := []drivers.MathOption{
	drivers.MathHeight(50),
	drivers.MathWidth(120),
	drivers.MathNoiseCount(0),
	drivers.MathFonts([]string{}),
	drivers.MathBGColor(&color.RGBA{}),
}
driver := drivers.NewMath(opts...)

String

// all options are optional.
opts := []drivers.StringOption{
	drivers.StringHeight(50),
	drivers.StringWidth(120),
	drivers.StringLength(4),
	drivers.StringNoiseCount(0),
	drivers.StringFonts([]string{}),
	drivers.StringSource("abcdefghijklmnopqrstuvwxyz"),
	drivers.StringBGColor(&color.RGBA{}),
}
driver := drivers.NewString(opts...)

Chinese

// all options are optional.
opts := []drivers.ChineseOption{
	drivers.ChineseHeight(50),
	drivers.ChineseWidth(120),
	drivers.ChineseLength(4),
	drivers.ChineseNoiseCount(0),
	drivers.ChineseFonts([]string{"wqy-microhei.ttc"}),
	drivers.ChineseSource("零一二三四五六七八九十"),
	drivers.ChineseBGColor(&color.RGBA{}),
}
driver := drivers.NewChinese(opts...)

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Audio

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

Audio is an audio driver.

func NewAudio

func NewAudio(opts ...AudioOption) *Audio

NewAudio returns an audio driver.

func (Audio) Generate

func (d Audio) Generate() (captchas.Captcha, error)

type AudioOption

type AudioOption func(*Audio)

AudioOption is a function that receives a pointer of audio driver.

func AudioLangauge

func AudioLangauge(language string) AudioOption

AudioLangauge sets audio language.

func AudioLength

func AudioLength(length int) AudioOption

AudioLength sets audio length.

type Captcha

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

Captcha implements captchas.Captcha interface.

func (*Captcha) Answer

func (c *Captcha) Answer() string

Answer implements Captcha.Answer.

func (*Captcha) EncodeToString

func (c *Captcha) EncodeToString() string

EncodeToString implements Captcha.EncodeToString.

func (*Captcha) HTMLField

func (c *Captcha) HTMLField(fieldName string) template.HTML

HTMLField implements Captcha.HTMLField.

func (*Captcha) ID

func (c *Captcha) ID() string

ID implements Captcha.ID.

func (*Captcha) IsTagAudio

func (c *Captcha) IsTagAudio() bool

IsTagAudio returns a bool value indicates whehter the tag is audio.

func (*Captcha) MediaAttr

func (c *Captcha) MediaAttr() template.HTMLAttr

MediaAttr returns template.HTMLAttr.

type Chinese

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

Chinese is a chinese driver.

func NewChinese

func NewChinese(opts ...ChineseOption) *Chinese

NewChinese returns a chinese driver.

func (Chinese) Generate

func (d Chinese) Generate() (captchas.Captcha, error)

type ChineseOption

type ChineseOption func(*Chinese)

ChineseOption is a function that receives a pointer of chinese driver.

func ChineseBGColor

func ChineseBGColor(color *color.RGBA) ChineseOption

ChineseBGColor sets background color.

func ChineseFonts

func ChineseFonts(fonts []string) ChineseOption

ChineseFonts sets fonts.

func ChineseHeight

func ChineseHeight(height int) ChineseOption

ChineseHeight sets height.

func ChineseLength

func ChineseLength(length int) ChineseOption

ChineseLength sets length.

func ChineseNoiseCount

func ChineseNoiseCount(count int) ChineseOption

ChineseNoiseCount sets noise count.

func ChineseSource

func ChineseSource(source string) ChineseOption

ChineseSource sets source.

func ChineseWidth

func ChineseWidth(width int) ChineseOption

ChineseWidth sets width.

type Digit

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

Digit is a digit driver.

func NewDigit

func NewDigit(opts ...DigitOption) *Digit

NewDigit return a digit driver.

func (Digit) Generate

func (d Digit) Generate() (captchas.Captcha, error)

type DigitOption

type DigitOption func(*Digit)

DigitOption is a function that receives a pointer of digit driver.

func DigitDotCount

func DigitDotCount(count int) DigitOption

DigitDotCount sets dot count.

func DigitHeight

func DigitHeight(height int) DigitOption

DigitHeight sets height.

func DigitLength

func DigitLength(length int) DigitOption

DigitLength sets length.

func DigitMaxSkew

func DigitMaxSkew(maxSkew float64) DigitOption

DigitMaxSkew sets max skew.

func DigitWidth

func DigitWidth(width int) DigitOption

DigitWidth sets width.

type Math

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

Math is a math driver.

func NewMath

func NewMath(opts ...MathOption) *Math

NewMath return a math driver.

func (Math) Generate

func (d Math) Generate() (captchas.Captcha, error)

type MathOption

type MathOption func(*Math)

MathOption is a function that receives a pointer of math driver.

func MathBGColor

func MathBGColor(color *color.RGBA) MathOption

MathBGColor sets background color.

func MathFonts

func MathFonts(fonts []string) MathOption

MathFonts sets fonts.

func MathHeight

func MathHeight(height int) MathOption

MathHeight sets height.

func MathNoiseCount

func MathNoiseCount(count int) MathOption

MathNoiseCount sets noise count.

func MathWidth

func MathWidth(width int) MathOption

MathWidth sets width.

type Str

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

Str is a string driver.

func NewString

func NewString(opts ...StringOption) *Str

NewString returns a string driver.

func (Str) Generate

func (d Str) Generate() (captchas.Captcha, error)

type StringOption

type StringOption func(*Str)

StringOption is a function that receives a pointer of string driver.

func StringBGColor

func StringBGColor(color *color.RGBA) StringOption

StringBGColor sets background color.

func StringFonts

func StringFonts(fonts []string) StringOption

StringFonts sets fonts.

func StringHeight

func StringHeight(height int) StringOption

StringHeight sets height.

func StringLength

func StringLength(length int) StringOption

StringLength sets length.

func StringNoiseCount

func StringNoiseCount(count int) StringOption

StringNoiseCount sets noise count.

func StringSource

func StringSource(source string) StringOption

StringSource sets source.

func StringWidth

func StringWidth(width int) StringOption

StringWidth sets width.

Jump to

Keyboard shortcuts

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