PLOT

These plotting routines use the current window to write on, in the current color, linestyle, etc.

Functions


g_get_xy

void g_get_xy(float *x, float *y)

Description:

Get the current position of the pen.

Outputs:

x, y - The current new position in user (world) coordinates.

g_moveto

void g_moveto(float x, float y)

Description:

move to drawing pen to position x, y

Inputs:

x, y - The new position in user (world) coordinates.

g_lineto

void g_lineto(float x, float y)

Description:

draw a line from the current pen position to position x, y.

Inputs:

x, y - The new position in user (world) coordinates.

g_label

void g_label(char *label)

Description:

print text at current pen position.

Inputs:

label - The text to be printed.

g_rectangle

void g_rectangle(float x1, float y1, float x2, float y2)

Description:

Draw a rectangle which has position x1, y1 in one corner and position x2, y2 in the corner that is diagonally opposed to it.

Inputs:

x1, y1 - Position of the first corner in user (world) coordinates.

x2, y2 - Position of the other corner in user (world) coordinates.


g_drawpoly

void g_drawpoly(long numpoint, float *points)

Description:

Draw a polygon from the first point in points, to the last point. The figure is not automatically closed. (at this moment no soft-clipping is supported).

Inputs:

numpoints - The number of x- and y-coordinate pairs in points.

points - An array of x- an y-coordinate pairs in user (world) coordinates.


g_circle

void g_circle(float radius)

Description:

Draw a circle with the current x,y coordinates as central point.

Inputs:

radius - Radius in user (world) coordinates.

g_fillrectangle

void g_fillrectangle(float x1, float y1, float x2, float y2)

Description:

Draw a rectangle which has position x1, y1 in one corner and position x2, y2 in the corner that is diagonally opposed to it, and fill it with the current foreground color. For black and white plot- on-paper, the fill color is white if foreground color == background color, and black otherwise.

Inputs:

x1, y1 - Position of the first corner in user (world) coordinates.

x2, y2 - Position of the other corner in user (world) coordinates.


g_fillpoly

void g_fillpoly(long numpoint, float *points)

Description:

Draw a polygon from the first point in points, to the last point, and fill it with the current foreground color. The figure is automatically closed. (at this moment no soft-clipping is supported).

Inputs:

numpoints - The number of x- and y-coordinate pairs in points.

points - An array of x- an y-coordinate pairs in user (world) coordinates.


g_fillcircle

void g_fillcircle(float radius)

Description:

Draw a circle with the current x,y coordinates as central point and fill the circle with the foreground color. For black and white plot-on-paper, the fill color is white if foreground color == background color, and black otherwise.

Inputs:

radius - Radius in user (world) coordinates.

g_newpage

void g_newpage(void)

Description:

Clear the window or eject paper. This will delete the history (objects, viewports) of a window. The objects and viewports itself will not be deleted.

g_set_outfile

void g_set_outfile(FILE *outfile)

Description:

Set the current output file. G_HPGL and G_POSTSCRIPT will write output to this file.

Inputs:

outfile - The outputfile.

Default:

stdout

g_get_outfile

FILE *g_get_outfile(void)

Description:

Returns the current output file.

g_set_clipping

void g_set_clipping(int clip)

Description:

Set viewport clipping. Everything outside the current viewport is not plotted. If the device does not support clipping, genplot will do the clipping (soft clipping) but only for g_moveto() and g_lineto() operations.

Inputs:

clip - The clipping state. TRUE = on , FALSE = off.

Default:

off

g_get_clipping

int g_get_clipping(void)

Description:

Returns the clipping state.

Returns:

TRUE = on , FALSE = off.

g_set_linewidth

void g_set_linewidth(int width)

Description:

Set the linewidth for all drawing operations.

Inputs:

width - The linewidth in pixels.

Default:

1

g_get_linewidth

int g_get_linewidth(void)

Description:

Get the current linewidth.

Returns:

The linewidth in pixels.

g_set_linestyle

void g_set_linestyle(int pattern)

Description:

Set the linestyle for all drawing operations.

Inputs:

pattern - G_SOLID, G_SHORT_DASHED, G_LONG_DASHED,G_DOTTED

Default:

G_SOLID

g_get_linestyle

void g_get_linestyle(void)

Description:

Get the current linestyle.

Returns:

G_SOLID, G_SHORT_DASHED, G_LONG_DASHED or G_DOTTED

g_set_palettesize

int g_set_palettesize(int size)

Description:

Set the number of palette entries (colors).

Inputs:

size - The new number of palette entries (colors).

Default:

16

Returns:

G_OK on success. G_ERROR if size less than 2.

g_get_palettesize

int g_get_palettesize(void)

Description:

Get the number of palette entries (colors).

g_set_paletteentry

int g_set_paletteentry(int entry_id, G_PALETTEENTRY entry)

Description:

Set the RGB color values of a palette entrie.

Inputs:

entry_id - The number of the palette entry (=color) that has to change.

entry - The new palette entry. The range of the RGB values is (0 ... 255).

Returns:

