Stardew Engine
Loading...
Searching...
No Matches
Atlas.h File Reference
#include "IntTypes.h"
#include "HandleDefs.h"
#include <cglm/cglm.h>
#include <stdbool.h>
Include dependency graph for Atlas.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Data Structures

struct  _AtlasSprite
 A sprite stored in the atlas. More...
 
struct  AtlasAnimation
 
struct  FontSize
 
struct  FontAtlasAdditionSpec
 
struct  EndAtlasOptions
 

Macros

#define VECTOR(a)   a*
 
#define MAX_FONT_NAME_SIZE   128
 
#define MAX_FONT_PATH_SIZE   256
 
#define MAX_NUM_FONT_SIZES   32
 

Typedefs

typedef struct DrawContext DrawContext
 
typedef struct _xmlNode xmlNode
 
typedef struct _AtlasSprite AtlasSprite
 A sprite stored in the atlas.
 

Functions

void At_Init ()
 
void At_BeginAtlas ()
 
hSprite At_AddSprite (const char *imgPath, int topLeftXPx, int topRightYPx, int widthPx, int heightPx, const char *name, bool bMinimizeSpace)
 Add a sprite to the atlas, cuts out the pixels for that specific sprite to be nested when At_EndAtlas is called.
 
HFont At_AddFont (const struct FontAtlasAdditionSpec *pFontSpec)
 
hAtlas At_EndAtlas (struct DrawContext *pDC)
 
hAtlas At_EndAtlasEx (struct DrawContext *pDC, struct EndAtlasOptions *pOptions)
 
void At_DestroyAtlas (hAtlas atlas, struct DrawContext *pDC)
 
hSprite At_FindSprite (const char *name, hAtlas atlas)
 
AtlasSpriteAt_GetSprite (hSprite sprite, hAtlas atlas)
 
hTexture At_GetAtlasTexture (hAtlas atlas)
 
float At_PixelsToPts (float val)
 
hAtlas At_LoadAtlas (xmlNode *child0, struct DrawContext *pDC)
 
hAtlas At_LoadAtlasEx (xmlNode *child0, struct DrawContext *pDC, struct EndAtlasOptions *pOptions)
 
hSprite At_TilemapIndexToSprite (hAtlas atlas, TileIndex tileIndex)
 
void At_SerializeAtlas (struct BinarySerializer *pSerializer, hAtlas *atlas, struct DrawContext *pDC)
 
void At_BeginTileset (int beginI)
 
void At_EndTileset (int endI)
 
void At_SetCurrent (hAtlas atlas, DrawContext *pDC)
 
struct AtlasAnimationAt_FindAnim (hAtlas atlas, const char *name)
 
HFont Fo_FindFont (hAtlas hAtlas, const char *fontName, float sizePts)
 
float Fo_CharWidth (hAtlas hAtlas, HFont hFont, char c)
 
float Fo_CharHeight (hAtlas hAtlas, HFont hFont, char c)
 
float Fo_StringWidth (hAtlas hAtlas, HFont hFont, const char *stringVal)
 
float Fo_StringHeightSingleLine (hAtlas hAtlas, HFont hFont, const char *stringVal)
 
float Fo_StringHeight (hAtlas hAtlas, HFont hFont, const char *stringVal)
 
AtlasSpriteFo_GetCharSprite (hAtlas hAtlas, HFont hFont, char c)
 
float Fo_GetMaxYBearing (hAtlas hAtlas, HFont hFont, const char *str)
 get the maximum y bearing value for a string:
 
float Fo_GetMinYBearing (hAtlas hAtlas, HFont hFont, const char *str)
 get the minimum y bearing value for a string:
 
bool Fo_TryGetCharBearing (hAtlas hAtlas, HFont hFont, char c, vec2 outBearing)
 
bool Fo_TryGetCharAdvance (hAtlas hAtlas, HFont hFont, char c, float *outAdvance)
 

Macro Definition Documentation

◆ MAX_FONT_NAME_SIZE

#define MAX_FONT_NAME_SIZE   128

◆ MAX_FONT_PATH_SIZE

#define MAX_FONT_PATH_SIZE   256

◆ MAX_NUM_FONT_SIZES

#define MAX_NUM_FONT_SIZES   32

◆ VECTOR

#define VECTOR (   a)    a*

Typedef Documentation

◆ AtlasSprite

typedef struct _AtlasSprite AtlasSprite

A sprite stored in the atlas.

◆ DrawContext

typedef struct DrawContext DrawContext

◆ xmlNode

typedef struct _xmlNode xmlNode

Function Documentation

◆ At_AddFont()

HFont At_AddFont ( const struct FontAtlasAdditionSpec pFontSpec)

◆ At_AddSprite()

hSprite At_AddSprite ( const char *  imgPath,
int  topLeftXPx,
int  topRightYPx,
int  widthPx,
int  heightPx,
const char *  name,
bool  bMinimizeSpace 
)

