PHPのimagecolorallocatealpha()関数
imagecolorallocatealpha()関数は、画像に色を割り当てます。
構文
imagecolorallocatealpha ( img, red, green, blue, alpha )
パラメータ
-
img : 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);
?> 出力
出力は次のとおりです。
-
PHPのimagefilledrectangle()関数
imagefilledrectangle()関数は、塗りつぶされた長方形を描画します。 構文 imagefilledrectangle( $img, $x1, $y1, $x2, $y2, $color ) パラメータ 画像 imagecreatetruecolor()を使用して空白の画像を作成します。 x1 ポイント1のx座標。 y1 ポイント1のy座標。 x2 ポイント2のx座標。 y2 ポイント2のy座標。 色 塗りつぶしの色。 戻る imagefilledrectangle()関数は、成功した場合はTRUEを返し、失
-
PHPのimagefilledellipse()関数
imagefilledellipse()関数は、塗りつぶされた楕円を描画するために使用されます。 構文 imagefilledellipse( $img, $cx, $cy, $width, $height, $color ) パラメータ img これにより、imagecreatetruecolor()を使用して空白の画像が作成されます。 cx 中心のx座標。 cy 中心のy座標。 幅 楕円の幅。 高さ 楕円の高さ。 色 塗りつぶしの色。 戻る imagefilledellipse()関数は、成功した場合はTRUEを返し、失敗した場合はFA