summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorjussi2023-04-06 22:17:33 +0300
committerjussi2023-04-06 22:17:33 +0300
commit9e7f538a38eb66430f919eec1d5cfa3a7a1efe8c (patch)
tree1b9b90b57a419ceef0dce1004b63b3ab04421a4d /src
parentfe15e836bd87963d10bd301a3a24652763059e0d (diff)
downloadreilua-enhanced-9e7f538a38eb66430f919eec1d5cfa3a7a1efe8c.tar.gz
reilua-enhanced-9e7f538a38eb66430f919eec1d5cfa3a7a1efe8c.tar.bz2
reilua-enhanced-9e7f538a38eb66430f919eec1d5cfa3a7a1efe8c.zip
Vector2LineAngle and more Color functions.
Diffstat (limited to 'src')
-rw-r--r--src/lua_core.c4
-rw-r--r--src/shapes.c35
-rw-r--r--src/textures.c69
3 files changed, 108 insertions, 0 deletions
diff --git a/src/lua_core.c b/src/lua_core.c
index 9197170..920d408 100644
--- a/src/lua_core.c
+++ b/src/lua_core.c
@@ -914,6 +914,7 @@ void luaRegister() {
assingGlobalFunction( "CheckCollisionPointRec", lshapesCheckCollisionPointRec );
assingGlobalFunction( "CheckCollisionPointCircle", lshapesCheckCollisionPointCircle );
assingGlobalFunction( "CheckCollisionPointTriangle", lshapesCheckCollisionPointTriangle );
+ assingGlobalFunction( "CheckCollisionPointPoly", lshapesCheckCollisionPointPoly );
assingGlobalFunction( "CheckCollisionLines", lshapesCheckCollisionLines );
assingGlobalFunction( "CheckCollisionPointLine", lshapesCheckCollisionPointLine );
assingGlobalFunction( "GetCollisionRec", lshapesGetCollisionRec );
@@ -1011,6 +1012,9 @@ void luaRegister() {
assingGlobalFunction( "ColorFromNormalized", ltexturesColorFromNormalized );
assingGlobalFunction( "ColorToHSV", ltexturesColorToHSV );
assingGlobalFunction( "ColorFromHSV", ltexturesColorFromHSV );
+ assingGlobalFunction( "ColorTint", ltexturesColorTint );
+ assingGlobalFunction( "ColorBrightness", ltexturesColorBrightness );
+ assingGlobalFunction( "ColorContrast", ltexturesColorContrast );
assingGlobalFunction( "ColorAlpha", ltexturesColorAlpha );
assingGlobalFunction( "ColorAlphaBlend", ltexturesColorAlphaBlend );
assingGlobalFunction( "GetColor", ltexturesGetColor );
diff --git a/src/shapes.c b/src/shapes.c
index cf50ca3..d5f92f6 100644
--- a/src/shapes.c
+++ b/src/shapes.c
@@ -1106,6 +1106,41 @@ int lshapesCheckCollisionPointTriangle( lua_State *L ) {
}
/*
+> collision = RL.CheckCollisionPointPoly( Vector2 point, Vector2{} points )
+
+Check if point is within a polygon described by array of vertices
+
+- Failure return nil
+- Success return bool
+*/
+int lshapesCheckCollisionPointPoly( lua_State *L ) {
+ if ( !lua_istable( L, -2 ) || !lua_istable( L, -1 ) ) {
+ TraceLog( LOG_WARNING, "%s", "Bad call of function. RL.CheckCollisionPointPoly( Vector2 point, Vector2{} points )" );
+ lua_pushnil( L );
+ return 1;
+ }
+ int pointCount = uluaGetTableLen( L );
+ Vector2 points[ pointCount ];
+
+ int t = lua_gettop( L );
+ int i = 0;
+ lua_pushnil( L );
+
+ while ( lua_next( L, t ) != 0 ) {
+ points[i] = uluaGetVector2( L );
+ i++;
+ lua_pop( L, 1 );
+ }
+ lua_pop( L, 1 );
+
+ Vector2 point = uluaGetVector2( L );
+
+ lua_pushboolean( L, CheckCollisionPointPoly( point, points, pointCount ) );
+
+ return 1;
+}
+
+/*
> collision, position = RL.CheckCollisionLines( Vector2 startPos1, Vector2 endPos1, Vector2 startPos2, Vector2 endPos2 )
Check the collision between two lines defined by two points each, returns collision point by reference
diff --git a/src/textures.c b/src/textures.c
index ab6e53f..b6a49f1 100644
--- a/src/textures.c
+++ b/src/textures.c
@@ -2449,6 +2449,75 @@ int ltexturesColorFromHSV( lua_State *L ) {
}
/*
+> 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 )
Returns color with alpha applied, alpha goes from 0.0f to 1.0f