PHPのimagesetthickness()関数を使用して線画の画像の太さを設定するにはどうすればよいですか?

WBOY
リリース: 2023-09-08 15:52:02
転載
974 人が閲覧しました

imagesetthickness() は PHP の組み込み関数で、線画の太さを設定するために使用されます。

構文

bool imagesetthickness($image, $thickness)
ログイン後にコピー

パラメータ

imagesetthickness()2 つのパラメータ - $image と $厚さ。

  • $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(&#39;Content-Type: image/png&#39;);
   imagepng($img);
   imagedestroy($img);
?>
ログイン後にコピー

出力

PHPのimagesetthickness()関数を使用して線画の画像の太さを設定するにはどうすればよいですか?

例 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(&#39;Content-Type: image/png&#39;);
   imagepng($img);
   imagedestroy($img);
?>
ログイン後にコピー
出力

PHPのimagesetthickness()関数を使用して線画の画像の太さを設定するにはどうすればよいですか?

以上がPHPのimagesetthickness()関数を使用して線画の画像の太さを設定するにはどうすればよいですか?の詳細内容です。詳細については、PHP 中国語 Web サイトの他の関連記事を参照してください。

ソース:tutorialspoint.com
このウェブサイトの声明
この記事の内容はネチズンが自主的に寄稿したものであり、著作権は原著者に帰属します。このサイトは、それに相当する法的責任を負いません。盗作または侵害の疑いのあるコンテンツを見つけた場合は、admin@php.cn までご連絡ください。
最新の問題
人気のチュートリアル
詳細>
最新のダウンロード
詳細>
ウェブエフェクト
公式サイト
サイト素材
フロントエンドテンプレート
私たちについて 免責事項 Sitemap
PHP中国語ウェブサイト:福祉オンライン PHP トレーニング,PHP 学習者の迅速な成長を支援します!