Jesus · Bible · HTML · CSS · JS · PHP · SVG · Applications

imagefilledpolygon

Description

The imagefilledpolygon of Image for PHP draw a filled polygon.

Syntax

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

Parameters

image

A GdImage object, returned by one of the image creation functions, such as imagecreatetruecolor().

points

An array containing the x and y coordinates of the polygons vertices consecutively.

color

A color identifier created with imagecolorallocate().

Return

Returns true on success or false on failure.

Examples

1 · return

<?

$width = 100;
$height = 100;
$image = imagecreate($width, $height);

$red = 255;
$green = 255;
$blue = 255;
$color = imagecolorallocate($image, $red, $green, $blue);

$points = array(
    0, 50,
    50, 0,
    100, 50,
    50, 100
);

$return = imagefilledpolygon($image, $points, $color);
    
var_export($return);

?>
true

2 · base64

<?

$width = 100;
$height = 100;
$image = imagecreatetruecolor($width, $height);

$red = 255;
$green = 255;
$blue = 255;
$color = imagecolorallocate($image, $red, $green, $blue);

$points = array(
    0, 50,
    50, 0,
    100, 50,
    50, 100
);
imagefilledpolygon($image, $points, $color);

ob_start();

    imagepng($image);

$output = ob_get_clean();

echo '<!doctype html>
<html>
<body>
    <img src="data:image/png;base64,' . base64_encode($output) . '">
</body>
</html>';

?>
<!doctype html>
<html>
<body>
    <img src="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAGQAAABkCAIAAAD/gAIDAAAACXBIWXMAAA7EAAAOxAGVKw4bAAACfklEQVR4nO3dW5KDIBRFUZz/oNMfp8skBpWL9wWcPQJqVR6ICqWk7PV6RQ+h0hY9gEq71LblGl6u0ZSfz1Qqr0RDKSffvjxeWcZRLn+nknilGERp+EXP4BU/gtL83xfuFY8lmiXEegVjdcynAr0isbpnnlFeYVgP5+ghXjFYKlcz/l4BWIrXfc5e3ljqV8ieXq5YRmsJbl5+WKarLj5eTlgO61MOXh5Ybit51l7mWM5rnqZetlghq8N2XoZYgevoRl5WWOF3HCy8TLDCpZC6lz5WEimk66WMlUoKKXppYiWUQlpealhppZCKlw5Wcin03EsBawgp9NDrKdZAUuiJ1yOs4aRQt1c/1qBSqM+rE2toKdTh1YM1gRSSeomxppFCIi8Z1mRSqN1LgDWlFGr0asWaWAq1eDVhTS+Fbr3usRaRQtdeN1hLSaELryusBaXQmdcp1rJSqOpVx1pcCv16VbAotXfwOmJR6tCn1xcWpartXm8sSl0Er38sSt22AYxSjW2Uao+fLEH8zWpt+5xE0Ouir39DRK9qlXkWoteh0xk8otfezbUholdpXHVAi3sJ1rPQsl7ilVK0oFfnGjxayuvR3R20iJfCfUM0vZfaHWk0sZfysw5oSi+Tp2jQZF6Gz2ehabzMn/xDE3g5PVOKhvZyfVoZDeoV8Bw8Gs4r7A0LNJBX8Ls7aAivFG+FoeReid43RGm90r3JihJ6JX1HGqXySv32PUriNcC+Dijca5gdQxD3opHFXY5kcf8sWdyZTRb3/JPF3SRlcZ9SWdwBVxb3VpbFXbtlcT94WTxpQBbPsJDF01Fk8dwdWTzRSRbPCpPFU+hk8XxDWWlPzvwDAtYsZ4NuPJEAAAAASUVORK5CYII=">
</body>
</html>
HomeMenu