이미지 세트 스타일() 선 그리기 스타일을 설정하는 데 사용되는 PHP의 내장 함수입니다. imagepolygon과 같은 모든 선 그리기 기능에서 사용할 수 있습니다. 또는 이미지 라인 .
구문
bool imagesetstyle(resource $image, array $style)
매개변수
이미지 세트 스타일() 두 개의 매개변수를 사용합니다. $image 및 $style .
-
$이미지 − 작업할 이미지 리소스를 지정합니다.
-
$스타일 − 픽셀 색상의 배열을 지정합니다.
반환 값
이미지 세트 스타일() 성공하면 True, 실패하면 False를 반환합니다.
예시 1
<?php
header("Content-type: image/jpeg");
$img = imagecreatetruecolor(700, 300);
$w = imagecolorallocate($img, 122, 122, 122);
$red = imagecolorallocate($img, 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($img, $style);
imageline($img, 0, 0, 200, 200, 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($img, $style);
$brush = imagecreatefrompng('C:\xampp\htdocs\Images\img34.png');
$w2 = imagecolorallocate($brush, 255, 255, 255);
imagecolortransparent($brush, $w2);
imagesetbrush($img, $brush);
imageline($img, 200, 0, 0, 200, IMG_COLOR_STYLEDBRUSHED);
imagejpeg($img);
imagedestroy($img);
?> 입력 이미지

출력 이미지

예시 2
<?php
// Load the png image using imagecreatefrompng() function.
$img = imagecreatefrompng('C:\xampp\htdocs\Images\img34.png');
// Allocated the blue and green colors
$blue = imagecolorallocate($img, 0, 0, 255);
$green = imagecolorallocate($img, 0, 255, 0);
// Draw a dashed line, 5 blue pixels, 5 white pixels
$style = array($blue, $blue, $blue, $blue, $blue, $green, $green, $green, $green, $green);
imagesetstyle($img, $style);
imageline($img, 0, 100, 800, 100, IMG_COLOR_STYLED);
// Output image to the browser
header('Content-type: image/png');
imagepng($img);
?> 출력
