imagecolorallocatealpha() 함수는 이미지에 색상을 할당합니다.
구문
imagecolorallocatealpha ( img, red, green, blue, alpha )
매개변수
-
이미지 : imagecreatetruecolor()로 만든 이미지 리소스입니다.
-
빨간색: 붉은색 성분
-
녹색 :녹색 성분
-
파란색: 파란색 구성 요소
-
알파: 이미지의 투명도. 0은 완전히 불투명한 것을 나타내고 127은 완전히 투명함을 나타냅니다.
돌아가기
imagecolorallocatealpha() 함수는 색상 식별자를 반환하거나 할당이 실패하면 FALSE를 반환합니다.
예시
다음은 예입니다.
<?php
$img = imagecreatetruecolor(520, 350);
$bgcolor = imagecolorallocate($img, 50, 10, 255);
imagefill($img, 0, 0, $bgcolor);
$one = imagecolorallocatealpha($img, 50, 255, 0, 70);
$two = imagecolorallocatealpha($img, 255, 0, 255, 50);
$three = imagecolorallocatealpha($img, 150, 255, 0, 60);
$four = imagecolorallocatealpha($img, 200, 0, 255, 90);
imagefilledellipse($img, 200, 150, 150, 150, $one);
imagefilledellipse($img, 220, 150, 150, 150, $two);
imagefilledellipse($img, 240, 150, 150, 150, $three);
imagefilledellipse($img, 280, 150, 150, 150, $four);
header('Content-Type: image/png');
imagepng($img);
imagedestroy($img);
?> 출력
다음은 출력입니다.
