簡易画像作成2

概要

200×200のイメージエリアにx=50、y=50、x2=150、y2=150に黄色の四角形を描画

imagecreatetruecolorによる画像リソース作成のため、背景を指定しない場合は黒の背景色となる


サンプル

<?php
	// 200×200の画像リソースを作成
	$im =  imagecreatetruecolor(200, 200);
 
	// 白色を作成
	$white = imagecolorallocate($im, 0xFF, 0xFF, 0xFF);
	// 黄色を作成
	$yellow = imagecolorallocate($im, 0xFF, 0xFF, 0x00);
 
	// 短形を描画する
	imagefilledrectangle($im, 50, 50, 150, 150, $yellow);
 
	// 画像出力
	header("Content-type: image/png");
	ImagePNG($im);
?>
 
 

イメージ



最終更新:2012年08月18日 10:04