imageopenpolygon
Description
The imageopenpolygon of Image for PHP draws an open polygon.
Syntax
imageopenpolygon(
GdImage $image,
array $points,
int $color
): boolParameters
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 =
[
0, 50,
50, 0,
100, 50,
50, 100
];
$return = imageopenpolygon($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 =
[
0, 50,
50, 0,
100, 50,
50, 100
];
imageopenpolygon($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/gAIDAAAACXBIWXMAAA7EAAAOxAGVKw4bAAABiUlEQVR4nO3S243DMAwFUffftPeDWCRIHHv8kERJMxVcHnBZUraua+sJnRRSeh33bqTXXt86em33y0Wvz/ZF9HpFLPRaljMKs3udvX9er2uXz+h15+a5vO5fO4vXU3eO7/XshSN7lbhtTK9yV43mVfqecbzqXDKCV80b+vaqv75Xr1a7+/Nqu7gnrwxbM2w4Ls/KPEu2y7Yv255XOZdlXJVx03+5tuVas1WWhVl2HNV+Z/sFZ2q5ti+pqM3mHqWi2sv7lYrq7e9dKqpxxRhSUdlbRpKKSl00nlT0/F2jSkVPXje2VPTMjTNIRXcvnUcqun7vbFLRlavnlIrO3T6zVEQFlIqOHZR6b09Dqe+2TZT61aeMUvu9fJQireuqlBXIr6IpRVOKphRNKZpSNKVoStGUoilFU4qmFE0pmlI0pWhK0ZSiKUVTiqYUTSmaUjSlaErRlKIpRVOKphRNKZpSNKVoStGUoilFU4qmFE0pmlI0pWhK0ZSiKUVTiqYUTSmaUjSlaErREkr9Ab7zvVGCCmRLAAAAAElFTkSuQmCC">
</body>
</html>Links
Image
- gd_info
- getimagesize
- getimagesizefromstring
- image_type_to_extension
- image_type_to_mime_type
- imageaffine
- imageaffinematrixconcat
- imageaffinematrixget
- imagealphablending
- imageantialias
- imagearc
- imageavif
- imagebmp
- imagechar
- imagecharup
- imagecolorallocate
- imagecolorallocatealpha
- imagecolorat
- imagecolorclosest
- imagecolorclosestalpha
- imagecolorclosesthwb
- imagecolordeallocate
- imagecolorexact
- imagecolorexactalpha
- imagecolormatch
- imagecolorresolve
- imagecolorresolvealpha
- imagecolorset
- imagecolorsforindex
- imagecolorstotal
- imagecolortransparent
- imageconvolution
- imagecopy
- imagecopymerge
- imagecopymergegray
- imagecopyresampled
- imagecopyresized
- imagecreate
- imagecreatefromavif
- imagecreatefrombmp
- imagecreatefromgif
- imagecreatefromjpeg
- imagecreatefrompng
- imagecreatefromstring
- imagecreatefromtga
- imagecreatefromwbmp
- imagecreatefromwebp
- imagecreatefromxbm
- imagecreatefromxpm
- imagecreatetruecolor
- imagecrop
- imagecropauto
- imagedashedline
- imagedestroy
- imageellipse
- imagefill
- imagefilledarc
- imagefilledellipse
- imagefilledpolygon
- imagefilledrectangle
- imagefilltoborder
- imagefilter
- imageflip
- imagefontheight
- imagefontwidth
- imageftbbox
- imagefttext
- imagegammacorrect
- imagegetclip
- imagegetinterpolation
- imagegif
- imageinterlace
- imageistruecolor
- imagejpeg
- imagelayereffect
- imageline
- imageloadfont
- imagepalettecopy
- imagepalettetotruecolor
- imagepng
- imagepolygon
- imagerectangle
- imageresolution
- imagerotate
- imagesavealpha
- imagescale
- imagesetbrush
- imagesetclip
- imagesetinterpolation
- imagesetpixel
- imagesetstyle
- imagesetthickness
- imagesettile
- imagestring
- imagestringup
- imagesx
- imagesy
- imagetruecolortopalette
- imagettfbbox
- imagettftext
- imagetypes
- imagewbmp
- imagewebp
- imagexbm
- iptcembed
- iptcparse