이미지 처리 및 GD imagesetstyle
(PHP 4 >= 4.0.6, PHP 5, PHP 7, PHP 8)
imagesetstyle — 선화 스타일 설정
설명
imagesetstyle(GdImage $image
, array $style
): bool
imagesetstyle()은 특수 색상 IMG_COLOR_STYLED
또는 색상 IMG_COLOR_STYLEDBRUSHED
로 이미지 라인을 그릴 때 모든 선 그리기 함수(예: imageline() 및 imagepolygon())에서 사용할 스타일을 설정합니다.
매개변수
image
- imagecreatetruecolor()와 같은 이미지 생성 함수 중 하나에서 반환되는 GdImage 객체.
style
- 픽셀 색상의 배열입니다.
IMG_COLOR_TRANSPARENT
상수를 사용하여 투명 픽셀을 추가할 수 있습니다.style
은 빈 배열이 아니어야 합니다.
반환 값
성공하면 true
를, 실패하면 false
를 반환합니다.
Examples
다음 예제 스크립트는 캔버스의 왼쪽 상단에서 오른쪽 하단 모서리로 파선을 그립니다.
예제 #1 imagesetstyle() 예제
<?php
header("Content-type: image/jpeg");
$im = imagecreatetruecolor(100, 100);
$w = imagecolorallocate($im, 255, 255, 255);
$red = imagecolorallocate($im, 255, 0, 0);
/* Draw a dashed line, 5 red pixels, 5 white pixels */
$style = array($red, $red, $red, $red, $red, $w, $w, $w, $w, $w);
imagesetstyle($im, $style);
imageline($im, 0, 0, 100, 100, IMG_COLOR_STYLED);
/* Draw a line of happy faces using imagesetbrush() with imagesetstyle */
$style = array($w, $w, $w, $w, $w, $w, $w, $w, $w, $w, $w, $w, $red);
imagesetstyle($im, $style);
$brush = imagecreatefrompng("http://www.libpng.org/pub/png/images/smile.happy.png");
$w2 = imagecolorallocate($brush, 255, 255, 255);
imagecolortransparent($brush, $w2);
imagesetbrush($im, $brush);
imageline($im, 100, 0, 0, 100, IMG_COLOR_STYLEDBRUSHED);
imagejpeg($im);
imagedestroy($im);
?>
위의 예는 다음과 유사한 결과를 출력합니다.
기타
- imagesetbrush() - 선화용 브러시 이미지 설정
- imageline() - 선을 그리다