Skip to content

Commit

Permalink
update readme
Browse files Browse the repository at this point in the history
  • Loading branch information
feiin committed Jun 18, 2022
1 parent e768768 commit 4e8f6ac
Show file tree
Hide file tree
Showing 5 changed files with 11 additions and 3 deletions.
3 changes: 3 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,9 @@ golang 实现普通验证码,同时支持中文汉字点击行为验证码

![](./previews/test_2.png)

![](./previews/test_3.png)


## Quick Start 使用

*普通验证码*
Expand Down
4 changes: 3 additions & 1 deletion canvas.go
Original file line number Diff line number Diff line change
Expand Up @@ -147,6 +147,7 @@ func (c *Canvas) getFontPostions(text string) []Point {
chCount := utf8.RuneCountInString(text)

var points []Point

if c.Config.Style == CaptchaStyle_Normal {

padding := c.Config.FontSize / 2
Expand All @@ -164,6 +165,7 @@ func (c *Canvas) getFontPostions(text string) []Point {

for i := 0; i < chCount; i++ {
p := c.randomFontPosition(56)

points = append(points, p)
}
}
Expand Down Expand Up @@ -417,4 +419,4 @@ func (c *Canvas) DrawCircle(xc, yc, r int, fill bool, cc color.Color) {
}
x++
}
}
}
2 changes: 1 addition & 1 deletion captcha.go
Original file line number Diff line number Diff line change
Expand Up @@ -128,7 +128,7 @@ func (cp *Captcha) GenCaptchaImage(text string) (CaptchaResult, error) {
result.ImageBase64 = fmt.Sprintf("data:%s;base64,%s", "image/png", base64.StdEncoding.EncodeToString(imageBytes))
result.Text = text

// writeImageFile("./previews/test.png", imageBytes)
writeImageFile("./previews/test.png", imageBytes)
return result, nil

}
Expand Down
5 changes: 4 additions & 1 deletion captcha_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,11 @@ func TestGenGenBehaviorCaptcha(t *testing.T) {

cpt := NewCaptcha(260, 100)
cpt.SetBackgroundColor(color.RGBA{R: uint8(20), G: uint8(8), B: uint8(100), A: uint8(255)})
// cpt.Config.Style = CaptchaStyle_Behavior
cpt.Config.Style = CaptchaStyle_Behavior
cpt.Config.MaxRotate = 20

t.Logf("cpt.Config: %+v ", cpt.Config)

result, err := cpt.GenBehaviorCNCaptcha()
t.Logf("GenCaptchaImage: %+v %+v", result, err)
}
Expand Down
Binary file added previews/test_3.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.

0 comments on commit 4e8f6ac

Please sign in to comment.