G_OK on success. G_ERROR if entry_id is out of range.

Example:

/* typedef from genplot.h */
typedef struct {
     unsigned char r;
     unsigned char g;
     unsigned char b;
} G_PALETTEENTRY;

G_PALETTEENTRY pal;
pal.r = 0;     /* red */
pal.g = 0;     /* green */
pal.b = 100;   /* blue */
g_set_paletteentry(5, pal);

g_get_paletteentry

int g_get_paletteentry(int entry_id, G_PALETTEENTRY *entry)

Description:

Get the RGB color values of a palette entrie.

Inputs:

entry_id - The number of the palette entry (=color).

Outputs:

entry - The RGB values of the palette entry.

Returns:

G_OK on success. G_ERROR if entry_id is out of range.

g_set_foreground

void g_set_foreground(int color)

Description:

Set the foreground color if color is available.

Inputs:

color - The foreground color. G_BLACK, G_BLUE, G_GREEN, G_CYAN, G_RED, G_MAGENTA, G_BROWN, G_LIGHTGRAY, G_DARKGRAY, G_LIGHTBLUE, G_LIGHTGREEN, G_LIGHTCYAN, G_LIGHTRED, G_LIGHTMAGENTA, G_YELLOW, or G_WHITE. If the palette has been re-defined, give the number of your palette-entry.

Range:

0 .. g_get_palettesize()-1

Default:

G_BLACK

g_get_foreground

int g_get_foreground(void)

Description:

Return the current foreground color.

g_set_background

void g_set_background(int color)

Description:

Set the background color if color is available.

Inputs:

color - The background color. G_BLACK, G_BLUE, G_GREEN, G_CYAN, G_RED, G_MAGENTA, G_BROWN, G_LIGHTGRAY, G_DARKGRAY, G_LIGHTBLUE, G_LIGHTGREEN, G_LIGHTCYAN, G_LIGHTRED, G_LIGHTMAGENTA, G_YELLOW, or G_WHITE.

Range:

0 .. g_get_palettesize()-1

Default:

G_WHITE

g_get_background

int g_get_background(void)

Description:

Return the current background color.

g_set_charsize

void g_set_charsize(float size)

Description:

Scale the default fontsize.(See g_set_font())

Inputs:

size - A scaling factor to scale the default fontsize, e.g. 0.75

Default:

1.0

g_get_charsize

float g_get_charsize(void)

Description:

Return the current charsize scale factor.

g_set_font

void g_set_font(int font, int scaling)

Description:

Set the current font and the font scaling policy. Font changes are not supported for G_HPGL when the G_WIN_PCL5 flag is not set. The font has a default point size of G_FONTSIZE when scaling is G_ABSOLUTE_FONTSCALING. (Point size is in pixels on the screen and in 1/72 inch units for PostScript and HPGL). Otherwise, when scaling is G_RELATIVE_FONTSCALING, the default font size is relative to the height of the window (= window height/ G_FONTSIZE_SCALING) and changes when the window is resized. The default fontsize can be modified with g_set_charsize(). An absolute font size prevents ugly bitmap scaling in X-Windows on some servers, and gives always the same character size on PostScript output. However, with a relative font size Screen and PostScript output match more closely. Note that the character width is always proportional to the character height, and never to the width of the window.

Inputs:

font - One of the following fonts: G_FONT_TIMES, G_FONT_TIMES_ITALIC, G_FONT_TIMES_BOLD, G_FONT_TIMES_BOLD_ITALIC, G_FONT_HELVETICA, G_FONT_HELVETICA_ITALIC, G_FONT_HELVETICA_BOLD, G_FONT_HELVETICA_BOLD_ITALIC, G_FONT_COURIER, G_FONT_COURIER_ITALIC, G_FONT_COURIER_BOLD, G_FONT_COURIER_BOLD_ITALIC, G_FONT_SYMBOL

Default:

G_FONT_HELVETICA

Inputs:

scaling - Set font scaling to absolute or relative:
G_ABSOLUTE_FONTSCALING, G_RELATIVE_FONTSCALING.

Default:

G_ABSOLUTE_FONTSCALING

g_get_font

void g_get_font(int *font, int *scaling)

Description:

Get the current font and the font scaling policy.

Outputs:

font - The current font.

scaling - The current font scaling policy.


g_get_fontheight

float g_get_fontheight(int win_id)

Description:

Get the current font height, relative to the window win_id.

Inputs:

win_id - The the window identifier ID.

Returns:

The height of the current font / the height of the window win_id.

g_set_textdirection

void g_set_textdirection(int direction)

Description:

Sets the text direction. Tries to rotate the text 90 degrees anti clockwise. X-Windows can not do this, text is drawn from top to bottom instead. Patch for now: To make X-Windows do real text rotations use g_set_motif_realtextrotation(TRUE). This function uses bitmap rotation and is sloooooow.

Inputs:

direction - The text direction. 90 = rotate, 0 = normal (left to right)

Default:

0

g_get_textdirection

int g_get_textdirection(void)

Returns:

The rotatetext flag. 90 = on , 0 = off.