imagesetthickness()函数是PHP中的内置函数,用于设置线条绘制的厚度。
用法:
bool imagesetthickness( $image, $thickness )
参数:该函数接受上述和以下描述的两个参数:
- $image:它由图像创建函数之一(例如imagecreatetruecolor())返回。它用于创建图像的尺寸。
- $thickness:此参数用于设置像素的厚度。
返回值:如果成功,此函数返回True;如果失败,则返回False。
以下示例程序旨在说明PHP中的imagesetthickness()函数:
示例1:
<?php 
  
// Create an image of given size 
$im = imagecreatetruecolor(400, 300); 
$green = imagecolorallocate($im, 0, 153, 0); 
$white = imagecolorallocate($im, 0xff, 0xff, 0xff); 
  
// Set the background to be white 
imagefilledrectangle($im, 0, 0, 400, 300, $green); 
  
// Set the line thickness to 5 
imagesetthickness($im, 5); 
  
// Draw the rectangle 
imagerectangle($im, 50, 50, 350, 250, $white); 
  
// Output image to the browser 
header('Content-Type: image/png'); 
  
imagepng($im); 
imagedestroy($im); 
?>输出:

示例2:
<?php 
   
// Create an image of given size 
$im = imagecreatetruecolor(400, 100); 
$green = imagecolorallocate($im, 0, 153, 0); 
$white = imagecolorallocate($im, 0xff, 0xff, 0xff); 
   
// Set the background to be white 
imagefilledrectangle($im, 0, 0, 400, 300, $green); 
   
// Set the line thickness to 15 
imagesetthickness($im, 15); 
  
// Draw the line 
imageline($im, 50, 50, 350, 50, $white); 
   
// Output image to the browser 
header('Content-Type: image/png'); 
   
imagepng($im); 
imagedestroy($im); 
?>输出:

参考: http://php.net/manual/en/function.imagesetthickness.php
相关用法
- PHP cos( )用法及代码示例
- p5.js tan()用法及代码示例
- d3.js d3.hsl()用法及代码示例
- PHP key()用法及代码示例
- PHP pos()用法及代码示例
- p5.js log()用法及代码示例
- p5.js cos()用法及代码示例
- p5.js day()用法及代码示例
- PHP tan( )用法及代码示例
- p5.js sin()用法及代码示例
- PHP each()用法及代码示例
- p5.js second()用法及代码示例
注:本文由纯净天空筛选整理自Mahadev99大神的英文原创作品 PHP | imagesetthickness() Function。非经特殊声明,原始代码版权归原作者所有,本译文未经允许或授权,请勿转载或复制。
