- Overview
- Files
- Related Pages
- Modules

Functions
Sprites

## Functions
TANVASTOUCH_API int | tanvastouch_add_sprite (tanvastouch_ctx *ctx, tanvastouch_resource_id view_id, tanvastouch_resource_id sprite_id)
TANVASTOUCH_API int | tanvastouch_remove_sprite (tanvastouch_ctx *ctx, tanvastouch_resource_id view_id, tanvastouch_resource_id sprite_id)
TANVASTOUCH_API int | tanvastouch_contains_sprite (tanvastouch_ctx *ctx, tanvastouch_resource_id view_id, tanvastouch_resource_id sprite_id, bool *p_contains)
TANVASTOUCH_API int | tanvastouch_get_sprite_count (tanvastouch_ctx *ctx, tanvastouch_resource_id view_id, int *p_count)
TANVASTOUCH_API int | tanvastouch_create_sprite (tanvastouch_ctx *ctx, tanvastouch_resource_id *p_sprite_id)
TANVASTOUCH_API int | tanvastouch_destroy_sprite (tanvastouch_ctx *ctx, tanvastouch_resource_id sprite_id)
TANVASTOUCH_API int | tanvastouch_set_sprite_enabled (tanvastouch_ctx *ctx, tanvastouch_resource_id sprite_id, bool enabled)
TANVASTOUCH_API int | tanvastouch_is_sprite_enabled (tanvastouch_ctx *ctx, tanvastouch_resource_id sprite_id, bool *p_enabled)
TANVASTOUCH_API int | tanvastouch_set_sprite_position (tanvastouch_ctx *ctx, tanvastouch_resource_id sprite_id, float x, float y)
TANVASTOUCH_API int | tanvastouch_get_sprite_position (tanvastouch_ctx *ctx, tanvastouch_resource_id sprite_id, float *p_x, float *p_y)
TANVASTOUCH_API int | tanvastouch_set_sprite_size (tanvastouch_ctx *ctx, tanvastouch_resource_id sprite_id, int width, int height)
TANVASTOUCH_API int | tanvastouch_get_sprite_size (tanvastouch_ctx *ctx, tanvastouch_resource_id sprite_id, int *p_width, int *p_height)
TANVASTOUCH_API int | tanvastouch_set_sprite_rotation (tanvastouch_ctx *ctx, tanvastouch_resource_id sprite_id, float theta, float pivot_x, float pivot_y)
TANVASTOUCH_API int | tanvastouch_get_sprite_theta (tanvastouch_ctx *ctx, tanvastouch_resource_id sprite_id, float *p_theta)
TANVASTOUCH_API int | tanvastouch_get_sprite_pivot (tanvastouch_ctx *ctx, tanvastouch_resource_id sprite_id, float *p_pivot_x, float *p_pivot_y)
TANVASTOUCH_API int | tanvastouch_set_sprite_material (tanvastouch_ctx *ctx, tanvastouch_resource_id sprite_id, tanvastouch_resource_id material_id)
TANVASTOUCH_API int | tanvastouch_get_sprite_material (tanvastouch_ctx *ctx, tanvastouch_resource_id sprite_id, tanvastouch_resource_id *p_material_id)
TANVASTOUCH_API int | tanvastouch_remove_sprite_material (tanvastouch_ctx *ctx, tanvastouch_resource_id sprite_id)
TANVASTOUCH_API int | tanvastouch_set_sprite_depth (tanvastouch_ctx *ctx, tanvastouch_resource_id sprite_id, float depth)
TANVASTOUCH_API int | tanvastouch_get_sprite_depth (tanvastouch_ctx *ctx, tanvastouch_resource_id sprite_id, float *p_depth)

## Detailed Description

## Function Documentation

## ◆ tanvastouch_add_sprite()

TANVASTOUCH_API int tanvastouch_add_sprite | ( | tanvastouch_ctx * | ctx,
|  | tanvastouch_resource_id | view_id,
|  | tanvastouch_resource_id | sprite_id
| ) |  |

Add a sprite to a view.

The sprite is positioned in its view's coordinate system; (0, 0) is the top-left corner of its parent view.

The view does not take ownership of the sprite: if the view is destroyed, the sprite will continue to exist.

See also
  Haptic resources are positioned using the window system's rules

Parameters

  ctx | The context to use.
  view_id | The view to modify.
  sprite_id | The sprite to add to the view.

Returns
  Resource-related API call return value

## ◆ tanvastouch_contains_sprite()

TANVASTOUCH_API int tanvastouch_contains_sprite | ( | tanvastouch_ctx * | ctx,
|  | tanvastouch_resource_id | view_id,
|  | tanvastouch_resource_id | sprite_id,
|  | bool * | p_contains
| ) |  |

Get whether a sprite is contained in a view.

See also
  Out-parameters are only written on success

Parameters

  ctx | The context to use.
  view_id | The view to query.
  sprite_id | The sprite to query.
  p_contains | Is-contained storage.

Returns
  Resource-related API call return value

## ◆ tanvastouch_create_sprite()

