imagefontwidth 函数接受一个包含字体的单个参数 $font。对于内置字体,它可以是1、2、3、4、5。对于自定义字体,它可以与imageloadfont() 一起使用。
$font = imageloadfont('Pacifico.ttf');
echo 'Font width for Pacifico is '. imagefontwidth($font);
$font = imageloadfont('Pacifico.ttf');
echo 'Font width for Pacifico is '. imagefontwidth($font);
2021-10-18
使验证码的字符无序:
$charSet = array_merge(range(0, 9), range('A', 'Z'), range('a', 'z'));
shuffle($charSet);
$code = implode(array_slice($charSet, 0, 4));
$charSet = array_merge(range(0, 9), range('A', 'Z'), range('a', 'z'));
shuffle($charSet);
$code = implode(array_slice($charSet, 0, 4));
2019-05-12
保证圆弧绘制在图像中:
$cx = mt_rand(0, $width);
$cy = mt_rand(0, $height);
$w = mt_rand(0, min($cx, $width - $cx));
$h = mt_rand(0, min($cy, $height - $cy));
$s = mt_rand(0, 360);
$e = mt_rand(0, 360);
imagearc($image, $cx, $cy, $w, $h, $s, $e, $color);
$cx = mt_rand(0, $width);
$cy = mt_rand(0, $height);
$w = mt_rand(0, min($cx, $width - $cx));
$h = mt_rand(0, min($cy, $height - $cy));
$s = mt_rand(0, 360);
$e = mt_rand(0, 360);
imagearc($image, $cx, $cy, $w, $h, $s, $e, $color);
2019-05-12
绘制圆弧
imagearc(图像, 圆心横坐标, 圆心纵坐标, 圆的宽度, 圆的高度, 起点角度, 终点角度, 颜色);
起点角度、终点角度:正数表示顺时针,负数表示逆时针
imagearc(图像, 圆心横坐标, 圆心纵坐标, 圆的宽度, 圆的高度, 起点角度, 终点角度, 颜色);
起点角度、终点角度:正数表示顺时针,负数表示逆时针
2019-05-12