diff options
| author | jussi | 2022-02-22 15:06:23 +0200 |
|---|---|---|
| committer | jussi | 2022-02-22 15:06:23 +0200 |
| commit | a7f58b3261565b59e508c659ae3a7f1964a5bad5 (patch) | |
| tree | e9e337687923e0997885d1b55f735d82bf29c6ed /src/text.c | |
| parent | 8800de59fa704cfe60ac980db079b44042639684 (diff) | |
| download | reilua-enhanced-a7f58b3261565b59e508c659ae3a7f1964a5bad5.tar.gz reilua-enhanced-a7f58b3261565b59e508c659ae3a7f1964a5bad5.tar.bz2 reilua-enhanced-a7f58b3261565b59e508c659ae3a7f1964a5bad5.zip | |
Touch and gestures.
Diffstat (limited to 'src/text.c')
| -rw-r--r-- | src/text.c | 69 |
1 files changed, 67 insertions, 2 deletions
@@ -40,7 +40,7 @@ Load font from file into GPU memory ( VRAM ) - Failure return -1 - Success return int */ -int lmodelsLoadFont( lua_State *L ) { +int ltextLoadFont( lua_State *L ) { if ( !lua_isstring( L, -1 ) ) { TraceLog( LOG_WARNING, "%s", "Bad call of function. RL_LoadFont( string fileName )" ); lua_pushinteger( L, -1 ); @@ -62,6 +62,33 @@ int lmodelsLoadFont( lua_State *L ) { } /* +> success = RL_UnloadFont( Font font ) + +Unload Font from GPU memory ( VRAM ) + +- Failure return false +- Success return true +*/ +int ltextUnloadFont( lua_State *L ) { + if ( !lua_isnumber( L, -1 ) ) { + TraceLog( LOG_WARNING, "%s", "Bad call of function. RL_UnloadFont( Font font )" ); + lua_pushboolean( L, false ); + return 1; + } + size_t id = lua_tointeger( L, -1 ); + + if ( !validFont( id ) ) { + lua_pushboolean( L, false ); + return 1; + } + UnloadFont( *state->fonts[ id ] ); + state->fonts[ id ] = NULL; + lua_pushboolean( L, true ); + + return 1; +} + +/* ## Text - Draw */ @@ -116,9 +143,47 @@ int ltextDrawText( lua_State *L ) { lua_pushboolean( L, false ); return 1; } - DrawTextEx( *state->fonts[ fontId ], lua_tostring( L, -1 ), position, fontSize, spacing, color ); lua_pushboolean( L, true ); return 1; } + +/* +> success = RL_DrawTextPro( Font font, const char text, Vector2 position, Vector2 origin, float rotation, float fontSize, float spacing, Color tint ) + +Draw text using Font and pro parameters ( rotation ) + +- Failure return false +- Success return true +*/ +int ltextDrawTextPro( lua_State *L ) { + if ( !lua_isnumber( L, -8 ) || !lua_isstring( L, -7 ) || !lua_istable( L, -6 ) || !lua_istable( L, -5 ) + || !lua_isnumber( L, -4 ) || !lua_isnumber( L, -3 ) || !lua_isnumber( L, -2 ) || !lua_istable( L, -1 ) ) { + TraceLog( LOG_WARNING, "%s", "Bad call of function. RL_DrawTextPro( Font font, const char text, Vector2 position, Vector2 origin, float rotation, float fontSize, float spacing, Color tint )" ); + lua_pushboolean( L, false ); + return 1; + } + Color color = uluaGetColor( L ); + lua_pop( L, 1 ); + float spacing = lua_tonumber( L, -1 ); + lua_pop( L, 1 ); + float fontSize = lua_tonumber( L, -1 ); + lua_pop( L, 1 ); + float rotation = lua_tonumber( L, -1 ); + lua_pop( L, 1 ); + Vector2 origin = uluaGetVector2( L ); + lua_pop( L, 1 ); + Vector2 position = uluaGetVector2( L ); + lua_pop( L, 1 ); + size_t fontId = lua_tointeger( L, -2 ); + + if ( !validFont( fontId ) ) { + lua_pushboolean( L, false ); + return 1; + } + DrawTextPro( *state->fonts[ fontId ], lua_tostring( L, -1 ), position, origin, rotation, fontSize, spacing, color ); + lua_pushboolean( L, true ); + + return 1; +} |
