라이브러리
[PHP] ps_rect - 사각형을 그립니다
PHP에서 PSRect 사용하기
PHP의 GD 라이브러리에서 `ps_rect` 함수를 사용하여 PostScript 그래픽을 생성할 수 있습니다. 이 함수는 PostScript 그래픽에서 사용되는 rect(정사각형) 모양을 그립니다.
사용법
`ps_rect` 함수의 사용법은 다음과 같습니다.
#hostingforum.kr
php
ps_rect($x, $y, $width, $height);
- `$x` : rect의 왼쪽 위 코너의 x 좌표
- `$y` : rect의 왼쪽 위 코너의 y 좌표
- `$width` : rect의 너비
- `$height` : rect의 높이
예제
다음 예제에서는 `ps_rect` 함수를 사용하여 PostScript 그래픽을 생성합니다.
#hostingforum.kr
php
<?php
// PostScript 그래픽을 생성할 수 있는 GD 라이브러리를 사용합니다.
$image = imagecreate(400, 300);
$white = imagecolorallocate($image, 255, 255, 255);
imagefill($image, 0, 0, $white);
// PostScript 그래픽을 생성합니다.
header('Content-Type: image/x-postscript');
imagepsloadfont($image, 'Helvetica');
imagepssetaa($image, true);
imagepsstring($image, 10, 10, 'Hello, World!');
imagepsrect($image, 50, 50, 100, 100); // rect를 그립니다.
imagepsstring($image, 160, 160, 'Rect');
// PostScript 그래픽을 출력합니다.
imagepsoutput($image, 'example.ps');
imagedestroy($image);
?>
이 예제에서는 PostScript 그래픽을 생성할 수 있는 GD 라이브러리를 사용합니다. `imagepsloadfont` 함수를 사용하여 PostScript 그래픽에 사용할 폰트를 로드하고, `imagepssetaa` 함수를 사용하여 PostScript 그래픽의 안티 알리아싱을 활성화합니다. `imagepsstring` 함수를 사용하여 PostScript 그래픽에 문자열을 출력하고, `imagepsrect` 함수를 사용하여 rect를 그립니다. 마지막으로, `imagepsoutput` 함수를 사용하여 PostScript 그래픽을 출력합니다.
결과
PostScript 그래픽을 생성한 결과는 다음과 같습니다.
#hostingforum.kr
%!PS-Adobe-3.0
%%BoundingBox: 0 0 400 300
%%Pages: 1
%%EndComments
/Helvetica findfont 12 scalefont setfont
10 10 moveto (Hello, World!) show
50 50 moveto 100 100 lineto 100 100 lineto 100 50 lineto 50 50 lineto closepath
gsave
0 setgray
fill
grestore
160 160 moveto (Rect) show
%%EOF
이 결과는 PostScript 그래픽을 생성한 결과이며, rect를 포함합니다.
-
- 나우호스팅 @pcs8404
-
호스팅포럼 화이팅!
댓글목록
등록된 댓글이 없습니다.