function

gd_polygon . gd . sncode

VERSIONlatest Draw a polygon.

GD_POLYGON(1e)

NAME

gd_polygon - Draws a polygon.

SYNOPSIS

gd_polygon (gd:variable, polygon:array, color:"string", closed:true|false,filled:true|false, thickness:integer, coloridx:integer);

DESCRIPTION

This function is used to draw a polygon.

PARAMETERS

gd
Variables must hold a returned value from gd_new.
x1,y1
First point in image.
x2,y2
Second point in image.
color
A color in the format #000000 or #255,255,255.
coloridx
A color index gotten from gd_get_color.
thickness
Thickness of line in pixel. By default, it is 4.
polygon
An array of the form [ [x1,y1], [x2,y2], … ].
closed
Closes the polygon if not closed. By default, it is true.
filled
Fills the polygon. By default, it is false.

RETURN

Nothing.

MODULES

To use this module, you must specify the following in /usr/local/website/site.conf:

Module gd {
        Library : "/usr/local/lib/libsngd.so"
        Init : "sngd_init"
}

EXAMPLES

res=<{
        %include "/includes/gd.sn";
        remove("/html/images/print.jpg");
        im=gd_new(width:1000,height:1000,bgcolor:Gray,truecolor:true);
        red = gd_get_color(gd:im, color:Red);
        cyan = gd_get_color(gd:im, color:Cyan);
        white = gd_get_color(gd:im, color:White);
        gd_polygon(gd:im, polygon:[ [10,10], [10, 500], [500, 500], [500, 10]], color:Yellow, thickness:2,filled:true);
        gd_polygon(gd:im, polygon:[ [40,40], [200,259], [332, 644], [500, 10], [700,700]], color:Red, thickness:1,closed:false);
        gd_write(gd:im,format:"jpg",filename:"/html/images/print.jpg",quality:100);

AUTHOR

Written by Pierre Laplante and Caroline Laplante, <laplante@sednove.com>