龙盟编程博客 | 无障碍搜索 | 云盘搜索神器
快速搜索
主页 > web编程 > php编程 >

php使用 imagepolygon()方法画图

时间:2015-01-07 11:23来源:网络整理 作者:网络 点击:
分享到:
php使用 imagepolygon()方法画图 [代码片段(27行)]
$points array accepted by the imagepolygon() function is of the following format

<?php

    define('WIDTH', 100);
    define('HEIGHT', 100);

    $img = imagecreate(WIDTH, HEIGHT);
    $white = imagecolorallocate($img, 0xFF, 0xFF, 0xFF);
    $black = Imagecolorallocate($img, 0, 0, 0);

    $points = array(0, 0,                // Vertex (0,0)
                    0, HEIGHT,           // Vertex (0, HEIGHT)
                    (int)WIDTH/2, 0,     // Vertex (WIDTH/2, 0)
                    WIDTH-1, HEIGHT-1,   // Vertex (WIDTH, HEIGHT)
                    WIDTH-1, 0);         // Vertex (WIDTH, 0)

    imagepolygon($img, $points, 5, $black);

    header('Content-type: image/png');
    imagepng($img);

?>

精彩图集

赞助商链接