rotate

package
v2.0.7 Latest Latest
Warning

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

Go to latest
Published: Jun 13, 2025 License: Apache-2.0 Imports: 10 Imported by: 1

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ErrEmptyImage = errors.New("no image")
View Source
var ErrImageType = errors.New("image must be is image.Image type")

Functions

func CheckAngle deprecated

func CheckAngle(angle, dAngle, padding int64) bool

Deprecated: As of 2.1.0, it will be removed, please use rotate.Validate

func Validate added in v2.0.7

func Validate(angle, dAngle, padding int) bool

Validate checks if the rotation angle is within the specified range params:

  • angle: Current angle
  • dAngle: Target angle
  • padding: Angle padding

return: Whether within range

Types

type Block

type Block struct {
	// Deprecated: As of 2.1.0, it will be removed, please use [[CaptchaInstance].GetOptions().GetImageSize()].
	ParentWidth int `json:"parent_width"`
	// Deprecated: As of 2.1.0, it will be removed, please use [[CaptchaInstance].GetOptions().GetImageSize()].
	ParentHeight int `json:"parent_height"`
	Width        int `json:"width"`
	Height       int `json:"height"`
	Angle        int `json:"angle"`
}

Block ..

type Builder

type Builder interface {
	SetOptions(opts ...Option)
	SetResources(resources ...Resource)
	Clear()
	Make() Captcha
}

Builder defines the interface for building rotate CAPTCHAs

func NewBuilder

func NewBuilder(opts ...Option) Builder

NewBuilder creates a new Builder instance params:

  • opts: Optional initial options

return: Builder interface instance

type CaptData

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

CaptData is the concrete implementation of the CaptchaData interface

func (CaptData) GetData

func (c CaptData) GetData() *Block

GetData is to get block

func (CaptData) GetMasterImage

func (c CaptData) GetMasterImage() imagedata.PNGImageData

GetMasterImage is to get master image

func (CaptData) GetThumbImage

func (c CaptData) GetThumbImage() imagedata.PNGImageData

GetThumbImage is to get thumb image

type Captcha

type Captcha interface {
	GetOptions() *Options
	Generate() (CaptchaData, error)
	// contains filtered or unexported methods
}

Captcha defines the interface for rotate CAPTCHA

type CaptchaData

type CaptchaData interface {
	GetData() *Block
	GetMasterImage() imagedata.PNGImageData
	GetThumbImage() imagedata.PNGImageData
}

CaptchaData defines the interface for rotate CAPTCHA data

type DrawBlock

type DrawBlock struct {
	Block  *Block
	X      int
	Y      int
	Width  int
	Height int
	Angle  int
}

DrawBlock .

type DrawCropCircleImageParams

type DrawCropCircleImageParams struct {
	ScaleRatioSize int
	Rotate         int
	SquareSize     int
	Background     image.Image
	Alpha          float32
}

DrawCropCircleImageParams defines the parameters for drawing a cropped circle image

type DrawImage

type DrawImage interface {
	DrawWithNRGBA(params *DrawImageParams) (img image.Image, err error)
	DrawWithCropCircle(params *DrawCropCircleImageParams) (image.Image, error)
}

DrawImage defines the interface for drawing images

func NewDrawImage

func NewDrawImage() DrawImage

NewDrawImage creates a new DrawImage instance return: DrawImage interface instance

type DrawImageParams

type DrawImageParams struct {
	Rotate     int
	SquareSize int
	Background image.Image
	Alpha      float32
}

DrawImageParams defines the parameters for drawing the main image

type Option

type Option func(*Options)

func WithImageSquareSize

func WithImageSquareSize(val int) Option

WithImageSquareSize .

func WithRangeAnglePos

func WithRangeAnglePos(vals []option.RangeVal) Option

WithRangeAnglePos .

func WithRangeThumbImageSquareSize

func WithRangeThumbImageSquareSize(val []int) Option

WithRangeThumbImageSquareSize .

func WithThumbImageAlpha

func WithThumbImageAlpha(val float32) Option

WithThumbImageAlpha .

type Options

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

func NewOptions

func NewOptions() *Options

NewOptions .

func (*Options) GetImageSize

func (o *Options) GetImageSize() int

GetImageSize .

func (*Options) GetRangeAngle

func (o *Options) GetRangeAngle() []*option.RangeVal

GetRangeAngle .

func (*Options) GetRangeThumbImageSquareSize

func (o *Options) GetRangeThumbImageSquareSize() []int

GetRangeThumbImageSquareSize .

func (*Options) GetThumbImageAlpha

func (o *Options) GetThumbImageAlpha() float32

GetThumbImageAlpha .

type Resource

type Resource func(*Resources)

func WithImages

func WithImages(images []image.Image) Resource

WithImages is to set image

type Resources

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

Resources defines the resources for the rotate CAPTCHA

func NewResources

func NewResources() *Resources

NewResources .

Jump to

Keyboard shortcuts

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