GDIT - GD InTpreter


Usage

gdit [-s] [-d] [-w] [-v] [-?] [-h] [-f <script_file>.gdt] [filename.[gif|xbm]

-s silent operation, don't write to stdout

-d turn parser debugging on

-w turn warning messages on

-v print version number

-? print usage

-h help

-f run gdit script file (extension .gdt)

Language Specification

Reserved Words

The words given in this language specification should not be used as color or style names.

Functions

arc, comment, debug, delete, fill, get, help, line, new, polygon, print, quit, rectangle, save, set.

Qualifiers

brush, brushed, closest, exact, filled, interlaced, information, large, pixel, style, small, tiled, tile, up, transparent.

new

n[ew] width height [color] [transparent] [interlaced]

n[ew] [filename.gif]

n[ew] [filename.xbm]

Description

Create a new image. Either the filename of an existing GIF or XBM file can be specified or the dimensions of an new image supplied. In this case the background color defaults to white, otherwise a predefined or previously defined color must be given. The background color can be made transparent; interlace instructs some browsers to build the image in a number of passes.

gd library

gdImageCreate(), gdImageCreateFromGif(), gdImageInterlace(), gdImageColorTransparent()

save

s[ave] [filename.gif]

Description

Saves the current image as a GIF file. Will overwrite any existing file. If no filename is given GIF data is written to the standard output.

gd library

gdImageGif()

delete

del[ete]

Description

Deletes the current image. Does nothing if there is not a current image.

del[ete] bru[sh]

Description

Deletes the bush.

delete tile

Description

Deletes the tile.

delete style name

Description

Deletes the named style.

del[ete] sty[le] al[l]

Description

Deletes all the styles.

del[ete] al[l]

Description

Deletes all of the above.

gd library

gdImageDestroy()

set

se[t] pix[el] x y color

Description

Sets the pixel specified by the coordinate x, y to the given color.

se[t] tran[sparent] [color | index]

Description

Set the transparent color, the color can either be specified as a name (either from the predefined list or the user list) or as an index from the current palette. If no value is give the transparent color is set to none. GDIT does not check whether an index is valid.

se[t] inter[laced]

Description

Make the current image interlaced. Some Web browsers can load interlaced images in a number of passes. An initial low resolution images of the correct dimensions is loaded first and the full image is built up over a number of passes.

se[t] [clos[est]] color <red> <green> <blue> name

Description

Define a color. This option lets the user add colors in addition to the predefined set. The user may redefine any of the predefined colors but may not redefine any previously defined user colors. These must be deleted before redefinition. The user defined color name takes precedence over a predefined color of the same name. Up to gdMaxColors can be defined.

se[t] clos[est]

set exact

Description

Instructs drawing operations to use either the closest color match if the color table is full. Normally draw functions fail if there is not an exact match for the desired color. The default is exact.

se[t] sty[le] name [count] color1... [countn] colorn

Description

se[t] bru[sh] <file>.gif

Description

Loads a brush from the specified brush file. The brush can be used in line drawing by giving a color of brushed.

Example

new 100 100 light_gray interlaced transparent

set brush brush.gif

arc 50 50 35 35 0 360 brushed

se[t] tile filename.gif

Description

Load a tile from the specified tile file. A tile can be used in filled area drawing by giving a color of tiled.

Example

new 100 100 light_gray interlaced transparent

set tile tile.gif

r 20 20 80 80 tiled filled

Remarks

You will normally want to set the background color of the brush to transparent. You can do this by loading the image in gdit , examining the background color with get pixel and then set the returned index to transparent. This is much better for you than giftrans!

new brush.gif Load brush gif file

get pixel 1 1

index 7 rgb 128 128 128

set transparent 7

save brush.gif

gd library

gdImageSetPixel(), gdImageInterlaced(), gdImageColorTransparent(), gdImageSetBrush() gdImageSetStyle(),

line

l[ine] x1 y1 x2 y2 color

l[ine] x1 y1 x2 y2 brushed

l[ine] x1 y1 x2 y2 style name [brushed]

Description

Draws a line between the points x1,y1 and x2,y2. Color can be any predefined or user defined color. If a brush has been loaded the modifier brushed can be used. The brush image will be drawn for each pixel, as a brush image is normally more than one pixel wide it will create the effect of a wide paintbrush.

The second form allows drawing with a previously defined style. Dashed, dotted or even more exotic line styles can be drawn. If the modifier brushed is supplied the brush image is drawn for each pixel which is not transparent.

example

This image was produced by linetest.gdt:

gd library

gdImageLine()

polygon

po[lygon] x1 y1 ... xn yn color [filled]

po[lygon] x1 y1 ... xn yn style name [brushed][filled]

po[lygon] x1 y1 ... xn yn tiled filled

Description

Draws a polygon. That is a closed shape between the given coordinates. It can be filled with the border color. The color can also be specified as brushed, and the border will be drawn with the current brush.

A user defined style can be used in place of the color. This color can be brushed, in this case the brush is only drawn where there is a color specified in the style (e.g. not transparent). Filled polygons can also be tiled.

example

This image was generated by the file polytest.gdt and shows some of the weird possibilities:

gd library

gdImagePolygon(), gdImageFilledPolygon()

rectangle

r[ectangle] x1 y1 x2 y2 color [filled]

r[ectangle] x1 y1 x2 y2 style name [brushed][filled]

r[ectangle] x1 y1 x2 y2 tiled filled

Description

Draw a rectangle. x1,y1 is the top left corner and x2,y2 the bottom right. The same styles as for polygons can be applied.

example

And using rectest.gdt here's what's possible:

gd library

gdImageRectangle(), gdImageFilledRectangle()

arc

a[rc] x y height width start end color

a[rc] x y height width start end brushed

a[rc] x y height width start end style name [brushed]

Description

Draws a partial ellipse centered on coordinates x,y of size width and height. It begins at the angle given by start and finishes at the angle specified by end. The same styles as for line can be applied.

example

n 100 100 light_gray interlaced transparent

arc 50 50 30 20 25 180 red

and from arctest.gdt:

gd library

gdImageArc()

fill

f[ill] x y color [color]

f[ill] x y tiled [color]

Description

This floods a portion of the image with the specified color. It begins at the point x y and floods the surrounding region until a color different from the starting color is reached. If a second color is given fill floods a region to this specified border color. The flood color can be tiled. Note: a tile should not be transparent, load a tile in gdit and set transparent to turn off transparency.

examples

n 100 100 light_gray interlaced transparent

r 20 20 80 80 red

r 40 40 60 60 green

fill 30 30 yellow

n 100 100 light_gray interlaced transparent

arc 50 50 40 80 0 360 red

fill 50 50 white red

and from filltest.gdt:

gd library

gdImageFill(), gdImageFillToBorder

get

g[et] pix[el] x y

Description

Returns the color index and red, green and blue components. This is useful for setting a color to transparent in a GIF.

Example

new old.gif an old GIF87 file

get pixel 0 0

index 0; RGB values are 192, 192, 192

set transparent 0 shiny new transparent GIF87!

get information

Description

Returns information about the image including the width and height in pixels, whether it's interlaced, the transparent color index

print

pr[int] [up][large|small|medium|giant|tiny] x y color "string"

Description

Print text strings. Two fonts are provided by the gd library, these are called large and small. The qualifier up prints text vertically. x and y give the position of the top left of the first letter. Color can be any predefined or user defined color. The string to be printed must be surrounded by double quotes.

Note: It should be possible to print a " character within a string by escaping it with a \, this does not work for some reason.

example

As a variation on the old hello world theme try prttest.gdt:

gd library

gdImageString(), gdImageStringUp()

comment

c[omment] "comment string"

Description

Add a comment string to the GIF file.

help

h[elp] <topic>

Description

On line help for the above topics.

quit

quit|bye

Description

Exit the program. Deallocates styles and images before quitting. This is the preferred way of exiting gdit.

debug

debug_on

debug_off

Description

Turn on parser debugging (program must be built with parser debugging enabled, see makefile)

Predefined Colors

This set of colors is predefined and may be referred to by name in the drawing primitives.

Color           Red        Green     Blue
salmon          255        128        128
red             255          0          0        
brown           128         64         64
dark_red        128          0          0
red_black        64          0          0
black             0          0          0
wheat           255        255        128
yellow          255        255          0
orange          255        128         64
orange_red      255        128          0
red_brown       128         64          0
forest_green    128        128          0
green_yellow    128        255        128
medium_green    128        255          0
green             0        255          0
dark_green        0        128          0
green_black       0         64          0
sienna          128        128         64
spring_green    128        255          0
blue_green        0        255         64
gun_metal         0        128        128
malachite         0        128         64
gray            128        128        128
aquamarine      128        255        255
sky_blue          0        255        255
blue              0          0        255
purple            0          0        128
ocean            64        128        128
slate_blue        0        128        255
cadet_blue        0        128        192
navy_blue         0          0        160
blue_black        0          0         64
light_gray      192        192        192
mauve           128          0        128
violet          255        128        255
magenta         255          0        255
violet_red      255          0        128
royal_blue      128          0        255
white           255        255        255

Notes

thus:

> new 100 100; line 0 0 100 100 red; save file.gif

is valid. This has been added because the Windows parser fails to recognize new line characters as input tokens until the next input token in encountered. I don't have a fix for this, any offers?

so on Windows:

> help <NEWLINE>

will not display help until the next input line (including an input line with only a newline token!).

> help;

will display help.

Unsupported gd functions

gdImageCreateFromGd(), gdImageGd(), gdImageDashedLine(),gdImageBoundsSafe(), gdImageChar(), gdImageCharUp(), gdImageCopy(), gdImageCopyResized().


Home Up Index

Last Updated: 16th December, 1995. © 1995 DB Harvey-George, ITCP