captcha

package module
v1.0.3 Latest Latest
Warning

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

Go to latest
Published: Oct 31, 2019 License: MIT Imports: 23 Imported by: 2

README

Golang package that provides an easy to use API for captcha generation.

Usage

See example folder.

License

MIT

Documentation

Index

Constants

View Source
const DefaultCharsList = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789"

DefaultCharsList defines default list of chars for a captcha image.

Variables

This section is empty.

Functions

This section is empty.

Types

type Captcha

type Captcha struct {
	Text  string
	Image draw.Image
}

Captcha represents captcha object.

type Options

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

Options manage captcha generation details.

func NewOptions

func NewOptions() (*Options, error)

NewOptions creates new CAPTCHA options object with default values.

func (*Options) CreateImage

func (opts *Options) CreateImage() (*Captcha, error)

CreateImage creates new captcha image with specified text.

func (*Options) SetBackgroundColor

func (opts *Options) SetBackgroundColor(backgroundColor color.Color)

SetBackgroundColor sets captcha image's background color.

func (*Options) SetBorderColor

func (opts *Options) SetBorderColor(borderColor color.Color)

SetBorderColor sets captcha image's border color.

func (*Options) SetCaptchaTextLength

func (opts *Options) SetCaptchaTextLength(length int) error

SetCaptchaTextLength sets amount of characters, text lentgh, for a captcha image.

func (*Options) SetCharacterList

func (opts *Options) SetCharacterList(chars string) error

SetCharacterList sets available characters for a captcha image.

func (*Options) SetDimensions

func (opts *Options) SetDimensions(width, height int) error

SetDimensions sets captcha image widtg and height.

func (*Options) SetFontDPI

func (opts *Options) SetFontDPI(dpi float64) error

SetFontDPI sets DPI (dots per inch) for a font.

func (*Options) SetFontScale

func (opts *Options) SetFontScale(scale float64) error

SetFontScale sets scale of a font.

func (*Options) SetFontsFromData

func (opts *Options) SetFontsFromData(fontsData ...[]byte) error

SetFontsFromData sets font from bytes slice.

func (*Options) SetFontsFromPath

func (opts *Options) SetFontsFromPath(paths ...string) error

SetFontsFromPath sets font from font file.

func (*Options) SetNoiseDensity

func (opts *Options) SetNoiseDensity(dot, rect, text float64)

SetNoiseDensity sets density between noise elements.

Directories

Path Synopsis
example module

Jump to

Keyboard shortcuts

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