忍者ブログ
Flex,Java,Html など、調べた事のメモ帳です。 間違ってたらゴメンなさい。
×

[PR]上記の広告は3ヶ月以上新規記事投稿のないブログに表示されています。新しい記事を書く事で広告が消えます。

現在の時刻
<?php echo date( "Y/m/d (D) H:i:s", time() ) ?>

グリニッジ標準時
<?php echo gmdate("Y/m/d (D) H:i:s", time() ) ?>

imagefilledpolygon — 塗りつぶした多角形を描画する

説明

bool imagefilledpolygon ( resource $image , array $points , int $num_points , int $color )

imagefilledpolygon() は画像 image 上に塗りつぶした多角形を生成します。

パラメータ

 

image

imagecreatetruecolor() のような画像作成関数が返す画像リソース。

points

多角形の頂点の座標 x および y を含む配列。

num_points

頂点の総数。 3 以上である必要があります。

color

imagecolorallocate() で作成した色 ID。

返り値

成功した場合に TRUE を、失敗した場合に FALSE を返します。

 

例1 imagefilledpolygon() の例

<?php
// 多角形の点の配列を準備します
$values = array(
            
40,  50,  // Point 1 (x, y)
            
20,  240// Point 2 (x, y)
            
60,  60,  // Point 3 (x, y)
            
24020,  // Point 4 (x, y)
            
50,  40,  // Point 5 (x, y)
            
10,  10   // Point 6 (x, y)
            
);

// 画像を生成します
$image imagecreatetruecolor(250250);

// 色を割り当てます
$bg   imagecolorallocate($image000);
$blue imagecolorallocate($image00255);

// 背景を塗りつぶします
imagefilledrectangle($image00249249$bg);

// 多角形を描画します
imagefilledpolygon($image$values6$blue);

// 画像を出力します
header('Content-type: image/png');
imagepng($image);
imagedestroy($image);
?>

GDの勉強がてら、円を透過PNGで書き出すサンプルです。

<?php
$img = imagecreatetruecolor(111, 111);//からのキャンバスの作成
$backgroundColor = imagecolorallocate($img, 255, 255, 255);//背景色セット
imagefill($img, 0, 0, $backgroundColor); // 背景を塗る。
imagecolortransparent($img,$backgroundColor);//透明化
 
// 楕円の色を選択します
$color = imagecolorallocate($img, 220, 90, 90);
$color2 = imagecolorallocate($img, 255, 255, 255);
 
// 白い楕円を描画します
imagefilledellipse($img, 55, 55, 110, 110, $color);
imagefilledellipse($img, 55, 55, 40, 40, $color2);
 
// 画像を出力します
imagepng($img,"./circle.png");
?>
 

スクリプトが実行可能な秒数を設定します。 この制限にかかるとスクリプトは致命的エラーを返します。 デフォルトの制限値は 30 秒です。 なお、php.inimax_execution_timeの 値が定義されている場合にはそれを用います。

この関数がコールされた場合、 タイムアウトカウンタをゼロから再スタートします。 言いかえると、タイムアウトがデフォルトの 30 秒で スクリプト実行までに 25 秒かかる場合に、 set_time_limit(20) を実行すると、スクリプトは、 タイムアウトまでに全体で 45秒 の間実行されます。

文字列型変数を数値型変数に変換する方法 (10進数)

// 文字列型変数の宣言
$str = "11";

// 文字列型変数を数値型変数に変換する
$num10 = intval($str);
 
ブログランキング
にほんブログ村 IT技術ブログ IT技術メモへ
 
カレンダー
02 2024/03 04
S M T W T F S
1 2
3 4 5 6 7 8 9
10 11 12 13 14 15 16
17 18 19 20 21 22 23
24 25 26 27 28 29 30
31
人気ブログランキング
ブログランキング ブログランキング
最新TB
ブログ内検索
PR
ATOM  
ATOM 
RSS  
RSS 
Copyright ©   プログラムメモ   All Rights Reserved
Design by MMIT  Powered by NINJA TOOLS
忍者ブログ [PR]