Documentation from draw.h

ROV

Introduction

[top]

ROV - Easy applications from C

Copyright - © Jason Tribbeck / 7th ARM 1994-2001

Contributing authors - Jason Tribbeck

File - draw.h

Type - subsystem

Description

spr_transtab (type definition)

[top]

Structure for a sprite translation table.

typedef struct {
  int xm;
  int ym;
  int xd;
  int yd;
  int xt;
  int yt;
} spr_transtab;

draw_plot

[top]

Interface to OS_Plot, but uses canvas' origin instead of screen origin.

Parameters:

 - int code - the plot code.
 - int x - the (canvas) x coordinate.
 - int y - the (canvas) y coordinate.

void draw_plot(int code,
	       int x,
	       int y);

draw_move

[top]

Perform a MOVE to canvas location

Parameters:

 - x - the (canvas) x coordinate.
 - y - the (canvas) y coordinate.

#define	draw_move(x,y) draw_plot(4,x,y)

draw_line

[top]

Perform a DRAW to canvas location.

Parameters:

 - x - the (canvas) x coordinate.
 - y - the (canvas) y coordinate.

#define	draw_line(x,y) draw_plot(5,x,y)

draw_moveto

[top]

Perform a relative MOVE

Parameters:

 - x - the x offset.
 - y - the y offset.

#define	draw_moveto(x,y) draw_plot(0,x,y)

draw_lineto

[top]

Perform a relative DRAW

Parameters:

 - x - the x offset.
 - y - the y offset.

#define	draw_lineto(x,y) draw_plot(1,x,y)

draw_circle

[top]

Draw a circle

Parameters:

 - x - the (canvas) x coordinate of the centre.
 - y - the (canvas) y coordinate of the centre.
 - z - the radius.

#define	draw_circle(x,y,z) \
		do { draw_plot(4, x, y); \
		draw_plot(145, 0, z); } while (0)

draw_circlefill (definition)

[top]

Draw a filled circle

Parameters:

 - x - the (canvas) x coordinate of the centre.
 - y - the (canvas) y coordinate of the centre.
 - z - the radius.

#define draw_circlefill(x,y,z) \
		do { draw_plot(4, x, y); \
	        draw_plot(153, 0, z); } while (0)

draw_rectangle (definition)

[top]

Draw a rectangle

Parameters:

 - x - the (canvas) x coordinate.
 - y - the (canvas) y coordinate.
 - j - the width.
 - k - the height.

#define draw_rectangle(x,y,j,k) \
		do { draw_plot(4, x, y); \
		draw_plot(1, j, 0); \
		draw_plot(1, 0, k); \
		draw_plot(1, - (j), 0); \
		draw_plot(1, 0, - (k)); } while(0)

draw_rectanglefill (definition)

[top]

Draw a filled rectangle

Parameters:

 - x - the (canvas) x coordinate.
 - y - the (canvas) y coordinate.
 - j - the width.
 - k - the height.

#define draw_rectanglefill(x,y,j,k) \
		do { draw_plot(4, x, y); \
		draw_plot(97, j, k); } while(0)

sprite_plotsprite

[top]

Plot a sprite

Parameters:

 - void *spr_area - the sprite area.
 - char *spr_name - the sprite name.
 - int x - the (canvas) x coordinate of the left hand side.
 - int y - the (canvas) y coordinate of the bottom.

void sprite_plotsprite(void *spr_area,
		       char *spr_name,
		       int x,
		       int y);

See also: sprite_plotspriten(), sprite_plotspritepn()

sprite_plotspriten

[top]

Plot a sprite without canvas translation.

Parameters:

 - void *spr_area - the sprite area.
 - char *spr_name - the sprite name.
 - int x - the (screen) x coordinate of the left hand side.
 - int y - the (screen) y coordinate of the bottom.

void sprite_plotspriten(void *spr_area,
			char *spr_name,
			int x,
			int y);

See also: sprite_plotsprite()

sprite_plotspritet

[top]

Plot a scaled sprite without canvas translation.

Parameters:

 - void *spr_area - the sprite area.
 - char *spr_name - the sprite name.
 - int x - the (screen) x coordinate of the left hand side.
 - int y - the (screen) y coordinate of the bottom.
 - int xm - the x multiplier.
 - int ym - the y multiplier.
 - int xd - the x divider.
 - int yd - the y divider.
 - spr_transtab *trans - the translation table.

void sprite_plotspritet(void *spr_area,
			char *spr_name,
			int x,
			int y,
			int xm,
			int ym,
			int xd,
			int yd,
			spr_transtab *trans);

See also: spr_transtab, sprite_plotspritept()

