<?php
// Initialisiere das Array der Polygon-Punkte
$values = array(
40, 50, // Punkt 1 (x, y)
20, 240, // Punkt 2 (x, y)
60, 60, // Punkt 3 (x, y)
240, 20, // Punkt 4 (x, y)
50, 40, // Punkt 5 (x, y)
10, 10 // Punkt 6 (x, y)
);
// Erzeuge das Bild
$image = imagecreatetruecolor(250, 250);
// Weise Farben zu
$bg = imagecolorallocate($image, 0, 0, 0);
$blue = imagecolorallocate($image, 0, 0, 255);
// Fülle den Hintergrund
imagefilledrectangle($image, 0, 0, 249, 249, $bg);
// Zeichne ein Polygon
imagefilledpolygon($image, $values, $blue);
// Gib das Bild aus
header('Content-type: image/png');
imagepng($image);
?>
Das oben gezeigte Beispiel erzeugt
eine ähnliche Ausgabe wie: