@@ -51,7 +51,6 @@ class Captcha implements CaptchaInterface
51
51
'length ' => 4 , // 验证码位数
52
52
'fontSize ' => 36 , // 验证码字体大小(px)
53
53
'bgColor ' => [255 ,255 ,255 ],
54
- 'color ' => [],
55
54
];
56
55
57
56
/**
@@ -72,7 +71,7 @@ class Captcha implements CaptchaInterface
72
71
*
73
72
* @var string
74
73
*/
75
- protected $ phraseSet = '23456789ABCDEFHKLMNPQRSTUVWXY ' ;
74
+ protected $ phraseSet = '2345679ABCDEFHKLMNPQRSTUVWXY ' ;
76
75
77
76
/**
78
77
* 验证码图片实例
@@ -190,20 +189,17 @@ public function getPhrase()
190
189
public function create ()
191
190
{
192
191
// 图片宽(px)
193
- $ this ->width = $ this ->cfg ['length ' ] * $ this ->cfg ['fontSize ' ] * 0.85 ;
192
+ $ this ->width = $ this ->cfg ['length ' ] * $ this ->cfg ['fontSize ' ] * 0.86 ;
194
193
195
194
// 图片高(px)
196
195
$ this ->height = $ this ->cfg ['fontSize ' ] * 1.36 ;
197
196
198
197
// 建立一幅 $this->width x $this->height 的图像
199
198
$ this ->image = imagecreate ($ this ->width , $ this ->height );
200
199
201
- $ bgColor = $ this ->cfg ['bgColor ' ] ? $ this -> cfg [ ' bgColor ' ] : [ mt_rand ( 0x70 , 0xff ), mt_rand ( 0x70 , 0xff ), mt_rand ( 0x70 , 0xff )] ;
200
+ $ bgColor = $ this ->cfg ['bgColor ' ];
202
201
imagecolorallocate ($ this ->image , $ bgColor [0 ], $ bgColor [1 ], $ bgColor [2 ]);
203
202
204
- if ($ this ->cfg ['color ' ]) {
205
- }
206
-
207
203
$ this ->phrase ();
208
204
209
205
if ($ this ->cfg ['distort ' ]) {
@@ -231,8 +227,7 @@ protected function phrase()
231
227
232
228
// 倾斜度
233
229
$ gradient = mt_rand (-22 , 22 );
234
- $ colorRGB = self ::COLORS [mt_rand (0 , count (self ::COLORS ) - 1 )];
235
- $ color = imagecolorallocate ($ this ->image , $ colorRGB [0 ], $ colorRGB [1 ], $ colorRGB [2 ]);
230
+ $ color = imagecolorallocate ($ this ->image , mt_rand (0 , 200 ), mt_rand (0 , 200 ), mt_rand (0 , 200 ));
236
231
237
232
// 绘制一个验证码字符
238
233
imagettftext ($ this ->image , $ this ->cfg ['fontSize ' ], $ gradient , $ phraseNX , $ this ->cfg ['fontSize ' ]*1.1 , $ color , $ this ->getFont (), $ phrase [$ i ]);
@@ -242,7 +237,6 @@ protected function phrase()
242
237
$ this ->phrase = implode ('' , $ phrase );
243
238
}
244
239
245
-
246
240
/**
247
241
* 画一条由两条连在一起构成的随机正弦函数曲线作干扰线(你可以改成更帅的曲线函数)
248
242
*
@@ -268,8 +262,7 @@ protected function curve()
268
262
269
263
$ px1 = mt_rand (0 , $ this ->width /4 ); // 曲线横坐标起始位置
270
264
$ px2 = mt_rand ($ px1 + $ this ->width /3 , $ this ->width ); // 曲线横坐标结束位置
271
- $ colorRGB = self ::COLORS [mt_rand (0 , count (self ::COLORS ) - 1 )];
272
- $ color = imagecolorallocate ($ this ->image , $ colorRGB [0 ], $ colorRGB [1 ], $ colorRGB [2 ]);
265
+ $ color = imagecolorallocate ($ this ->image , mt_rand (0 , 200 ), mt_rand (0 , 200 ), mt_rand (0 , 200 ));
273
266
274
267
for ($ px = $ px1 ; $ px <= $ px2 ; $ px ++) {
275
268
if ($ w == 0 ) {
0 commit comments