sprite_plotspritep

[top]

Plot a sprite

Parameters:

 - void *spr_area - the sprite area.
 - void *spr_ptr - the sprite pointer.
 - int x - the (canvas) x coordinate of the left hand side.
 - int y - the (canvas) y coordinate of the bottom.

void sprite_plotspritep(void *spr_area,
			void *spr_ptr,
			int x,
			int y);

See also: sprite_plotsprite(), sprite_plotspritepn()

sprite_plotspritepn

[top]

Plot a sprite without canvas translation.

Parameters:

 - void *spr_area - the sprite area.
 - void *spr_ptr - the sprite pointer.
 - int x - the (screen) x coordinate of the left hand side.
 - int y - the (screen) y coordinate of the bottom.

void sprite_plotspritepn(void *spr_area,
			 void *spr_ptr,
			 int x,
			 int y);

See also: sprite_plotspriten(), sprite_plotspritep()

sprite_plotspritept

[top]

Plot a scaled sprite without canvas translation.

Parameters:

 - void *spr_area - the sprite area.
 - void *spr_ptr - the sprite pointer.
 - int x - the (screen) x coordinate of the left hand side.
 - int y - the (screen) y coordinate of the bottom.
 - int xm - the x multiplier.
 - int ym - the y multiplier.
 - int xd - the x divider.
 - int yd - the y divider.
 - spr_transtab *trans - the translation table.

void sprite_plotspritept(void *spr_area,
			 void *spr_ptr,
			 int x,
			 int y,
			 int xm,
			 int ym,
			 int xd,
			 int yd,
			 spr_transtab *trans);

See also: draw_plotsprite(), draw_plotsprite56(), spr_transtab, sprite_plotrawp(), sprite_plotspritet()

sprite_loadsprite

[top]

Load a sprite file into memory, allocating memory for it.

Parameters:

 - char *file_name - the name of the file.

Returns:

 -  the pointer to the sprite area, or NULL if unable to load the file (memory failure, or file not found).

void *sprite_loadsprite(char *file_name);

sprite_spriteexists

[top]

Check to see if the sprite exists.

Parameters:

 - void *spr_area - the sprite area.
 - char *spr_name - the name of the sprite.

Returns:

 - s zero for sprite does not exist, non-zero for sprite exists.

int sprite_spriteexists(void *spr_area,
			char *spr_name);

See also: sprite_address()

sprite_address

[top]

Get the address of a sprite.

Parameters:

 - void *spr_area - the sprite area to search.
 - char *spr_name - the name of the sprite.

Returns:

 -  the pointer to the sprite, or NULL if not found.

void *sprite_address(void *spr_area,
		     char *spr_name);

draw_colours (external variable)

[top]

The number of colours.

extern unsigned int draw_colours; 			/* Maximum number of colours		 */

draw_scalex (external variable)

[top]

The current X scale.

extern int draw_scalex;

draw_scaley (external variable)

[top]

The current Y scale.

extern int draw_scaley;

draw_shiftx (external variable)

[top]

The current X shift (ie. to convert from OS pixels to screen units)

extern int draw_shiftx;

draw_shifty (external variable)

[top]

The current Y shift (ie. to convert from OS pixels to screen units)

extern int draw_shifty;

draw_maxx (external variable)

[top]

The maximum X coordinate.

extern int draw_maxx;

draw_maxy (external variable)

[top]

The maximum Y coordinate.

extern int draw_maxy;

draw_mode (external variable)

[top]

The current mode (or mode selector).

extern int draw_mode;

draw_bpp (external variable)

[top]

The current log base2 of bits per pixel.

extern int draw_bpp;

draw_capline (type definition)

[top]

Structure of a draw capline

Fields:

 - char join - the join type.
 - char lead_cap - the lead cap type.
 - char tail_cap - the tail cap type.
 - char reserved - do not use; reserved.
 - int mitre_limit - the limit of the mitre length for mitre joins.
 - short int lead_capwidth - the width of the lead cap.
 - short int lead_caplength - the length of the lead cap.
 - short int tail_capwidth - the width of the tail cap.
 - short int tail_caplength - the length of the tail cap.

typedef struct {
  char join;
  char lead_cap;
  char tail_cap;
  char reserved;
  int mitre_limit;
  short int lead_capwidth;
  short int lead_caplength;
  short int tail_capwidth;
  short int tail_caplength;
} draw_capline;

draw_dash (type definition)

[top]

Structure of a draw dash line

Fields:

 - int start_distance - the distance from the start of the line to the start of the first dash.
 - int entries - the number of items in the dash list.
 - int[1] elements - the dashed elements.

