
Data Structure
Networking
RDBMS
Operating System
Java
MS Excel
iOS
HTML
CSS
Android
Python
C Programming
C++
C#
MongoDB
MySQL
Javascript
PHP
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
imagepolygon() function in PHP
The imagepolygon() function is used to draw a polygon.
Syntax
bool imagepolygon( $img, $points, $num_points, $color)
Parameters
- $img: Create a blank image with imagecreatetruecolor() function.
- $points: An array with vertices of polygon.
- $num_points: Total number of vertices in a polygon.
- $color: A color identifier created with imagecolorallocate() function.
Return
The imagepolygon() function returns TRUE on success or FALSE on failure.
Example
The following is an example:
<?php $img = imagecreatetruecolor(400, 300); $color = imagecolorallocate($img, 120, 160, 190); $bgcolor = imagecolorallocate($img, 10, 100, 50); imagefill($img, 0, 0, $bgcolor); imagepolygon($img, array( 50, 50, 150, 200, 340, 200 ), 3, $color); header('Content-type: image/png'); imagepng($img); imagedestroy($img); ?>
Output
The following is the output:
Advertisements