puzzlecaptcha

package module
v0.1.5 Latest Latest
Warning

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

Go to latest
Published: May 31, 2024 License: MIT Imports: 5 Imported by: 0

README

PUZZLE-CAPTCHA

一个简易的滑动图形验证码图片处理。

USAGE

f, _ := os.Open("image.png")
img, _ := png.Decode(f)
c := NewPuzzleCaptcha(img, 50, 2)
base, hole := c.Generate()

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	// Alpha represents the distance from the intersection points of the circle
	// with the inner rectangle to the outer rectangle.
	Alpha = 1.8
)

Functions

This section is empty.

Types

type Option

type Option func(m *PuzzleMask)

func WithHoles

func WithHoles(holes int) Option

func WithMaskType

func WithMaskType(masktype PuzzleMaskType) Option

func WithNotches

func WithNotches(notches int) Option

type PuzzleCaptcha

type PuzzleCaptcha interface {
	Generate() (image.Image, image.Image)
	HoleRect() image.Rectangle
}

func NewPuzzleCaptcha

func NewPuzzleCaptcha(origin image.Image, holesize, maxholes int) PuzzleCaptcha

type PuzzleMask

type PuzzleMask struct {

	// binary number 0b0001
	// These four bits respectively represent up, down, left, and right.
	Holes int
	// contains filtered or unexported fields
}

func NewPuzzleMask

func NewPuzzleMask(whole, hole image.Rectangle, options ...Option) *PuzzleMask

func (*PuzzleMask) At

func (m *PuzzleMask) At(x, y int) color.Color

func (*PuzzleMask) Bounds

func (m *PuzzleMask) Bounds() image.Rectangle

func (*PuzzleMask) ColorModel

func (m *PuzzleMask) ColorModel() color.Model

type PuzzleMaskType

type PuzzleMaskType int
const (
	HoleType PuzzleMaskType = iota
	BaseType
)

Jump to

Keyboard shortcuts

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