From 9e7f538a38eb66430f919eec1d5cfa3a7a1efe8c Mon Sep 17 00:00:00 2001 From: jussi Date: Thu, 6 Apr 2023 22:17:33 +0300 Subject: Vector2LineAngle and more Color functions. --- src/textures.c | 69 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 69 insertions(+) (limited to 'src/textures.c') diff --git a/src/textures.c b/src/textures.c index ab6e53f..b6a49f1 100644 --- a/src/textures.c +++ b/src/textures.c @@ -2448,6 +2448,75 @@ int ltexturesColorFromHSV( lua_State *L ) { return 1; } +/* +> color = RL.ColorTint( Color color, Color tint ) + +Get color multiplied with another color + +- Failure return false +- Success return Color +*/ +int ltexturesColorTint( lua_State *L ) { + if ( !lua_istable( L, -2 ) || !lua_istable( L, -1 ) ) { + TraceLog( LOG_WARNING, "%s", "Bad call of function. RL.ColorTint( Color color, Color tint )" ); + lua_pushboolean( L, false ); + return 1; + } + Color tint = uluaGetColor( L ); + lua_pop( L, 1 ); + Color color = uluaGetColor( L ); + + uluaPushColor( L, ColorTint( color, tint ) ); + + return 1; +} + +/* +> color = RL.ColorBrightness( Color color, float factor ) + +Get color with brightness correction, brightness factor goes from -1.0f to 1.0f + +- Failure return false +- Success return Color +*/ +int ltexturesColorBrightness( lua_State *L ) { + if ( !lua_istable( L, -2 ) || !lua_isnumber( L, -1 ) ) { + TraceLog( LOG_WARNING, "%s", "Bad call of function. RL.ColorBrightness( Color color, float factor )" ); + lua_pushboolean( L, false ); + return 1; + } + float factor = lua_tonumber( L, -1 ); + lua_pop( L, 1 ); + Color color = uluaGetColor( L ); + + uluaPushColor( L, ColorBrightness( color, factor ) ); + + return 1; +} + +/* +> color = RL.ColorContrast( Color color, float contrast ) + +Get color with contrast correction, contrast values between -1.0f and 1.0f + +- Failure return false +- Success return Color +*/ +int ltexturesColorContrast( lua_State *L ) { + if ( !lua_istable( L, -2 ) || !lua_isnumber( L, -1 ) ) { + TraceLog( LOG_WARNING, "%s", "Bad call of function. RL.ColorContrast( Color color, float contrast )" ); + lua_pushboolean( L, false ); + return 1; + } + float contrast = lua_tonumber( L, -1 ); + lua_pop( L, 1 ); + Color color = uluaGetColor( L ); + + uluaPushColor( L, ColorContrast( color, contrast ) ); + + return 1; +} + /* > color = RL.ColorAlpha( Color color, float alpha ) -- cgit v1.2.3