PHP
 Computer >> コンピューター >  >> プログラミング >> PHP

PHPのimagecolortransparent()関数


imagecolortransparent()関数は、透明な画像の色を設定するために使用されます。

構文

imagecolortransparent ( img, color )

パラメータ

  • img :imagecreatetruecolor()関数を使用して画像を作成します。

  • :imagecolorallocate()で作成された色識別子。

戻る

imagecolortransparent()関数は、新しい透明色の識別子を返します。色が指定されておらず、画像に透明色がない場合、戻り値は-1です。

以下は例です

<?php
   $img = imagecreatetruecolor(500, 400);
   $blue = imagecolorallocate($img, 0, 0, 255);
   $transparent = imagecolorallocate($img, 0, 0, 0);
   imagecolortransparent($img, $transparent);
   imagefilledrectangle($img, 80, 90, 400, 220, $blue);
   header('Content-Type: image/png');
   imagepng($img);
   imagedestroy($img);
?>

出力

出力は次のとおりです。

PHPのimagecolortransparent()関数


  1. 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を返し、失

  2. PHPのimagefilledellipse()関数

    imagefilledellipse()関数は、塗りつぶされた楕円を描画するために使用されます。 構文 imagefilledellipse( $img, $cx, $cy, $width, $height, $color ) パラメータ img これにより、imagecreatetruecolor()を使用して空白の画像が作成されます。 cx 中心のx座標。 cy 中心のy座標。 幅 楕円の幅。 高さ 楕円の高さ。 色 塗りつぶしの色。 戻る imagefilledellipse()関数は、成功した場合はTRUEを返し、失敗した場合はFA