Subtexture

Typedefs

typedef struct binocle_subtexture binocle_subtexture

A subtexture is a slice of a texture. Generally used for sprite sheets.

Functions

binocle_subtexture binocle_subtexture_with_texture(struct sg_image *texture, float x, float y, float width, float height)

Creates a subtexture given a texture, coordinates and size.

Parameters
  • texture – the texture

  • x – the x position of the subtexture

  • y – the y position of the subtexture

  • width – the width of the subtexture

  • height – the height of the subtexture

Returns

the subtexture

binocle_subtexture binocle_subtexture_with_subtexture(binocle_subtexture *subtexture, float x, float y, float width, float height)

Creates a subtexture given a subtexture, coordinates and size.

Parameters
  • subtexture – the subtexture to get the texture from

  • x – the x position of the subtexture

  • y – the y position of the subtexture

  • width – the width of the subtexture

  • height – the height of the subtexture

Returns

the subtexture

uint64_t binocle_subtexture_get_x(binocle_subtexture subtexture)

Gets the X coordinate of a subtexture within its texture.

Parameters

subtexture – the subtexture

Returns

the X position

uint64_t binocle_subtexture_get_y(binocle_subtexture subtexture)

Gets the Y coordinate of a subtexture within its texture.

Parameters

subtexture – the subtexture

Returns

the Y position

uint64_t binocle_subtexture_get_width(binocle_subtexture *subtexture)

Gets the width of a subtexture.

Parameters

subtexture – the subtexture

Returns

the width of the subtexture

uint64_t binocle_subtexture_get_height(binocle_subtexture *subtexture)

Gets the height of a subtexture.

Parameters

subtexture – the subtexture

Returns

the height of the subtexture

kmVec2 binocle_subtexture_get_size(binocle_subtexture *subtexture)

Gets the size of a subtexture.

Parameters

subtexture – the subtexture

Returns

the size of the subtexture

kmVec2 binocle_subtexture_get_center(binocle_subtexture *subtexture)

Gets the coordinates of the center of the subtexture.

Parameters

subtexture – the subtexture

Returns

the coordinates of the center of the subtexture

kmAABB2 binocle_subtexture_get_frame(binocle_subtexture subtexture, uint64_t index, uint64_t frame_width, uint64_t frame_height)

Gets a frame position from a subtexture.

Parameters
  • subtexture – the subtexture

  • index – the index of the frame

  • frame_width – the width of the frame

  • frame_height – the height of the frame

Returns

the position of the frame

kmAABB2 binocle_subtexture_get_absolute_clip_rect(binocle_subtexture subtexture, kmAABB2 relative_clip_rect)

Gets the absolute clip rectangle of a subtexture given a relative clip rectangle.

Parameters
  • subtexture – the subtexture

  • relative_clip_rect – the relative clip rectangle

Returns

the absolute clip rectangle

struct binocle_subtexture
#include <binocle_subtexture.h>

A subtexture is a slice of a texture. Generally used for sprite sheets.

Public Members

struct sg_image *texture
kmAABB2 rect
char name[1024]