Agar Logo

Agar 1.7 Manual

(Printable Version)


#include <agar/core.h>
#include <agar/gui.h>
#include <agar/map/rg.h>


The RG_Tile structure describes a graphical surface generated from a set of instructions or elements.

Note: Unless you need to generate or manipulate tiles programmatically, you do not need to use this interface. Libraries such as MAP(3) use this interface to display graphics.

The following types of elements are implemented:
RG_TILE_PIXMAPBlit the given surface (a RG_Pixmap(3) reference) at target coordinates x, y with alpha blending factor alpha.
RG_TILE_SKETCHBlit a rendering of the given vector drawing at x, y, using scale factor scale and alpha blending factor alpha.
RG_TILE_FEATUREGeneric graphical operation. Features may or may not have associated target coordinates. Filters such as Blur are implemented as features. New features are easily implemented. See RG_Feature(3) for more information on the feature framework.

The public members of the RG_Tile structure are as follows:
typedef struct rg_tile {
	char name[RG_TILE_NAME_MAX];    /* User description */
	char clname[RG_TILE_CLASS_MAX]; /* Category (app-specific) */
	AG_Surface *su;                 /* Generated surface */
	int xOrig, yOrig;               /* Origin coordinates */
	enum rg_snap_mode {
		RG_SNAP_NONE,           /* No snapping */
		RG_SNAP_TO_GRID         /* Snap to grid */
	} snap_mode;


RG_Tile * RG_TileNew (RG_Tileset *tileset, const char *name, Uint16 width, Uint16 height, Uint flags)

void RG_TileScale (RG_Tileset *tileset, RG_Tile *tile, Uint16 width, Uint16 height)

void RG_TileGenerate (RG_Tile *tile)

RG_TileElement * RG_TileAddPixmap (RG_Tile *tile, const char *name, RG_Pixmap *pixmap, int x, int y)

RG_TileElement * RG_TileAddSketch (RG_Tile *tile, const char *name, RG_Sketch *sketch, int x, int y)

RG_TileElement * RG_TileAddFeature (RG_Tile *tile, const char *name, RG_FeatureOps *featureOps, int x, int y)

void RG_TileDelPixmap (RG_Tile *tile, RG_Pixmap *pixmap, int destroyFlag)

void RG_TileDelSketch (RG_Tile *tile, RG_Sketch *sketch, int destroyFlag)

void RG_TileDelFeature (RG_Tile *tile, RG_Feature *feature, int destroyFlag)

The RG_TileNew() function allocates, initializes, and attaches a new RG_Tile of width by height pixels. name is a string identifier for the tile (if a tile of the same name exists, a unique name will be generated automatically). Accepted flags include:
RG_TILE_SRCCOLORKEYUse colorkeying with the tile surface.
RG_TILE_SRCALPHAUse alpha blending with the tile surface.

RG_TileScale() resizes the canvas of the tile to width by height pixels. Note that this only resizes the canvas used for rendering the tile, and has no effect on the pixmaps and other features.

The RG_TileGenerate() function updates the surface (the su member of the RG_Tile structure) using the tile instructions.

RG_TileFindElement() searches for a tile element by type and name.

RG_TileAddPixmap() inserts a reference to pixmap at coordinates x, y. RG_TileAddSketch() inserts a reference to sketch at coordinates x, y. RG_TileAddFeature() inserts the feature described by featureOps. For features, the x and y parameters may or may not have any meaning. See RG_Feature(3) for more information on the feature framework.

RG_TileDelFeature(), RG_TileDelPixmap() and RG_TileDelSketch() remove any element that refers to the given pixmap, sketch or feature, respectively. This causes the reference count of the referenced element to be decremented. If destroyFlag is 1, the element is automatically freed is that reference count reaches 0.

SEE ALSO ElectronTubeStore