이미지 처리 및 GD imagedashedline
(PHP 4, PHP 5, PHP 7, PHP 8)
imagedashedline — 점선 그리기
설명
imagedashedline( GdImage $image, int $x1, int $y1, int $x2, int $y2, int $color ): bool
이 함수는 더 이상 사용되지 않습니다. 대신 imagesetstyle()과 imageline()의 조합을 사용하십시오.
매개변수
image
- imagecreatetruecolor()와 같은 이미지 생성 함수 중 하나에서 반환되는 GdImage 객체.
x1
- 왼쪽 상단 x 좌표.
y1
- 왼쪽 상단 y 좌표 0, 0은 이미지의 왼쪽 상단 모서리입니다.
x2
- 오른쪽 아래 x 좌표.
y2
- 오른쪽 하단 y 좌표.
color
- 채우기 색상입니다. imagecolorallocate()로 생성된 색상 식별자입니다.
반환 값
성공하면 true
를, 실패하면 false
를 반환합니다.
변경 로그
버전 | 설명 |
---|---|
8.0.0 | image 는 이제 GdImage 인스턴스를 예상합니다. 이전에는 리소스가 필요했습니다. |
Examples
예제 #1 imagedashedline() 예제
<?php
// Create a 100x100 image
$im = imagecreatetruecolor(100, 100);
$white = imagecolorallocate($im, 0xFF, 0xFF, 0xFF);
// Draw a vertical dashed line
imagedashedline($im, 50, 25, 50, 75, $white);
// Save the image
imagepng($im, './dashedline.png');
imagedestroy($im);
?>
위의 예는 다음과 유사한 결과를 출력합니다.
예제 #2 imagedashedline()의 대안
<?php
// Create a 100x100 image
$im = imagecreatetruecolor(100, 100);
$white = imagecolorallocate($im, 0xFF, 0xFF, 0xFF);
// Define our style: First 4 pixels is white and the
// next 4 is transparent. This creates the dashed line effect
$style = Array(
$white,
$white,
$white,
$white,
IMG_COLOR_TRANSPARENT,
IMG_COLOR_TRANSPARENT,
IMG_COLOR_TRANSPARENT,
IMG_COLOR_TRANSPARENT
);
imagesetstyle($im, $style);
// Draw the dashed line
imageline($im, 50, 25, 50, 75, IMG_COLOR_STYLED);
// Save the image
imagepng($im, './imageline.png');
imagedestroy($im);
?>
기타
- imagesetstyle() - 선화 스타일 설정
- imageline() - 선을 그리다