Goto main content

gd_line

Draw a line.

GD_LINE

NAME

gd_line - Draws a line.

SYNOPSIS

gd_line (gd:variable, x1:integer, y1:integer, x2:integer, y2:integer, color:"string", style: array, thickness:integer, coloridx:integer);

DESCRIPTION

This function is used to draw a line between (x1,y1) and (x2,y2).

PARAMETERS

gd
Variable 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. Default is 4.
style
It is often desirable to draw dashed lines, dotted lines, and other variations on a broken line. Style can be used to set any desired series of colors, including a special color that leaves the background intact, to be repeated during the drawing of a line. To use style, create an array of integers and assign them the desired series of color values to be repeated. You can assign the special color value null to indicate that the existing color should be left unchanged for that particular pixel (allowing a dashed line to be attractively drawn over an existing image). The specification of color are color index not string. You must allocate them with gd_get_color.

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:Blue,truecolor:true);
        coral = gd_get_color(gd:im, color:Coral);
        cyan = gd_get_color(gd:im, color:Cyan);
        gd_line(gd:im, x1:500, y1:500, x2:500,y2:300, thickness:20,
        style:[coral,cyan,null,color,null,white]);
        color = gd_get_color(gd:im, color:Yellow);
        color;
        gd_line(gd:im, x1:-100, y1:-100, x2:200,y2:900, color:White);
        gd_write(gd:im,format:"jpg",filename:"/html/images/print.jpg",quality:100);
        gd_free(im);

SEE ALSO

AUTHOR

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

MODIFICATIONS

1.0 2014-09-09 21:24:14 laplante@sednove.com

Edit

© 2024 extenso Inc. All rights reserved.