円を描画

imagearc

円を描画

imagefilledarc

円を描画(塗りつぶし)


サンプル(imagearc)

<?php
	// 200×200の画像リソースを作成
	$im =  imagecreatetruecolor(200, 200);
 
	// 白色を作成
	$white = imagecolorallocate($im, 0xFF, 0xFF, 0xFF);
 
	// ブレンドモードを無効
	imagealphablending($im, false);
	// 背景色を描画する
	imagefilledrectangle($im, 0, 0, 200, 200, $white);
 
	// 色インデックスを作成
	$red = imagecolorresolvealpha($im, 255, 50, 0, 50);
	$red2 = imagecolorresolvealpha($im, 0, 150, 200, 50);
 
	// 円を描画する
	imagearc($im, 100, 100, 120, 120, 0, 360, $red);
 
	// 破線を描画するためのスタイルを設定
	$style = array($red2, $red2, $red2, $white, $white, $white);
	imagesetstyle($im, $style);
 
	// 円を描画する
	imagearc($im, 50, 50, 60, 60, 0, 360, IMG_COLOR_STYLED);
 
	// 画像出力
	header("Content-type: image/png");
	ImagePNG($im);
?>
 
 
 

イメージ


サンプル(スタイルを設定)

<?php
	// 200×200の画像リソースを作成
	$im =  imagecreatetruecolor(200, 200);
 
	// 白色を作成
	$white = imagecolorallocate($im, 0xFF, 0xFF, 0xFF);
 
	// ブレンドモードを無効
	imagealphablending($im, false);
	// 背景色を描画する
	imagefilledrectangle($im, 0, 0, 200, 200, $white);
 
	// 色インデックスを作成
	$red = imagecolorresolvealpha($im, 255, 50, 0, 50);
	$red2 = imagecolorresolvealpha($im, 0, 150, 200, 50);
 
	// 円を描画する
	imagefilledarc($im, 100, 100, 120, 120, 0, 360, $red,  IMG_ARC_PIE);
 
	// 破線を描画するためのスタイルを設定
	$style = array($red2, $red2, $red2, $white, $white, $white);
	imagesetstyle($im, $style);
 
	// 円を描画する
	imagefilledarc($im, 50, 50, 60, 60, 0, 360, IMG_COLOR_STYLED,  IMG_ARC_PIE);
 
	// 画像出力
	header("Content-type: image/png");
	ImagePNG($im);
?>
 
 
 

イメージ




最終更新:2012年08月18日 19:30