typedef struct {
  int start_distance;
  int entries;
  int elements[1];
} draw_dash;

draw_fill

[top]

Draw a filled segment.

Parameters:

 - void *path - the input path.
 - int style - the fill style.
 - int *trans - the transformation matrix (or NULL for identity).
 - int flat - the flatness.

void draw_fill(void *path,
	       int style,
	       int *trans,
	       int flat);

draw_stroke

[top]

Draw a stroked segment.

Parameters:

 - void *path - the input path.
 - int style - the fill style.
 - int *trans - the transformation matrix (or NULL for identity).
 - int flat - the flatness.
 - int thick - the thickness.
 - draw_capline *cap - the line cap style.
 - draw_dash *dash - the line dash style.

void draw_stroke(void *path,
		 int style,
		 int *trans,
		 int flat,
		 int thick,
		 draw_capline *cap,
		 draw_dash *dash);

See also: draw_capline, draw_dash

draw_setcolour

[top]

Set the current graphics colour.

Parameters:

 - int col - the colour to use (0xBBGGRR00)

void draw_setcolour(int col);

draw_setfontcolour

[top]

Set the font colour.

Parameters:

 - int handle - the font handle.
 - int back - the background colour.
 - int fore - the foreground colour.

Note - Unlike font_setcolour(), this uses ColourTrans to set the colours correctly.

void draw_setfontcolour(int handle,
			int back,
			int fore);

See also: font.h

draw_findfont

[top]

Find the font handle

Parameters:

 - char *name - the font name.
 - int w - the width in points.
 - int h - the height in points.

Returns:

 -  the font handle.

Note - This is identical to font_find().

int draw_findfont(char *name,
		  int w,
		  int h);

draw_losefont

[top]

Lose a font handle.

Parameters:

 - int handle - the handle to lose.

Note - This is identical to font_lose();

void draw_losefont(int handle);

draw_paintfont

[top]

Draw with the given font/coordinates.

Parameters:

 - int handle - the handle.
 - char *str - the string to plot.
 - int x - the (screen) x coordinate.
 - int y - the (screen) y coordinate.

Note - If you want to draw on a canvas, add __draw_localx and __draw_localy to the coordinates.

void draw_paintfont(int handle,
		    char *str,
		    int x,
		    int y);

draw_paintfontx

[top]

Draw with the given font/coordinates.

Parameters:

 - int handle - the handle.
 - char *str - the string to plot.
 - int x - the (millipoint) x coordinate.
 - int y - the (millipoint) y coordinate.
 - int *trans - the pointer to the transformation matrix
 - int flags - the icon flags.

Note - If you want to draw on a canvas, add __draw_localx and __draw_localy to the coordinates.

void draw_paintfontx(int handle,
		     char *str,
		     int x,
		     int y,
		     int *trans,
		     int flags);

draw_gcol

[top]

Sets the colour to the WIMP colour.

Parameters:

 - int col - bits 0 to 3 are the WIMP colour (0-15) to use, bits 4 to 7 are the GCOL action.

void draw_gcol(int col);

draw_getspriteinfo

[top]

Get the information on a sprite pointer.

Parameters:

 - void *spr_ptr - the pointer to the sprite.
 - int *xpix - the pointer to the variable to hold the width in pixels.
 - int *ypix - the pointer to the variable to hold the height in pixels.
 - int *mode - the pointer to the variable to hold the sprite mode.

void draw_getspriteinfo(void *spr_ptr,
			int *xpix,
			int *ypix,
			int *mode);

draw_getnamedspriteinfo

[top]

Get the information on a namedsprite.

Parameters:

 - void *spr_area - the pointer to the sprite area.
 - char *spr_name - the pointer to the sprite name.
 - int *xpix - the pointer to the variable to hold the width in pixels.
 - int *ypix - the pointer to the variable to hold the height in pixels.
 - int *mode - the pointer to the variable to hold the sprite mode.
 - int *mask - the pointer to the variable to hold the sprite mask state.

void draw_getnamedspriteinfo(void *spr_area,
			     char *spr_name,
			     int *xpix,
			     int *ypix,
			     int *mode,
			     int *mask);

draw_getmodevar

[top]

Get the mode variable.

Parameters:

 - int mode - the mode to use (-1 for current).
 - int var_num - the variable number to get.

Returns:

 -  the value of the mode variable.

int draw_getmodevar(int mode,
		    int var_num);

sprite_getscalingp

[top]

Get the pointed sprite's translation tables.

Parameters:

 - void *spr_ptr - the pointer to the sprite.
 - int *sfactor - the pointer to the scaling factor buffer.
 - char *ctrans - the pointer to the colour translation table buffer.

