---
name: "sprite"
section: "3caca"
platform: "linux"
package: "libcaca-dev"
version: "0.9-4"
release: "Debian 3.1 (Sarge)"
platforms: ["linux"]
url: "https://new.carta.tech/sprite"
---

# sprite(3caca)

## NAME

Sprite handling -

### Functions

caca\_sprite \* **caca\_load\_sprite** (char const \*)\
 *Allocate a sprite loaded from a file.*  int **caca\_get\_sprite\_frames** (struct caca\_sprite const \*)\
 *Return the number of frames in a sprite.*  int **caca\_get\_sprite\_width** (struct caca\_sprite const \*, int)\
 *Return the width of a sprite.*  int **caca\_get\_sprite\_height** (struct caca\_sprite const \*, int)\
 *Return the height of a sprite.*  int **caca\_get\_sprite\_dx** (struct caca\_sprite const \*, int)\
 *Return the X coordinate of a sprite's handle.*  int **caca\_get\_sprite\_dy** (struct caca\_sprite const \*, int)\
 *Return the Y coordinate of a sprite's handle.*  void **caca\_draw\_sprite** (int, int, struct caca\_sprite const \*, int)\
 *Draw a sprite's specific frame at the given coordinates. If the frame does not exist, nothing is displayed.*  void **caca\_free\_sprite** (struct caca\_sprite \*)\
 *Free the memory associated with a sprite.*

## Detailed Description

These functions provide high level routines for sprite loading, animation and rendering.

## Function Documentation

### void caca\_draw\_sprite (int x, int y, struct caca\_sprite const \* sprite, int f)

**Parameters:**

*x* The X coordinate. \
 *y* The Y coordinate. \
 *sprite* The sprite. \
 *f* The frame index.

**Returns:**

void

### void caca\_free\_sprite (struct caca\_sprite \* sprite)

**Parameters:**

*sprite* The sprite to be freed.

**Returns:**

void

### int caca\_get\_sprite\_dx (struct caca\_sprite const \* sprite, int f)

**Parameters:**

*sprite* The sprite. \
 *f* The frame index.

**Returns:**

The X coordinate of the given frame's handle.

### int caca\_get\_sprite\_dy (struct caca\_sprite const \* sprite, int f)

**Parameters:**

*sprite* The sprite. \
 *f* The frame index.

**Returns:**

The Y coordinate of the given frame's handle.

### int caca\_get\_sprite\_frames (struct caca\_sprite const \* sprite)

**Parameters:**

*sprite* The sprite.

**Returns:**

The number of frames.

### int caca\_get\_sprite\_height (struct caca\_sprite const \* sprite, int f)

**Parameters:**

*sprite* The sprite. \
 *f* The frame index.

**Returns:**

The height of the given frame of the sprite.

### int caca\_get\_sprite\_width (struct caca\_sprite const \* sprite, int f)

**Parameters:**

*sprite* The sprite. \
 *f* The frame index.

**Returns:**

The width of the given frame of the sprite.

### struct caca\_sprite\* caca\_load\_sprite (char const \* file)

**Parameters:**

*file* The filename.

**Returns:**

The sprite, or NULL if an error occured.
