이미지 라인() 주어진 두 점 사이에 선을 그리는 데 사용되는 PHP의 내장 함수입니다.
구문
bool imageline(resource $image, int $x1, int $y1,int $x2, int $y2, int $color)
매개변수
이미지 라인() $image, $x1, $y1, $x2, $y2 및 $color의 6가지 매개변수를 사용합니다.
-
$이미지 − 작업할 이미지 리소스를 지정합니다.
-
$x1 - 시작 x 좌표를 지정합니다.
-
$y1 − 시작 y 좌표를 지정합니다.
-
$x2 − 종료 x 좌표를 지정합니다.
-
$y2 − 끝 y 좌표를 지정합니다.
-
$color − imagecolorallocate()를 사용하여 생성된 선 색상 및 색상 식별자를 지정합니다. 기능.
반환 값
imageline()은 성공하면 True를, 실패하면 False를 반환합니다.
예시 1 - 이미지에 선 추가
<?php
// Create an image using imagecreatefrompng() function
$img = imagecreatefrompng('C:\xampp\htdocs\test\515.png');
// allocated the line color
$text_color = imagecolorallocate($img, 255, 255, 0);
// Set the thickness of the line
imagesetthickness($img, 5);
// Add a line using imageline() function.
imageline($img, 80, 300, 1140, 300, $text_color);
// Output of the image
header('Content-type: image/png');
imagepng($img);
imagedestroy($img);
?> 출력

예시 2
<?php
// Create an image using imagecreate() function
$img = imagecreate(700, 300);
// Allocate the colors
$grey = imagecolorallocate($img, 122, 122, 122);
$blue = imagecolorallocate($img, 0, 0, 255);
// Set the thickness of the line
imagesetthickness($img, 15);
// Add a grey background color
imageline($img, 0, 0, 550, 400, $grey);
// Add a blue line
imageline($img, 0, 0, 550, 400, $blue);
// Output the image
header('Content-type: image/png');
imagepng($img);
imagedestroy($img);
?> 출력
