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

WBOY
풀어 주다: 2023-09-08 15:52:02
앞으로
974명이 탐색했습니다.

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으로 문의하세요.
인기 튜토리얼
더>
최신 다운로드
더>
웹 효과
웹사이트 소스 코드
웹사이트 자료
프론트엔드 템플릿
회사 소개 부인 성명 Sitemap
PHP 중국어 웹사이트:공공복지 온라인 PHP 교육,PHP 학습자의 빠른 성장을 도와주세요!