現在の位置: ホーム> 最新記事一覧> phpのimagelipse()関数を使用して楕円グラフを描く方法

phpのimagelipse()関数を使用して楕円グラフを描く方法

M66 2025-06-21

PHPでImageEllipse()関数を使用して楕円を描画する方法は?

imageellipse()

パラメーター

ImageEllipse()関数は、6つのパラメーターを受け入れます。

  • $ IMAGE-画像リソース。これは、画像作成関数( ImageCreateTrueColor()など)によって返される可能性があります。
  • $ cx-楕円の中心のx座標。
  • $ cy-楕円の中心のy座標。
  • $幅- 楕円の幅。
  • $高さ- 楕円の高さ。
  • $ COLOR-通常、 ImageColorAllocate()関数を介して取得される楕円の色。

返品値

関数が正常に実行されるとtrueを返し、失敗した場合はfalseを返します。

例1

 
<?php
// 空白の画像を作成します
$image = imagecreatetruecolor(700, 350);

// 背景色を選択します
$bg = imagecolorallocate($image, 0, 0, 0);

// 背景の色を埋めます
imagefill($image, 0, 0, $bg);

// 楕円の色を選択します
$col_ellipse = imagecolorallocate($image, 255, 255, 255);

// 楕円を描きます
imageellipse($image, 325, 175, 500, 175, $col_ellipse);

// 出力画像
header("Content-type: image/png");
imagepng($image);
?>

出力

例2

 
<?php
// 空白の画像を作成します
$image = imagecreatetruecolor(700, 600);

// 背景色を設定します
$bg = imagecolorallocate($image, 122, 122, 122);

// 背景の色を埋めます
imagefill($image, 0, 0, $bg);

// 楕円の色を設定します
$col_ellipse = imagecolorallocate($image, 0, 255, 255);

// 楕円を描きます
imageellipse($image, 250, 300, 300, 550, $col_ellipse);

// 出力画像
header("Content-type: image/gif");
imagepng($image);
?>

出力

上記の2つの例を使用して、PHPでImageLipse()関数を使用して楕円を描画する方法を示します。この関数は、グラフィックス処理アプリケーションとWeb開発の両方で、さまざまな画像描画タスクに適しています。