>  기사  >  백엔드 개발  >  PHP에서 imagesetthickness() 함수를 사용하여 선 그리기의 이미지 두께를 설정하는 방법은 무엇입니까?

PHP에서 imagesetthickness() 함수를 사용하여 선 그리기의 이미지 두께를 설정하는 방법은 무엇입니까?

WBOY
WBOY앞으로
2023-09-08 15:49:01945검색

imagesetthickness()는 선 그리기의 두께를 설정하는 데 사용되는 PHP 내장 함수입니다.

Syntax

bool imagesetthickness($image, $thickness)

Parameters

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(&#39;Content-Type: image/png&#39;);
   imagepng($img);
   imagedestroy($img);
?>

Output

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);
?>

Output

PHP에서 imagesetthickness() 함수를 사용하여 선 그리기의 이미지 두께를 설정하는 방법은 무엇입니까?

위 내용은 PHP에서 imagesetthickness() 함수를 사용하여 선 그리기의 이미지 두께를 설정하는 방법은 무엇입니까?의 상세 내용입니다. 자세한 내용은 PHP 중국어 웹사이트의 기타 관련 기사를 참조하세요!

성명:
이 기사는 tutorialspoint.com에서 복제됩니다. 침해가 있는 경우 admin@php.cn으로 문의하시기 바랍니다. 삭제