This is a work in progress and is intended for the J602 release. It is currently available in the J601 script library from build 31.

Drawing Commands

New plot commands support direct use of drawing commands within a pd command sequence. The main benefit of doing this within Plot instead of direct to the isigraph control after a Plot is drawn, is that the drawing is positioned in the Plot graphics subwindow, and the commands can be run before the data is drawn.

The new commands are named gdxxx, and are cover functions for the corresponding glxxx commands, much like the Graph package, e.g. gdpencolor 255 0 0 sets the pen color to red.

By default, drawing takes place after the axes are drawn, and before the data is plotted. The command gdend sets subsequent gdxxx commands to be drawn after the data is plotted.

Drawing takes place in the current plot's Graf Box, Gxywh, see Layout.

Positions

All positions are set with absolute positions xy, rather than positions plus width and height. For example, a rectangle is specfied as x0,y0,x1,y1 rather than as x,y,w,h.

An xy of 0 0 is the bottom left corner, i.e. Gx,Gy. This corresponds to the positioning in plot, whereas gl2 commands normally start at the top left.

Each position can be given in one of three ways, that can be mixed together:

1. an ordinary number is a value between 0 and 1000 inclusive, where 0 is the bottom/left and 1000 is the top/right of the Graf Box, e.g. 500,1000 is halfway along the x axis, at the top.

2. a number with an r suffix is an axis position, e.g. 2r,3r corresponds to position 2 on the x-axis, 3 on the y-axis. (Note, positioning to a second y axis is not yet supported).

3. a number with an x suffix is in pixels. A negative position counts from the end, offset by 1, so that -101x -201x -1x -1x is the 100 x 200 pixels at the top right corner.

Command Summary

Only a few commands are currently implemented.

State-setting:

Drawing:

Example

pd 'type bar'
pd 'barwidth 0.4'
pd 'color 128 192 255'
pd 'gdpen 2 0'
pd 'gdlines 0 4r 1000 4r'
pd 'gdend'
pd 'gdpen 5 0;gdpencolor 255 0 0'
pd 'gdlines 0 0 1000 800'
pd 'gdpen 1 0;gdpencolor 0 0 0;gdbrushcolor 0 128 0'
pd 'gdrect 0 0 2r 1r'
pd 5 2 7 3
pd 'show'

gdcmd.png

ChrisBurke/Drawing (last edited 2008-12-08 10:45:33 by )