Documentation ¶
Index ¶
- Variables
- func GetCaptchaBase64(width, height, n int) (base64Str, text string)
- func GetFont(dirpath, fontName string) (*truetype.Font, error)
- func GetRandColor() color.RGBA
- func GetRandDeepColor() color.RGBA
- func GetRandFont() (*truetype.Font, error)
- func GetRandLightColor() color.RGBA
- func GetRandText(n int) string
- func GetSingleCaptcha(width, height, n int) (pth, text string)
- func LoadFonts(dirpath string) (err error)
- type CaptchaImage
- func (c *CaptchaImage) DrawCircle(maxsize int, count int)
- func (c *CaptchaImage) DrawNoise()
- func (c *CaptchaImage) DrawSinLine()
- func (c *CaptchaImage) DrawText() error
- func (c *CaptchaImage) GetText() string
- func (c *CaptchaImage) ImageToBaseb64(format int) string
- func (c *CaptchaImage) SaveImage(saveFolder string, imageFormat int) (pth string, err error)
Constants ¶
This section is empty.
Variables ¶
var FontFamily []string
FontFamily a slice stores the all fonts path
Functions ¶
func GetCaptchaBase64 ¶
GetCaptchaBase64 This shortcut function contains several functions for generating captchaimage. You can directly generate a captchaimage that encoded base64(or base64url) mode and its corresponding captcha through this function
func GetRandLightColor ¶
GetRandLightColor Get a random light color
func GetSingleCaptcha ¶
GetSingleCaptcha This shortcut function contains several functions for generating captchaimage. You can directly generate a captchaimage and save it through this function It's return stored Image's path and Captcha text
Types ¶
type CaptchaImage ¶
type CaptchaImage struct {
// contains filtered or unexported fields
}
CaptchaImage text is the captcha writed in the image
func NewCaptchaImage ¶
func NewCaptchaImage(width, height, n int, bgColor color.RGBA) *CaptchaImage
NewCaptchaImage initialization of the captchaimage struct
func (*CaptchaImage) DrawCircle ¶
func (c *CaptchaImage) DrawCircle(maxsize int, count int)
DrawCirlce maxsize : the max redius the one circle may have ;count: the number of circle The algorithm is parametric equations that x=r*sin(a) y=r*cos(a)
func (*CaptchaImage) DrawSinLine ¶
func (c *CaptchaImage) DrawSinLine()
DrawSinLine Draw a sine curve
func (*CaptchaImage) DrawText ¶
func (c *CaptchaImage) DrawText() error
DrawText write the test on image
func (*CaptchaImage) GetText ¶
func (c *CaptchaImage) GetText() string
GetText return CaptchaImage's text
func (*CaptchaImage) ImageToBaseb64 ¶
func (c *CaptchaImage) ImageToBaseb64(format int) string
ImageToBaseb64 encode image to base64 or base64url mode