TANVASTOUCH_API int tanvastouch_create_sprite | ( | tanvastouch_ctx * | ctx,
|  | tanvastouch_resource_id * | p_sprite_id
| ) |  |

Create a sprite.

A sprite starts at (0, 0) with size (0, 0) and a rotation of zero radians, with the pivot point at (0, 0). A sprite does not have an initial view.

The sprite is positioned in its view's coordinate system; (0, 0) is the top-left corner of its parent view.

See also
  Haptic resources are positioned using the window system's rules
  Out-parameters are only written on success

Parameters

  ctx | The context to use.
  p_sprite_id | Sprite ID storage.

Returns
  Resource-related API call return value

## ◆ tanvastouch_destroy_sprite()

TANVASTOUCH_API int tanvastouch_destroy_sprite | ( | tanvastouch_ctx * | ctx,
|  | tanvastouch_resource_id | sprite_id
| ) |  |

Destroy a sprite.

The sprite ID is not modified by this function. It is safe to keep the sprite ID around, but any modifications or queries done with that ID will return TANVASTOUCH_ERROR_RESOURCE_UNKNOWN.

Destroying sprites does not destroy any materials or textures contained in that sprite.

Parameters

  ctx | The context to use.
  sprite_id | The sprite to destroy.

Returns
  Resource-related API call return value

## ◆ tanvastouch_get_sprite_count()

TANVASTOUCH_API int tanvastouch_get_sprite_count | ( | tanvastouch_ctx * | ctx,
|  | tanvastouch_resource_id | view_id,
|  | int * | p_count
| ) |  |

Get the number of sprites in a view.

Parameters

  ctx | The context to use.
  view_id | The view to query.
  p_count | Storage for the result.

Returns
  Resource-related API call return value

Since
  4.1.0

## ◆ tanvastouch_get_sprite_depth()

TANVASTOUCH_API int tanvastouch_get_sprite_depth | ( | tanvastouch_ctx * | ctx,
|  | tanvastouch_resource_id | sprite_id,
|  | float * | p_depth
| ) |  |

Get a sprite's depth.

See also
  Out-parameters are only written on success

Parameters

  ctx | The context to use.
  sprite_id | The sprite to query.
  p_depth | Depth storage.

Returns
  Resource-related API call return value

## ◆ tanvastouch_get_sprite_material()

TANVASTOUCH_API int tanvastouch_get_sprite_material | ( | tanvastouch_ctx * | ctx,
|  | tanvastouch_resource_id | sprite_id,
|  | tanvastouch_resource_id * | p_material_id
| ) |  |

Get the material ID set for the sprite.

Parameters

  ctx | The context to use.
  sprite_id | The sprite to query.
  p_material_id | On success, will contain the material ID set for the sprite, or TANVASTOUCH_INVALID_RESOURCE_ID if the sprite does not have a material set.

Since
  4.1.0

## ◆ tanvastouch_get_sprite_pivot()

TANVASTOUCH_API int tanvastouch_get_sprite_pivot | ( | tanvastouch_ctx * | ctx,
|  | tanvastouch_resource_id | sprite_id,
|  | float * | p_pivot_x,
|  | float * | p_pivot_y
| ) |  |

Return a sprite's pivot point.

The pivot point is specified in the coordinate system of the sprite's view.

See also
  Haptic resources are positioned using the window system's rules

Parameters

  ctx | The context to use.
  sprite_id | The sprite to query.
  p_pivot_x | X-position storage.
  p_pivot_y | Y-position storage.

Returns
  Resource-related API call return value

## ◆ tanvastouch_get_sprite_position()

TANVASTOUCH_API int tanvastouch_get_sprite_position | ( | tanvastouch_ctx * | ctx,
|  | tanvastouch_resource_id | sprite_id,
|  | float * | p_x,
|  | float * | p_y
| ) |  |

Get the sprite's position.

See also
  Haptic resources are positioned using the window system's rules
  Out-parameters are only written on success

Parameters

  ctx | The context to use.
  sprite_id | The sprite to query.
  p_x | X-position storage.
  p_y | Y-position storage.

Returns
  Resource-related API call return value

## ◆ tanvastouch_get_sprite_size()

TANVASTOUCH_API int tanvastouch_get_sprite_size | ( | tanvastouch_ctx * | ctx,
|  | tanvastouch_resource_id | sprite_id,
|  | int * | p_width,
|  | int * | p_height
| ) |  |

Get a sprite's size.

See also
  Haptic resources are positioned using the window system's rules
  Out-parameters are only written on success

Parameters

  ctx | The context to use.
  sprite_id | The sprite to query.
  p_width | Width storage.
  p_height | Height storage.

Returns
  Resource-related API call return value

## ◆ tanvastouch_get_sprite_theta()

TANVASTOUCH_API int tanvastouch_get_sprite_theta | ( | tanvastouch_ctx * | ctx,
|  | tanvastouch_resource_id | sprite_id,
|  | float * | p_theta
| ) |  |

Return a sprite's angle.

The rotation angle is specified in radians; rotation proceeds clockwise.

