Contents
Login Register Wishes Forum About
Language Reference » Drawing functions » drawPolygon
Help topics
Latest updates
4575d  replaceImageMapTitle
4575d  replaceImageMapValues
4575d  createFunctionSerie
4575d  setAbsicssaPosition
4575d  negateValues
Toolbox
  Download as PDF
  Print this page
  Share this page
  Create an account
  Feed the updates!
Google AdSense
drawPolygon - Draw polygons

This function allows you to draw aliased polygons on your pictures. It is possible to tune the rendering by playing with the $Format array. To learn more about this please read the Format array guide. Lines like all simple drawing functions are supporting anti-alias and shadows.

This function is also used internally by a lot of drawing functions (arrows, ...).

Calling this function
drawPolygon($Points,$Format="");
Where :

Points is an array of points.
Format is an array containing the drawing parameters of the polygon.


Customisation array - Tune up your polygon!

It is possible to customize the line rendering by playing with this array. Providing a detailled configuration is not mandatory, by default the polygon will be drawn black with no transparency.

The background color can be set with R, G, B.
The alpha transparency factor can be set with Alpha.
You can specify the border color BorderR,BorderG,BorderB parameter.
The alpha transparency factor of the border can be set with BorderAlpha.
You can use the Surrounding option to define the border color. This value will be added to the R,G,B factors to define the border color.


Sample script



 /* Enable shadow support */
 $myPicture->setShadow(TRUE,array("X"=>2,"Y"=>2,"R"=>0,"G"=>0,"B"=>0,"Alpha"=>10));

 $White = array("R"=>255,"G"=>255,"B"=>255,"Surrounding"=>-100);

 $Step  = 8;
 for($i=1;$i<=4;$i++)
  {
   $Points = "";
   for($j=0;$j<=360;$j=$j+(360/$Step))
    {
     $Points[] = cos(deg2rad($j))*50+($i*140);
     $Points[] = sin(deg2rad($j))*50+120;
    }
   $myPicture->drawPolygon($Points,$White);
   $Step = $Step * 2;
  }

This will draw 4 polygons. As the shadow support is enabled on line 2, the polygons will be surrounded by a small (+2,+2) shadow.
Last updated on 07/12/2010 
by Jean-Damien 
Linked resources
  There is no linked topic yet.
Community comments
  No comments have been posted yet.
© Copyrights
Components used on this web site : Famfamfam icons has been made by Mark James, Rounded corners lite has been coded by Cameron Cooke and Tim Hutchison, SyntaxHighlighter has been written by Alex Gorbatchev. pChart and this web site have been created by Jean-Damien POGOLOTTI. This documentation contains 185 pages and 56 comments. 415 users have registered. This page has been rendered in 0,10 seconds. Wiki revision 1.37.