imagedashedline
(PHP 4, PHP 5, PHP 7)
imagedashedline - 画一条虚线
描述
bool imagedashedline ( resource $image , int $x1 , int $y1 , int $x2 , int $y2 , int $color )
此功能已弃用。改为使用 imagesetstyle()和 imageline()的组合。
参数
`image`
一个图像资源,由图像创建函数之一返回,如 imagecreatetruecolor()。
x1
左上角的x坐标。
y1
左上方y坐标0,0是图像的左上角。
x2
底部右侧x坐标。
y2
右下角y坐标。
color
填充颜??色。使用 imagecolorallocate()创建的颜色标识符。
返回值
始终返回 true
示例
示例#1 imagedashedline()示例
<?php
//?Create?a?100x100?image
$im?=?imagecreatetruecolor(100,?100);
$white?=?imagecolorallocate($im,?0xFF,?0xFF,?0xFF);
//?Draw?a?vertical?dashed?line
imagedashedline($im,?50,?25,?50,?75,?$white);
//?Save?the?image
imagepng($im,?'./dashedline.png');
imagedestroy($im);
?>
上面的例子会输出类似于:
示例#2替代 imagedashedline()
<?php
//?Create?a?100x100?image
$im?=?imagecreatetruecolor(100,?100);
$white?=?imagecolorallocate($im,?0xFF,?0xFF,?0xFF);
//?Define?our?style:?First?4?pixels?is?white?and?the?
//?next?4?is?transparent.?This?creates?the?dashed?line?effect
$style?=?Array(
????????????????$white,?
????????????????$white,?
????????????????$white,?
????????????????$white,?
????????????????IMG_COLOR_TRANSPARENT,?
????????????????IMG_COLOR_TRANSPARENT,?
????????????????IMG_COLOR_TRANSPARENT,?
????????????????IMG_COLOR_TRANSPARENT
????????????????);
imagesetstyle($im,?$style);
//?Draw?the?dashed?line
imageline($im,?50,?25,?50,?75,?IMG_COLOR_STYLED);
//?Save?the?image
imagepng($im,?'./imageline.png');
imagedestroy($im);
?>
也可以看看
- imagesetstyle() - 设置线条绘制的样式
- imageline() - 绘制一条线
← imagecropauto
imagedestroy →
本文档系腾讯云开发者社区成员共同维护,如有问题请联系 cloudcommunity@tencent.com