Skip to content

Commit 869078f

Browse files
committed
docs(base64Captcha): 更新 README.md 中的示例代码
- 在各个示例中添加了 Source、Fonts 和 BgColor等自定义配置参数 - 优化了代码格式,提高了可读性 - 这些修改使示例更加详细,便于用户理解如何自定义验证码
1 parent 68f79d5 commit 869078f

File tree

1 file changed

+38
-35
lines changed

1 file changed

+38
-35
lines changed

README.md

Lines changed: 38 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -48,10 +48,13 @@ base64Driver := driver.DefaultDriverDigit
4848
4949
// 使用自定义配置
5050
base64Driver := driver.NewDriverDigit(driver.DriverDigit{
51-
Width: 240, // 宽度
52-
Height: 60, // 高度
53-
Length: 6, // 长度
54-
NoiseCount: 2, // 点数量
51+
Width: 240, // 宽度
52+
Height: 60, // 高度
53+
Length: 6, // 长度
54+
NoiseCount: 2, // 点数量
55+
Source: "0123456789",
56+
Fonts: []string{"wqy-microhei.ttc"}, // 显示字体
57+
BgColor: &color.RGBA{R: 0, G: 0, B: 0, A: 0}, // 背景颜色
5558
})
5659
```
5760
@@ -65,13 +68,13 @@ base64Driver := driver.DefaultDriverLetter
6568
6669
// 使用自定义配置
6770
base64Driver := driver.NewDriverLetter(driver.DriverLetter{
68-
Width: 240, // 宽度
69-
Height: 60, // 高度
70-
Length: 6, // 长度
71-
NoiseCount: 2, // 点数量
72-
Source: "ABCDEFGHJKMNOQRSTUVXYZabcdefghjkmnoqrstuvxyz",
73-
Fonts: []string{"wqy-microhei.ttc"}, // 显示字体
74-
BgColor: &color.RGBA{R: 0, G: 0, B: 0, A: 0}, // 背景颜色
71+
Width: 240, // 宽度
72+
Height: 60, // 高度
73+
Length: 6, // 长度
74+
NoiseCount: 2, // 点数量
75+
Source: "ABCDEFGHJKMNOQRSTUVXYZabcdefghjkmnoqrstuvxyz",
76+
Fonts: []string{"wqy-microhei.ttc"}, // 显示字体
77+
BgColor: &color.RGBA{R: 0, G: 0, B: 0, A: 0}, // 背景颜色
7578
})
7679
```
7780
@@ -85,12 +88,12 @@ base64Driver := driver.DefaultDriverMath
8588
8689
// 使用自定义配置
8790
base64Driver := driver.NewDriverMath(driver.DriverMath{
88-
Width: 240, // 宽度
89-
Height: 60, // 高度
90-
NoiseCount: 2, // 点数量
91-
ShowLineOptions: 0, // 显示线条
92-
Fonts: []string{"wqy-microhei.ttc"}, // 显示字体
93-
BgColor: &color.RGBA{R: 0, G: 0, B: 0, A: 0}, // 背景颜色
91+
Width: 240, // 宽度
92+
Height: 60, // 高度
93+
NoiseCount: 2, // 点数量
94+
ShowLineOptions: 0, // 显示线条
95+
Fonts: []string{"wqy-microhei.ttc"}, // 显示字体
96+
BgColor: &color.RGBA{R: 0, G: 0, B: 0, A: 0}, // 背景颜色
9497
})
9598
```
9699
@@ -104,14 +107,14 @@ base64Driver := driver.DefaultDriverString
104107
105108
// 使用自定义配置
106109
base64Driver := driver.NewDriverString(driver.DriverString{
107-
Width: 240, // 宽度
108-
Height: 60, // 高度
109-
Length: 6, // 长度
110-
NoiseCount: 2, // 点数量
111-
ShowLineOptions: 0, // 显示线条
112-
Source: "ABCDEFGHJKMNOQRSTUVXYZabcdefghjkmnoqrstuvxyz", // 字符源
113-
Fonts: []string{"wqy-microhei.ttc"}, // 显示字体
114-
BgColor: &color.RGBA{R: 0, G: 0, B: 0, A: 0}, // 背景颜色
110+
Width: 240, // 宽度
111+
Height: 60, // 高度
112+
Length: 6, // 长度
113+
NoiseCount: 2, // 点数量
114+
ShowLineOptions: 0, // 显示线条
115+
Source: "ABCDEFGHJKMNOQRSTUVXYZabcdefghjkmnoqrstuvxyz", // 字符源
116+
Fonts: []string{"wqy-microhei.ttc"}, // 显示字体
117+
BgColor: &color.RGBA{R: 0, G: 0, B: 0, A: 0}, // 背景颜色
115118
})
116119
```
117120
@@ -125,14 +128,14 @@ base64Driver := driver.DefaultDriverChinese
125128
126129
// 使用自定义配置
127130
base64Driver := driver.NewDriverChinese(driver.DriverChinese{
128-
Width: 240, // 宽度
129-
Height: 60, // 高度
130-
Length: 6, // 长度
131-
NoiseCount: 2, // 点数量
132-
ShowLineOptions: 0, // 显示线条
133-
Source: "设想,你在,处理,消费者,的音,频输,出音,频可,能无,论什,么都,没有,任何,输出,或者,它可,能是,单声道,立体声,或是,环绕立,体声的,,不想要,的值", // 字符源
134-
Fonts: []string{"wqy-microhei.ttc"}, // 显示字体
135-
BgColor: &color.RGBA{R: 125, G: 125, B: 0, A: 118}, // 背景颜色
131+
Width: 240, // 宽度
132+
Height: 60, // 高度
133+
Length: 6, // 长度
134+
NoiseCount: 2, // 点数量
135+
ShowLineOptions: 0, // 显示线条
136+
Source: "设想,你在,处理,消费者,的音,频输,出音,频可,能无,论什,么都,没有,任何,输出,或者,它可,能是,单声道,立体声,或是,环绕立,体声的,,不想要,的值", // 字符源
137+
Fonts: []string{"wqy-microhei.ttc"}, // 显示字体
138+
BgColor: &color.RGBA{R: 125, G: 125, B: 0, A: 118}, // 背景颜色
136139
})
137140
```
138141
@@ -146,8 +149,8 @@ base64Driver := driver.DefaultDriverAudio
146149
147150
// 使用自定义配置
148151
base64Driver := driver.NewDriverAudio(driver.DriverAudio{
149-
Length: 6, // 长度
150-
Language: "en", // 语言,目前支持:en、zh、ja、ru、de
152+
Length: 6, // 长度
153+
Language: "en", // 语言,目前支持:en、zh、ja、ru、de
151154
})
152155
```
153156

0 commit comments

Comments
 (0)