void sprite_getscalingp(void *spr_ptr,
			int *sfactor,
			char *ctrans);

sprite_plotrawp

[top]

Plot a sprite with scaling and colour translation.

Parameters:

 - void *spr_ptr - the sprite pointer.
 - int x - the (screen) x coordinate.
 - int y - the (screen) y coordinate.
 - int *sfactor - the pointer to the scaling factor buffer.
 - char *ctrans - the pointer to the colour translation table buffer.

void sprite_plotrawp(void *spr_ptr,
		     int x,
		     int y,
		     int *sfactor,
		     char *ctrans);

See also: draw_plotsprite(), draw_plotsprite56()

draw_origin

[top]

Set the origin.

Parameters:

 - int x - the (screen) x coordinate.
 - int y - the (screen) y coordinate.

void draw_origin(int x,
		 int y);

draw_ecforigin

[top]

Set the ECF origin.

Parameters:

 - int x - the (screen) x coordinate.
 - int y - the (screen) y coordinate.

void draw_ecforigin(int x,
		    int y);

draw_ploticon

[top]

Plot an icon.

Parameters:

 - int x0 - the left hand coordinate.
 - int y0 - the bottom coordinate.
 - int x1 - the right hand coordinate.
 - int y1 - the top coordinate.
 - int flags - the icon flags.
 - icon_data *data - the pointer to the icon data buffer.

Note - The coordinates are either screen or canvas, depending on context - if the icon is being plotted while in the middle of a canvas redraw or update, then they are canvas coordinates. Otherwise, they are screen coordinates. Note that screen coordinates are only recognised by certain OS versions.

void draw_ploticon(int x0,
		   int y0,
		   int x1,
		   int y1,
		   int flags,
		   icon_data *data);

See also: icons.h

draw_setmode

[top]

Set the screen to a numerical mode.

Parameters:

 - int mode - the mode number.

Note - This is deprecated, as it does not support mode strings.

Note - Changing modes should not be done anyway.

void draw_setmode(int mode);

draw_redrawscreen

[top]

Redraw the whole screen.

void draw_redrawscreen(void);

draw_mode0

[top]

Sets the screen mode to 0 (very low bandwidth).

void draw_mode0(void);

draw_plotsprite

[top]

Plot a sprite.

Parameters:

 - void *spr_ptr - the pointer to the sprite.
 - int style - the plot style.
 - int x - the (screen) x coordinate.
 - int y - the (screen) y coordinate.
 - int *sfactor - the scaling factor buffer.
 - char *ctrans - the colour translation buffer.

void draw_plotsprite(void *spr_ptr,
		     int style,
		     int x,
		     int y,
		     int *sfactor,
		     char *ctrans);

See also: draw_plotsprite56()

draw_plotsprite56

[top]

Plot a sprite using transformation matrix.

Parameters:

 - void *spr_ptr - the pointer to the sprite.
 - int style - the plot style.
 - int *strans - the scaling transformation matrix buffer.
 - char *ctrans - the colour translation buffer.

void draw_plotsprite56(void *spr_ptr,
		       int style,
		       int *strans,
		       char *ctrans);

See also: draw_plotsprite()

draw_charscaled

[top]

Draw a scaled character on the screen.

Parameters:

 - char chr - the character to plot.
 - int x - the (screen) x coordinate.
 - int y - the (screen) y coordinate.
 - int *sfactor - the scaling factors buffer.

void draw_charscaled(char chr,
		     int x,
		     int y,
		     int *sfactor);

draw_setcharsize

[top]

Set the screen character size.

Parameters:

 - int w - the width
 - int h - the height.

void draw_setcharsize(int w,
		      int h);

draw_pchar

[top]

Raw print character.

Parameters:

 - char chr - the character to print.

void draw_pchar(char chr);

WIMP colours

[top]
#define COLOUR_WHITE      (0)
#define COLOUR_GREY1	  (1)
#define COLOUR_GREY2	  (2)
#define COLOUR_GREY3	  (3)
#define COLOUR_GREY4	  (4)
#define COLOUR_GREY5	  (5)
#define COLOUR_GREY6	  (6)
#define COLOUR_BLACK	  (7)
#define COLOUR_DARKBLUE	  (8)
#define COLOUR_YELLOW	  (9)
#define COLOUR_LIGHTGREEN (10)
#define COLOUR_RED	  (11)
#define COLOUR_CREAM	  (12)
#define COLOUR_DARKGREEN  (13)
#define COLOUR_ORANGE	  (14)
#define COLOUR_LIGHTBLUE  (15)

Generated Mon Feb 11 22:18:38 2002