Touch and gestures.
This commit is contained in:
69
src/text.c
69
src/text.c
@@ -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 );
|
||||
@@ -61,6 +61,33 @@ int lmodelsLoadFont( lua_State *L ) {
|
||||
return 1;
|
||||
}
|
||||
|
||||
/*
|
||||
> 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;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user