imagesetthickness()是 PHP 中的一個內置函數,用於設置線條繪製的粗細。
用法
bool imagesetthickness($image, $thickness)
參數
imagesetthickness()接受兩個參數 -$圖像和$厚度。
$image− 該參數由imagecreatetruecolor() 等圖像創建函數返回。它用於創建圖像的大小。
$thickness− 此參數以像素為單位設置厚度。
返回值
imagesetthickness()成功時返回 True,失敗時返回 False。
例子1
<?php
// Create an image of a given size
$img = imagecreatetruecolor(700, 300);
$gray = imagecolorallocate($img, 0, 0, 255);
$white = imagecolorallocate($img, 0xff, 0xff, 0xff);
// Set the gray background color
imagefilledrectangle($img, 0, 0, 700, 300, $gray);
// Set the line thickness to 10
imagesetthickness($img, 10);
// Draw the rectangle
imagerectangle($img, 30, 30, 200, 150, $white);
// Output image to the browser
header('Content-Type:image/png');
imagepng($img);
imagedestroy($img);
?>
輸出
例子2
<?php
// Create an image of given size using imagecreatetruecolor() function
$img = imagecreatetruecolor(700, 300);
$blue = imagecolorallocate($img, 0, 0, 255);
$white = imagecolorallocate($img, 0xff, 0xff, 0xff);
// Set the white background-color
imagefilledrectangle($img, 0, 0, 300, 200, $blue);
// Set the line thickness to 50
imagesetthickness($img, 50);
// Draw the white line
imageline($img, 50, 50, 250, 50, $white);
// Output image to the browser
header('Content-Type:image/png');
imagepng($img);
imagedestroy($img);
?>
輸出
相關用法
- PHP imagegif()用法及代碼示例
- PHP imageresolution()用法及代碼示例
- PHP imagebmp()用法及代碼示例
- PHP imap_getsubscribed()用法及代碼示例
- PHP imagearc()用法及代碼示例
- PHP imageftbbox()用法及代碼示例
- PHP imagecreatefromgif()用法及代碼示例
- PHP imagecreatefrombmp()用法及代碼示例
- PHP imap_header()用法及代碼示例
- PHP imap_last_error()用法及代碼示例
- PHP imap_mutf7_to_utf8()用法及代碼示例
- PHP imagecreatefromstring()用法及代碼示例
- PHP imap_headerinfo()用法及代碼示例
- PHP imagestring()用法及代碼示例
- PHP imap_lsub()用法及代碼示例
- PHP imagecreatetruecolor()用法及代碼示例
- PHP imap_createmailbox()用法及代碼示例
- PHP imagecrop()用法及代碼示例
- PHP imap_fetchtext()用法及代碼示例
- PHP imagecreatefrompng()用法及代碼示例
注:本文由純淨天空篩選整理自Urmila Samariya大神的英文原創作品 How to set the image thickness for line drawing using imgesetthickness() function in PHP?。非經特殊聲明,原始代碼版權歸原作者所有,本譯文未經允許或授權,請勿轉載或複製。