如何使用 PHP 中的 imgesetthickness() 函式設定線描的影像厚度?
imagesetthickness() 是 PHP 中的一個內建函式,用於設定線描的厚度。
語法
bool imagesetthickness($image, $thickness)
引數
imagesetthickness() 接受兩個引數− $image 和 $thickness。
$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); ?>
輸出
.jpg)
示例 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); ?>
輸出
.jpg)
廣告
資料結構
網路
RDBMS
作業系統
Java
iOS
HTML
CSS
Android
Python
C 程式設計
C++
C#
MongoDB
MySQL
Javascript
PHP