imagefilledpolygon

(PHP 4, PHP 5, PHP 7)

imagefilledpolygon — Zeichne ein gefülltes Polygon

Beschreibung

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

imagefilledpolygon() erzeugt ein gefülltes Polygon im angegebenen image.

Parameter-Liste

image

Eine von den verschiedenen Erzeugungsfunktionen wie imagecreatetruecolor() gelieferte Grafikressource.

points

Ein Array, das die x und y Koordinaten der aufeinanderfolgenden Polygon-Eckpunkte enthält.

num_points

Die Anzahl der Eckpunkte, die wenigstens 3 sein muss.

color

Eine Farbkennung, die mit imagecolorallocate() erzeugt wurde.

Rückgabewerte

Gibt bei Erfolg TRUE zurück. Im Fehlerfall wird FALSE zurückgegeben.

Beispiele

Beispiel #1 imagefilledpolygon() Beispiel

<?php
// initialisiere das Array der Polygon-Punkte
$values = array(
            
40,  50,  // Point 1 (x, y)
            
20,  240, // Point 2 (x, y)
            
60,  60,  // Point 3 (x, y)
            
240, 20,  // Point 4 (x, y)
            
50,  40,  // Point 5 (x, y)
            
10,  10   // Point 6 (x, y)
            
);

// Erzeuge das Bild
$image = imagecreatetruecolor(250, 250);

// Alloziere Farben
$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, 6, $blue);

// Gib das Bild aus
header('Content-type: image/png');
imagepng($image);
imagedestroy($image);
?>

Das oben gezeigte Beispiel erzeugt eine ähnliche Ausgabe wie:

Ausgabe des Beispiels : imagefilledpolygon()

Siehe auch