PHP/Graphics Image/imagepolygon

Материал из Web эксперт
Версия от 10:05, 26 мая 2010; Admin (обсуждение | вклад) (1 версия)
(разн.) ← Предыдущая | Текущая версия (разн.) | Следующая → (разн.)
Перейти к: навигация, поиск

Drawing Polygons Using imagepolygon()

   <source lang="html4strict">

$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);

?>

 </source>