Computer >> 컴퓨터 >  >> 프로그램 작성 >> PHP

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

<시간/>

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

구문

bool imagesetthickness($image, $thickness)

매개변수

이미지 세트 두께() $image 및 $thickness의 두 매개변수를 허용합니다.

  • $이미지 - 이 매개변수는 imagecreatetruecolor()와 같은 이미지 생성 함수에 의해 반환됩니다. 이미지의 크기를 생성할 때 사용합니다.

  • $두께 − 이 매개변수는 픽셀의 두께를 설정합니다.

반환 값

이미지 세트 두께() 성공하면 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);
?>

출력

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

예시 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에서 imgesetthickness() 함수를 사용하여 선 그리기의 이미지 두께를 설정하는 방법은 무엇입니까?