Vector2LineAngle and more Color functions.
This commit is contained in:
@@ -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 );
|
||||
|
||||
35
src/shapes.c
35
src/shapes.c
@@ -1105,6 +1105,41 @@ int lshapesCheckCollisionPointTriangle( lua_State *L ) {
|
||||
return 1;
|
||||
}
|
||||
|
||||
/*
|
||||
> 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 )
|
||||
|
||||
|
||||
@@ -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 )
|
||||
|
||||
|
||||
Reference in New Issue
Block a user