Skip to content

Commit 4e8f6ac

Browse files
committedJun 18, 2022
update readme
1 parent e768768 commit 4e8f6ac

File tree

5 files changed

+11
-3
lines changed

5 files changed

+11
-3
lines changed
 

‎README.md

+3
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,9 @@ golang 实现普通验证码,同时支持中文汉字点击行为验证码
1919

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

22+
![](./previews/test_3.png)
23+
24+
2225
## Quick Start 使用
2326

2427
*普通验证码*

‎canvas.go

+3-1
Original file line numberDiff line numberDiff line change
@@ -147,6 +147,7 @@ func (c *Canvas) getFontPostions(text string) []Point {
147147
chCount := utf8.RuneCountInString(text)
148148

149149
var points []Point
150+
150151
if c.Config.Style == CaptchaStyle_Normal {
151152

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

165166
for i := 0; i < chCount; i++ {
166167
p := c.randomFontPosition(56)
168+
167169
points = append(points, p)
168170
}
169171
}
@@ -417,4 +419,4 @@ func (c *Canvas) DrawCircle(xc, yc, r int, fill bool, cc color.Color) {
417419
}
418420
x++
419421
}
420-
}
422+
}

‎captcha.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -128,7 +128,7 @@ func (cp *Captcha) GenCaptchaImage(text string) (CaptchaResult, error) {
128128
result.ImageBase64 = fmt.Sprintf("data:%s;base64,%s", "image/png", base64.StdEncoding.EncodeToString(imageBytes))
129129
result.Text = text
130130

131-
// writeImageFile("./previews/test.png", imageBytes)
131+
writeImageFile("./previews/test.png", imageBytes)
132132
return result, nil
133133

134134
}

‎captcha_test.go

+4-1
Original file line numberDiff line numberDiff line change
@@ -27,8 +27,11 @@ func TestGenGenBehaviorCaptcha(t *testing.T) {
2727

2828
cpt := NewCaptcha(260, 100)
2929
cpt.SetBackgroundColor(color.RGBA{R: uint8(20), G: uint8(8), B: uint8(100), A: uint8(255)})
30-
// cpt.Config.Style = CaptchaStyle_Behavior
30+
cpt.Config.Style = CaptchaStyle_Behavior
3131
cpt.Config.MaxRotate = 20
32+
33+
t.Logf("cpt.Config: %+v ", cpt.Config)
34+
3235
result, err := cpt.GenBehaviorCNCaptcha()
3336
t.Logf("GenCaptchaImage: %+v %+v", result, err)
3437
}

‎previews/test_3.png

4.38 KB
Loading

0 commit comments

Comments
 (0)
Please sign in to comment.