Javatpoint Logo
Javatpoint Logo

PHP imagepolygon ( ) Function

The image polygon ( ) function is one more inbuilt PHP work basically used to draw a polygon with absolutely given coordinates. This capacity works utilizing the x and y axis that are automatically derived by the PHP compiler, all we have to do is to set organizes for the beginning stage from where the image must be drawn. The beginning directions also called the origin (0, 0) are in the perusing window's upper left corner. You can set the directions in like manner from the beginning to get the subsequent polygon as per our necessities. This function returns a Boolean value which validates a true on successful progression and a false validation on disapproval

Syntax:

Parameters: This function accepts various parameters; which are as follows:

S.No Parameter Description Optional / mandatory
1 $ image This parameter is utilized to characterize the size of the picture we need to show. This parameter is utilized by a picture asset like the imagecreatetruecolor ( ) function which is used to return a picture source. Mandatory
2 $ points This parameter is utilized to set the ideal vertices of the polygon, beginning from the origin mandatory
3 $ num - points This parameter is utilized to set the absolute number of vertices in a polygon. What's more, it should be more prominent than 3 as no polygon can be less than of three sides or else it is called a straight line. mandatory
4 $ color This parameter is utilized to characterize the shade of the picture. This parameter is utilized for making a variety recognizes like the imagecolorallocate ( ) functions optional

The image arc ( ) function returns TRUE on successful execution of the program and FALSE on a failed attempt.

Program 1: PHP program to display the use of imagepolygon ( ) function to draw a polygon

Output:

PHP imagepolygon ( ) Function

In the above program, we have pronounced different factors like $image to stamp out the size of the picture that we require, $background variety to check out the shade of foundation we require, $text variety to stamp out the shade of text we require, a cluster $values to set the directions of the polygon we want to proclaim, and we have utilized the image polygon ( ) capacity to show the polygon we need to show as a picture, to show the result of the picture we have utilized an inbuilt PHP order header and image png to show in the program.

Program 2: PHP program to display the use of imagepolygon ( ) function to draw a polygon

Output:

PHP imagepolygon ( ) Function

Here in this program, we have announced different factors like $image to stamp out the size of the picture that we require, $background variety to check out the shade of foundation we require, $text variety to stamp out the shade of text we require, an exhibit $values to set the directions of the polygon we want to proclaim, and we have utilized image polygon ( ) to show the polygon we need to show as a picture, to show the result of the picture we have utilized an inbuilt PHP order header and image png to show on program.

Program 3: Basic PHP program to display the use of imagepolygon ( ) function to draw a polygon

Output:

PHP imagepolygon ( ) Function

Here, in the above program, we have pronounced different factors like $image to characterize the size of the picture that we require, $background variety to characterize the shade of foundation we require, $text variety to characterize the shade of text we require, an exhibit $values to set the directions of the polygon we want to proclaim, and we have utilized image polygon ( ) to show the polygon we need to show as a picture, to show the result of the picture we have utilized an inbuilt PHP order header and image png to show on program.







Youtube For Videos Join Our Youtube Channel: Join Now

Feedback


Help Others, Please Share

facebook twitter pinterest

Learn Latest Tutorials


Preparation


Trending Technologies


B.Tech / MCA