Parameters

  ctx | The context to use.
  sprite_id | The sprite to modify.
  p_theta | Angle storage.

Returns
  Resource-related API call return value

## ◆ tanvastouch_is_sprite_enabled()

TANVASTOUCH_API int tanvastouch_is_sprite_enabled | ( | tanvastouch_ctx * | ctx,
|  | tanvastouch_resource_id | sprite_id,
|  | bool * | p_enabled
| ) |  |

Get whether a sprite is enabled.

See also
  Out-parameters are only written on success

Parameters

  ctx | The context to use.
  sprite_id | The sprite to query.
  p_enabled | Is-enabled storage.

Returns
  Resource-related API call return value

## ◆ tanvastouch_remove_sprite()

TANVASTOUCH_API int tanvastouch_remove_sprite | ( | tanvastouch_ctx * | ctx,
|  | tanvastouch_resource_id | view_id,
|  | tanvastouch_resource_id | sprite_id
| ) |  |

Remove a sprite from a view.

Parameters

  ctx | The context to use.
  view_id | The view to modify.
  sprite_id | The sprite to remove from the view.

Returns
  Resource-related API call return value

## ◆ tanvastouch_remove_sprite_material()

TANVASTOUCH_API int tanvastouch_remove_sprite_material | ( | tanvastouch_ctx * | ctx,
|  | tanvastouch_resource_id | sprite_id
| ) |  |

Clears a sprite's material.

If successful, subsequent calls to tanvastouch_get_sprite_material on the affected sprite will return TANVASTOUCH_INVALID_RESOURCE_ID.

Parameters

  ctx | The context to use.
  sprite_id | The sprite to modify.

Returns
  Resource-related API call return value

## ◆ tanvastouch_set_sprite_depth()

TANVASTOUCH_API int tanvastouch_set_sprite_depth | ( | tanvastouch_ctx * | ctx,
|  | tanvastouch_resource_id | sprite_id,
|  | float | depth
| ) |  |

Set a sprite's depth.

Depth zero is the closest to the screen; increasing depth means going deeper into the screen.

Parameters

  ctx | The context to use.
  sprite_id | The sprite to modify.
  depth | Desired depth.

Returns
  Resource-related API call return value

## ◆ tanvastouch_set_sprite_enabled()

TANVASTOUCH_API int tanvastouch_set_sprite_enabled | ( | tanvastouch_ctx * | ctx,
|  | tanvastouch_resource_id | sprite_id,
|  | bool | enabled
| ) |  |

Set whether the given sprite will participate in haptic rendering.

See also
  Destructors do not clear resource IDs

Parameters

  ctx | The context to use.
  sprite_id | The sprite to modify.
  enabled | True to enable, false to disable.

Returns
  Resource-related API call return value

## ◆ tanvastouch_set_sprite_material()

TANVASTOUCH_API int tanvastouch_set_sprite_material | ( | tanvastouch_ctx * | ctx,
|  | tanvastouch_resource_id | sprite_id,
|  | tanvastouch_resource_id | material_id
| ) |  |

Set a sprite's material.

Parameters

  ctx | The context to use.
  sprite_id | The sprite to modify.
  material_id | The material to assign.

Returns
  Resource-related API call return value

## ◆ tanvastouch_set_sprite_position()

TANVASTOUCH_API int tanvastouch_set_sprite_position | ( | tanvastouch_ctx * | ctx,
|  | tanvastouch_resource_id | sprite_id,
|  | float | x,
|  | float | y
| ) |  |

Set a sprite's position.

The origin of the sprite's coordinate system is the top-left corner of its parent view. The origin of the sprite is its top-left corner.

See also
  Haptic resources are positioned using the window system's rules

Parameters

  ctx | The context to use.
  sprite_id | The sprite to modify.
  x | X position.
  y | Y position.

Returns
  Resource-related API call return value

## ◆ tanvastouch_set_sprite_rotation()

TANVASTOUCH_API int tanvastouch_set_sprite_rotation | ( | tanvastouch_ctx * | ctx,
|  | tanvastouch_resource_id | sprite_id,
|  | float | theta,
|  | float | pivot_x,
|  | float | pivot_y
| ) |  |

Set a sprite's rotation and pivot point.

The rotation angle is specified in radians; rotation proceeds clockwise. The pivot point is specified in the coordinate system of the sprite's view.

See also
  Haptic resources are positioned using the window system's rules

Parameters

  ctx | The context to use.
  sprite_id | The sprite to modify.
  theta | Sprite angle.
  pivot_x | Pivot point X.
  pivot_y | Pivot point Y.

Returns
  Resource-related API call return value

## ◆ tanvastouch_set_sprite_size()

TANVASTOUCH_API int tanvastouch_set_sprite_size | ( | tanvastouch_ctx * | ctx,
|  | tanvastouch_resource_id | sprite_id,
|  | int | width,
|  | int | height
| ) |  |

Set a sprite's size.

See also
  Haptic resources are positioned using the window system's rules

Parameters

  ctx | The context to use.
  sprite_id | The sprite to modify.
  width | Desired width.
  height | Desired height.

Returns
  Resource-related API call return value