Add a sprite to the atlas, cuts out the pixels for that specific sprite to be nested when At_EndAtlas is called.

Parameters
imgPathpath to img file
topLeftXPxsprite TL coords
topRightYPxsprite TR coords
widthPx"notional" width
heightPx"notional" height
namesprite name, for referencing when it's in the atlas
bMinimizeSpacefind minimum rect to store the sprite, if false action dims == "notional" dims
Returns

◆ At_BeginAtlas()

void At_BeginAtlas ( )

◆ At_BeginTileset()

void At_BeginTileset ( int  beginI)

◆ At_DestroyAtlas()

void At_DestroyAtlas ( hAtlas  atlas,
struct DrawContext pDC 
)

◆ At_EndAtlas()

hAtlas At_EndAtlas ( struct DrawContext pDC)

◆ At_EndAtlasEx()

hAtlas At_EndAtlasEx ( struct DrawContext pDC,
struct EndAtlasOptions pOptions 
)

◆ At_EndTileset()

void At_EndTileset ( int  endI)

◆ At_FindAnim()

struct AtlasAnimation * At_FindAnim ( hAtlas  atlas,
const char *  name 
)

◆ At_FindSprite()

hSprite At_FindSprite ( const char *  name,
hAtlas  atlas 
)

◆ At_GetAtlasTexture()

hTexture At_GetAtlasTexture ( hAtlas  atlas)

◆ At_GetSprite()

AtlasSprite * At_GetSprite ( hSprite  sprite,
hAtlas  atlas 
)

◆ At_Init()

void At_Init ( )

◆ At_LoadAtlas()

hAtlas At_LoadAtlas ( xmlNode child0,
struct DrawContext pDC 
)

◆ At_LoadAtlasEx()

hAtlas At_LoadAtlasEx ( xmlNode child0,
struct DrawContext pDC,
struct EndAtlasOptions pOptions 
)

◆ At_PixelsToPts()

float At_PixelsToPts ( float  val)

◆ At_SerializeAtlas()

void At_SerializeAtlas ( struct BinarySerializer pSerializer,
hAtlas atlas,
struct DrawContext pDC 
)
Parameters
pSerializerbinary serialzier to load or save
atlasIf loading, point to an unititialized handle to output the new handle If saving point to the handle of the atlas you want to save
pDC

◆ At_SetCurrent()

void At_SetCurrent ( hAtlas  atlas,
DrawContext pDC 
)

◆ At_TilemapIndexToSprite()

hSprite At_TilemapIndexToSprite ( hAtlas  atlas,
TileIndex  tileIndex 
)

◆ Fo_CharHeight()

float Fo_CharHeight ( hAtlas  hAtlas,
HFont  hFont,
char  c 
)

◆ Fo_CharWidth()

float Fo_CharWidth ( hAtlas  hAtlas,
HFont  hFont,
char  c 
)

◆ Fo_FindFont()

HFont Fo_FindFont ( hAtlas  hAtlas,
const char *  fontName,
float  sizePts 
)

◆ Fo_GetCharSprite()

AtlasSprite * Fo_GetCharSprite ( hAtlas  hAtlas,
HFont  hFont,
char  c 
)

◆ Fo_GetMaxYBearing()

float Fo_GetMaxYBearing ( hAtlas  hAtlas,
HFont  hFont,
const char *  str 
)

get the maximum y bearing value for a string:

  • bearing is offset from pen position to bounding box edge
    Parameters
    hAtlas
    hFont
    str
    Returns
    max Y bearing

◆ Fo_GetMinYBearing()

float Fo_GetMinYBearing ( hAtlas  hAtlas,
HFont  hFont,
const char *  str 
)

get the minimum y bearing value for a string:

  • bearing is offset from pen position to bounding box edge
  • used to position the string by its top left corner
    Parameters
    hAtlas
    hFont
    str
    Returns
    min Y bearing

◆ Fo_StringHeight()

float Fo_StringHeight ( hAtlas  hAtlas,
HFont  hFont,
const char *  stringVal 
)

◆ Fo_StringHeightSingleLine()

float Fo_StringHeightSingleLine ( hAtlas  hAtlas,
HFont  hFont,
const char *  stringVal 
)

◆ Fo_StringWidth()

float Fo_StringWidth ( hAtlas  hAtlas,
HFont  hFont,
const char *  stringVal 
)

◆ Fo_TryGetCharAdvance()

bool Fo_TryGetCharAdvance ( hAtlas  hAtlas,
HFont  hFont,
char  c,
float *  outAdvance 
)

◆ Fo_TryGetCharBearing()

bool Fo_TryGetCharBearing ( hAtlas  hAtlas,
HFont  hFont,
char  c,
vec2  outBearing 
)