summaryrefslogtreecommitdiff
path: root/src/shapes.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/shapes.c')
-rw-r--r--src/shapes.c588
1 files changed, 117 insertions, 471 deletions
diff --git a/src/shapes.c b/src/shapes.c
index 876520a..ed2af7a 100644
--- a/src/shapes.c
+++ b/src/shapes.c
@@ -25,147 +25,92 @@ int lshapesSetShapesTexture( lua_State *L ) {
}
/*
-> success = RL.DrawPixel( Vector2 pos, Color color )
+> RL.DrawPixel( Vector2 pos, Color color )
Draw a pixel
-
-- Failure return false
-- Success return true
*/
int lshapesDrawPixel( lua_State *L ) {
- if ( !lua_istable( L, 1 ) || !lua_istable( L, 2 ) ) {
- TraceLog( state->logLevelInvalid, "%s", "Bad call of function. RL.DrawPixel( Vector2 pos, Color color )" );
- lua_pushboolean( L, false );
- return 1;
- }
Vector2 pos = uluaGetVector2Index( L, 1 );
Color color = uluaGetColorIndex( L, 2 );
DrawPixelV( pos, color );
- lua_pushboolean( L, true );
- return 1;
+ return 0;
}
/*
-> success = RL.DrawLine( Vector2 startPos, Vector2 endPos, float thickness, Color color )
+> RL.DrawLine( Vector2 startPos, Vector2 endPos, float thickness, Color color )
Draw a line defining thickness
-
-- Failure return false
-- Success return true
*/
int lshapesDrawLine( lua_State *L ) {
- if ( !lua_istable( L, 1 ) || !lua_istable( L, 2 ) || !lua_isnumber( L, 3 ) || !lua_istable( L, 4 ) ) {
- TraceLog( state->logLevelInvalid, "%s", "Bad call of function. RL.DrawLine( Vector2 startPos, Vector2 endPos, float thickness, Color color )" );
- lua_pushboolean( L, false );
- return 1;
- }
Vector2 startPos = uluaGetVector2Index( L, 1 );
Vector2 endPos = uluaGetVector2Index( L, 2 );
- float thickness = lua_tonumber( L, 3 );
+ float thickness = luaL_checknumber( L, 3 );
Color color = uluaGetColorIndex( L, 4 );
DrawLineEx( startPos, endPos, thickness, color );
- lua_pushboolean( L, true );
- return 1;
+ return 0;
}
/*
-> success = RL.DrawLineBezier( Vector2 startPos, Vector2 endPos, float thickness, Color color )
+> RL.DrawLineBezier( Vector2 startPos, Vector2 endPos, float thickness, Color color )
Draw a line using cubic-bezier curves in-out
-
-- Failure return false
-- Success return true
*/
int lshapesDrawLineBezier( lua_State *L ) {
- if ( !lua_istable( L, 1 ) || !lua_istable( L, 2 ) || !lua_isnumber( L, 3 ) || !lua_istable( L, 4 ) ) {
- TraceLog( state->logLevelInvalid, "%s", "Bad call of function. RL.DrawLineBezier( Vector2 startPos, Vector2 endPos, float thickness, Color color )" );
- lua_pushboolean( L, false );
- return 1;
- }
Vector2 startPos = uluaGetVector2Index( L, 1 );
Vector2 endPos = uluaGetVector2Index( L, 2 );
- float thickness = lua_tonumber( L, 3 );
+ float thickness = luaL_checknumber( L, 3 );
Color color = uluaGetColorIndex( L, 4 );
DrawLineBezier( startPos, endPos, thickness, color );
- lua_pushboolean( L, true );
- return 1;
+ return 0;
}
/*
-> success = RL.DrawLineBezierQuad( Vector2 startPos, Vector2 endPos, Vector2 controlPos, float thickness, Color color )
+> RL.DrawLineBezierQuad( Vector2 startPos, Vector2 endPos, Vector2 controlPos, float thickness, Color color )
Draw line using quadratic bezier curves with a control point
-
-- Failure return false
-- Success return true
*/
int lshapesDrawLineBezierQuad( lua_State *L ) {
- if ( !lua_istable( L, 1 ) || !lua_istable( L, 2 ) || !lua_istable( L, 3 )
- || !lua_isnumber( L, 4 ) || !lua_istable( L, 5 ) ) {
- TraceLog( state->logLevelInvalid, "%s", "Bad call of function. RL.DrawLineBezier( Vector2 startPos, Vector2 endPos, Vector2 controlPos, float thickness, Color color )" );
- lua_pushboolean( L, false );
- return 1;
- }
Vector2 startPos = uluaGetVector2Index( L, 1 );
Vector2 endPos = uluaGetVector2Index( L, 2 );
Vector2 controlPos = uluaGetVector2Index( L, 3 );
- float thickness = lua_tonumber( L, 4 );
+ float thickness = luaL_checknumber( L, 4 );
Color color = uluaGetColorIndex( L, 5 );
DrawLineBezierQuad( startPos, endPos, controlPos, thickness, color );
- lua_pushboolean( L, true );
- return 1;
+ return 0;
}
/*
-> success = RL.DrawLineBezierCubic( Vector2 startPos, Vector2 endPos, Vector2 startControlPos, Vector2 endControlPos, float thickness, Color color )
+> RL.DrawLineBezierCubic( Vector2 startPos, Vector2 endPos, Vector2 startControlPos, Vector2 endControlPos, float thickness, Color color )
Draw line using quadratic bezier curves with a control point
-
-- Failure return false
-- Success return true
*/
int lshapesDrawLineBezierCubic( lua_State *L ) {
- if ( !lua_istable( L, 1 ) || !lua_istable( L, 2 ) || !lua_istable( L, 3 ) ||
- !lua_istable( L, 4 ) || !lua_isnumber( L, 5 ) || !lua_istable( L, 6 ) ) {
- TraceLog( state->logLevelInvalid, "%s", "Bad call of function. RL.DrawLineBezierCubic( Vector2 startPos, Vector2 endPos, Vector2 startControlPos, Vector2 endControlPos, float thickness, Color color )" );
- lua_pushboolean( L, false );
- return 1;
- }
Vector2 startPos = uluaGetVector2Index( L, 1 );
Vector2 endPos = uluaGetVector2Index( L, 2 );
Vector2 startControlPos = uluaGetVector2Index( L, 3 );
Vector2 endControlPos = uluaGetVector2Index( L, 4 );
- float thickness = lua_tonumber( L, 5 );
+ float thickness = luaL_checknumber( L, 5 );
Color color = uluaGetColorIndex( L, 6 );
DrawLineBezierCubic( startPos, endPos, startControlPos, endControlPos, thickness, color );
- lua_pushboolean( L, true );
- return 1;
+ return 0;
}
/*
-> success = RL.DrawLineStrip( Vector2{} points, Color color )
+> RL.DrawLineStrip( Vector2{} points, Color color )
Draw lines sequence
-
-- Failure return false
-- Success return true
*/
int lshapesDrawLineStrip( lua_State *L ) {
- if ( !lua_istable( L, 1 ) || !lua_istable( L, 2 ) ) {
- TraceLog( state->logLevelInvalid, "%s", "Bad call of function. RL.DrawLineStrip( Vector2{} points, Color color )" );
- lua_pushboolean( L, false );
- return 1;
- }
int pointsCount = uluaGetTableLenIndex( L, 1 );
Color color = uluaGetColorIndex( L, 2 );
@@ -180,361 +125,229 @@ int lshapesDrawLineStrip( lua_State *L ) {
i++;
lua_pop( L, 1 );
}
-
DrawLineStrip( points, pointsCount, color );
- lua_pushboolean( L, true );
- return 1;
+ return 0;
}
/*
-> success = RL.DrawCircle( Vector2 center, float radius, Color color )
+> RL.DrawCircle( Vector2 center, float radius, Color color )
Draw a color-filled circle
-
-- Failure return false
-- Success return true
*/
int lshapesDrawCircle( lua_State *L ) {
- if ( !lua_istable( L, 1 ) || !lua_isnumber( L, 2 ) || !lua_istable( L, 3 ) ) {
- TraceLog( state->logLevelInvalid, "%s", "Bad call of function. RL.DrawCircle( Vector2 center, float radius, Color color )" );
- lua_pushboolean( L, false );
- return 1;
- }
Vector2 center = uluaGetVector2Index( L, 1 );
- float radius = lua_tonumber( L, 2 );
+ float radius = luaL_checknumber( L, 2 );
Color color = uluaGetColorIndex( L, 3 );
DrawCircleV( center, radius, color );
- lua_pushboolean( L, true );
- return 1;
+ return 0;
}
/*
-> success = RL.DrawCircleSector( Vector2 center, float radius, float startAngle, float endAngle, int segments, Color color )
+> RL.DrawCircleSector( Vector2 center, float radius, float startAngle, float endAngle, int segments, Color color )
Draw a piece of a circle
-
-- Failure return false
-- Success return true
*/
int lshapesDrawCircleSector( lua_State *L ) {
- if ( !lua_istable( L, 1 ) || !lua_isnumber( L, 2 ) || !lua_isnumber( L, 3 ) ||
- !lua_isnumber( L, 4 ) || !lua_isnumber( L, 5 ) || !lua_istable( L, 6 ) ) {
- TraceLog( state->logLevelInvalid, "%s", "Bad call of function. RL.DrawCircleSector( Vector2 center, float radius, float startAngle, float endAngle, int segments, Color color )" );
- lua_pushboolean( L, false );
- return 1;
- }
Vector2 center = uluaGetVector2Index( L, 1 );
- float radius = lua_tonumber( L, 2 );
- float startAngle = lua_tonumber( L, 3 );
- float endAngle = lua_tonumber( L, 4 );
- int segments = lua_tointeger( L, 5 );
+ float radius = luaL_checknumber( L, 2 );
+ float startAngle = luaL_checknumber( L, 3 );
+ float endAngle = luaL_checknumber( L, 4 );
+ int segments = luaL_checkinteger( L, 5 );
Color color = uluaGetColorIndex( L, 6 );
DrawCircleSector( center, radius, startAngle, endAngle, segments, color );
- lua_pushboolean( L, true );
- return 1;
+ return 0;
}
/*
-> success = RL.DrawCircleSectorLines( Vector2 center, float radius, float startAngle, float endAngle, int segments, Color color )
+> RL.DrawCircleSectorLines( Vector2 center, float radius, float startAngle, float endAngle, int segments, Color color )
Draw circle sector outline
-
-- Failure return false
-- Success return true
*/
int lshapesDrawCircleSectorLines( lua_State *L ) {
- if ( !lua_istable( L, 1 ) || !lua_isnumber( L, 2 ) || !lua_isnumber( L, 3 ) ||
- !lua_isnumber( L, 4 ) || !lua_isnumber( L, 5 ) || !lua_istable( L, 6 ) ) {
- TraceLog( state->logLevelInvalid, "%s", "Bad call of function. RL.DrawCircleSectorLines( Vector2 center, float radius, float startAngle, float endAngle, int segments, Color color )" );
- lua_pushboolean( L, false );
- return 1;
- }
Vector2 center = uluaGetVector2Index( L, 1 );
- float radius = lua_tonumber( L, 2 );
- float startAngle = lua_tonumber( L, 3 );
- float endAngle = lua_tonumber( L, 4 );
- int segments = lua_tointeger( L, 5 );
+ float radius = luaL_checknumber( L, 2 );
+ float startAngle = luaL_checknumber( L, 3 );
+ float endAngle = luaL_checknumber( L, 4 );
+ int segments = luaL_checkinteger( L, 5 );
Color color = uluaGetColorIndex( L, 6 );
DrawCircleSectorLines( center, radius, startAngle, endAngle, segments, color );
- lua_pushboolean( L, true );
- return 1;
+ return 0;
}
/*
-> success = RL.DrawCircleGradient( Vector2 center, float radius, Color color1, Color color2 )
+> RL.DrawCircleGradient( Vector2 center, float radius, Color color1, Color color2 )
Draw a gradient-filled circle
-
-- Failure return false
-- Success return true
*/
int lshapesDrawCircleGradient( lua_State *L ) {
- if ( !lua_istable( L, 1 ) || !lua_isnumber( L, 2 ) || !lua_istable( L, 3 ) || !lua_istable( L, 4 ) ) {
- TraceLog( state->logLevelInvalid, "%s", "Bad call of function. RL.DrawCircleGradient( Vector2 center, float radius, Color color1, Color color2 )" );
- lua_pushboolean( L, false );
- return 1;
- }
Vector2 center = uluaGetVector2Index( L, 1 );
- float radius = lua_tonumber( L, 2 );
+ float radius = luaL_checknumber( L, 2 );
Color color1 = uluaGetColorIndex( L, 3 );
Color color2 = uluaGetColorIndex( L, 4 );
DrawCircleGradient( center.x, center.y, radius, color1, color2 );
- lua_pushboolean( L, true );
- return 1;
+ return 0;
}
/*
-> success = RL.DrawCircleLines( Vector2 center, float radius, Color color )
+> RL.DrawCircleLines( Vector2 center, float radius, Color color )
Draw circle outline
-
-- Failure return false
-- Success return true
*/
int lshapesDrawCircleLines( lua_State *L ) {
- if ( !lua_istable( L, 1 ) || !lua_isnumber( L, 2 ) || !lua_istable( L, 3 ) ) {
- TraceLog( state->logLevelInvalid, "%s", "Bad call of function. RL.DrawCircleLines( Vector2 center, float radius, Color color )" );
- lua_pushboolean( L, false );
- return 1;
- }
Vector2 center = uluaGetVector2Index( L, 1 );
- float radius = lua_tonumber( L, 2 );
+ float radius = luaL_checknumber( L, 2 );
Color color = uluaGetColorIndex( L, 3 );
DrawCircleLines( center.x, center.y, radius, color );
- lua_pushboolean( L, true );
- return 1;
+ return 0;
}
/*
-> success = RL.DrawEllipse( Vector2 center, float radiusH, float radiusV, Color color )
+> RL.DrawEllipse( Vector2 center, float radiusH, float radiusV, Color color )
Draw ellipse
-
-- Failure return false
-- Success return true
*/
int lshapesDrawEllipse( lua_State *L ) {
- if ( !lua_istable( L, 1 ) || !lua_isnumber( L, 2 ) || !lua_isnumber( L, 3 ) || !lua_istable( L, 4 ) ) {
- TraceLog( state->logLevelInvalid, "%s", "Bad call of function. RL.DrawEllipse( Vector2 center, float radiusH, float radiusV, Color color )" );
- lua_pushboolean( L, false );
- return 1;
- }
Vector2 center = uluaGetVector2Index( L, 1 );
- float radiusH = lua_tonumber( L, 2 );
- float radiusV = lua_tonumber( L, 3 );
+ float radiusH = luaL_checknumber( L, 2 );
+ float radiusV = luaL_checknumber( L, 3 );
Color color = uluaGetColorIndex( L, 4 );
DrawEllipse( center.x, center.y, radiusH, radiusV, color );
- lua_pushboolean( L, true );
- return 1;
+ return 0;
}
/*
-> success = RL.DrawEllipseLines( Vector2 center, float radiusH, float radiusV, Color color )
+> RL.DrawEllipseLines( Vector2 center, float radiusH, float radiusV, Color color )
Draw ellipse outline
-
-- Failure return false
-- Success return true
*/
int lshapesDrawEllipseLines( lua_State *L ) {
- if ( !lua_istable( L, 1 ) || !lua_isnumber( L, 2 ) || !lua_isnumber( L, 3 ) || !lua_istable( L, 4 ) ) {
- TraceLog( state->logLevelInvalid, "%s", "Bad call of function. RL.DrawEllipseLines( Vector2 center, float radiusH, float radiusV, Color color )" );
- lua_pushboolean( L, false );
- return 1;
- }
Vector2 center = uluaGetVector2Index( L, 1 );
- float radiusH = lua_tonumber( L, 2 );
- float radiusV = lua_tonumber( L, 3 );
+ float radiusH = luaL_checknumber( L, 2 );
+ float radiusV = luaL_checknumber( L, 3 );
Color color = uluaGetColorIndex( L, 4 );
DrawEllipseLines( center.x, center.y, radiusH, radiusV, color );
- lua_pushboolean( L, true );
- return 1;
+ return 0;
}
/*
-> success = RL.DrawRing( Vector2 center, float innerRadius, float outerRadius, float startAngle, float endAngle, int segments, Color color )
+> RL.DrawRing( Vector2 center, float innerRadius, float outerRadius, float startAngle, float endAngle, int segments, Color color )
Draw ring
-
-- Failure return false
-- Success return true
*/
int lshapesDrawRing( lua_State *L ) {
- if ( !lua_istable( L, 1 ) || !lua_istable( L, 2 ) || !lua_isnumber( L, 3 ) || !lua_isnumber( L, 4 ) ||
- !lua_isnumber( L, 5 ) || !lua_isnumber( L, 6 ) || !lua_istable( L, 7 ) ) {
- TraceLog( state->logLevelInvalid, "%s", "Bad call of function. RL.DrawRing( Vector2 center, float innerRadius, float outerRadius, float startAngle, float endAngle, int segments, Color color )" );
- lua_pushboolean( L, false );
- return 1;
- }
Vector2 center = uluaGetVector2Index( L, 1 );
- float innerRadius = lua_tonumber( L, 2 );
- float outerRadius = lua_tonumber( L, 3 );
- float startAngle = lua_tonumber( L, 4 );
- float endAngle = lua_tonumber( L, 5 );
- int segments = lua_tointeger( L, 6 );
+ float innerRadius = luaL_checknumber( L, 2 );
+ float outerRadius = luaL_checknumber( L, 3 );
+ float startAngle = luaL_checknumber( L, 4 );
+ float endAngle = luaL_checknumber( L, 5 );
+ int segments = luaL_checkinteger( L, 6 );
Color color = uluaGetColorIndex( L, 7 );
DrawRing( center, innerRadius, outerRadius, startAngle, endAngle, segments, color );
- lua_pushboolean( L, true );
- return 1;
+ return 0;
}
/*
-> success = RL.DrawRingLines( Vector2 center, float innerRadius, float outerRadius, float startAngle, float endAngle, int segments, Color color )
+> RL.DrawRingLines( Vector2 center, float innerRadius, float outerRadius, float startAngle, float endAngle, int segments, Color color )
Draw ring outline
-
-- Failure return false
-- Success return true
*/
int lshapesDrawRingLines( lua_State *L ) {
- if ( !lua_istable( L, 1 ) || !lua_istable( L, 2 ) || !lua_isnumber( L, 3 ) || !lua_isnumber( L, 4 ) ||
- !lua_isnumber( L, 5 ) || !lua_isnumber( L, 6 ) || !lua_istable( L, 7 ) ) {
- TraceLog( state->logLevelInvalid, "%s", "Bad call of function. RL.DrawRingLines( Vector2 center, float innerRadius, float outerRadius, float startAngle, float endAngle, int segments, Color color )" );
- lua_pushboolean( L, false );
- return 1;
- }
Vector2 center = uluaGetVector2Index( L, 1 );
- float innerRadius = lua_tonumber( L, 2 );
- float outerRadius = lua_tonumber( L, 3 );
- float startAngle = lua_tonumber( L, 4 );
- float endAngle = lua_tonumber( L, 5 );
- int segments = lua_tointeger( L, 6 );
+ float innerRadius = luaL_checknumber( L, 2 );
+ float outerRadius = luaL_checknumber( L, 3 );
+ float startAngle = luaL_checknumber( L, 4 );
+ float endAngle = luaL_checknumber( L, 5 );
+ int segments = luaL_checkinteger( L, 6 );
Color color = uluaGetColorIndex( L, 7 );
DrawRingLines( center, innerRadius, outerRadius, startAngle, endAngle, segments, color );
- lua_pushboolean( L, true );
- return 1;
+ return 0;
}
/*
-> success = RL.DrawRectangle( Rectangle rec, Color color )
+> RL.DrawRectangle( Rectangle rec, Color color )
Draw a color-filled rectangle
-
-- Failure return false
-- Success return true
*/
int lshapesDrawRectangle( lua_State *L ) {
- if ( !lua_istable( L, 1 ) || !lua_istable( L, 2 ) ) {
- TraceLog( state->logLevelInvalid, "%s", "Bad call of function. RL.DrawRectangle( Rectangle rec, Color color )" );
- lua_pushboolean( L, false );
- return 1;
- }
Rectangle rect = uluaGetRectangleIndex( L, 1 );
Color color = uluaGetColorIndex( L, 2 );
DrawRectangleRec( rect, color );
- lua_pushboolean( L, true );
- return 1;
+ return 0;
}
/*
-> success = RL.DrawRectanglePro( Rectangle rec, Vector2 origin, float rotation, Color color )
+> RL.DrawRectanglePro( Rectangle rec, Vector2 origin, float rotation, Color color )
Draw a color-filled rectangle with pro parameters
-
-- Failure return false
-- Success return true
*/
int lshapesDrawRectanglePro( lua_State *L ) {
- if ( !lua_istable( L, 1 ) || !lua_istable( L, 2 ) || !lua_isnumber( L, 3 ) || !lua_istable( L, 4 ) ) {
- TraceLog( state->logLevelInvalid, "%s", "Bad call of function. RL.DrawRectanglePro( Rectangle rec, Vector2 origin, float rotation, Color color )" );
- lua_pushboolean( L, false );
- return 1;
- }
Rectangle rec = uluaGetRectangleIndex( L, 1 );
Vector2 origin = uluaGetVector2Index( L, 2 );
- float rotation = lua_tonumber( L, 3 );
+ float rotation = luaL_checknumber( L, 3 );
Color color = uluaGetColorIndex( L, 4 );
DrawRectanglePro( rec, origin, rotation, color );
- lua_pushboolean( L, true );
- return 1;
+ return 0;
}
/*
-> success = RL.DrawRectangleGradientV( Rectangle rectangle, Color color1, Color color2 )
+> RL.DrawRectangleGradientV( Rectangle rectangle, Color color1, Color color2 )
Draw a vertical-gradient-filled rectangle
-
-- Failure return false
-- Success return true
*/
int lshapesDrawRectangleGradientV( lua_State *L ) {
- if ( !lua_istable( L, 1 ) || !lua_istable( L, 2 ) || !lua_istable( L, 3 ) ) {
- TraceLog( state->logLevelInvalid, "%s", "Bad call of function. RL.DrawRectangleGradientV( Rectangle rectangle, Color color1, Color color2 )" );
- lua_pushboolean( L, false );
- return 1;
- }
Rectangle rect = uluaGetRectangleIndex( L, 1 );
Color color1 = uluaGetColorIndex( L, 2 );
Color color2 = uluaGetColorIndex( L, 3 );
DrawRectangleGradientV( rect.x, rect.y, rect.width, rect.height, color1, color2 );
- lua_pushboolean( L, true );
- return 1;
+ return 0;
}
/*
-> success = RL.DrawRectangleGradientH( Rectangle rectangle, Color color1, Color color2 )
+> RL.DrawRectangleGradientH( Rectangle rectangle, Color color1, Color color2 )
Draw a horizontal-gradient-filled rectangle
-
-- Failure return false
-- Success return true
*/
int lshapesDrawRectangleGradientH( lua_State *L ) {
- if ( !lua_istable( L, 1 ) || !lua_istable( L, 2 ) || !lua_istable( L, 3 ) ) {
- TraceLog( state->logLevelInvalid, "%s", "Bad call of function. RL.DrawRectangleGradientH( Rectangle rectangle, Color color1, Color color2 )" );
- lua_pushboolean( L, false );
- return 1;
- }
Rectangle rect = uluaGetRectangleIndex( L, 1 );
Color color1 = uluaGetColorIndex( L, 2 );
Color color2 = uluaGetColorIndex( L, 3 );
DrawRectangleGradientH( rect.x, rect.y, rect.width, rect.height, color1, color2 );
- lua_pushboolean( L, true );
- return 1;
+ return 0;
}
/*
-> success = RL.DrawRectangleGradientEx( Rectangle rectangle, Color col1, Color col2, Color col3, Color col4 )
+> RL.DrawRectangleGradientEx( Rectangle rectangle, Color col1, Color col2, Color col3, Color col4 )
Draw a gradient-filled rectangle with custom vertex colors
-
-- Failure return false
-- Success return true
*/
int lshapesDrawRectangleGradientEx( lua_State *L ) {
- if ( !lua_istable( L, 1 ) || !lua_istable( L, 2 ) || !lua_istable( L, 3 )
- || !lua_istable( L, 4 ) || !lua_istable( L, 5 ) ) {
- TraceLog( state->logLevelInvalid, "%s", "Bad call of function. RL.DrawRectangleGradientEx( Rectangle rectangle, Color col1, Color col2, Color col3, Color col4 )" );
- lua_pushboolean( L, false );
- return 1;
- }
Rectangle rect = uluaGetRectangleIndex( L, 1 );
Color color1 = uluaGetColorIndex( L, 2 );
Color color2 = uluaGetColorIndex( L, 3 );
@@ -542,174 +355,110 @@ int lshapesDrawRectangleGradientEx( lua_State *L ) {
Color color4 = uluaGetColorIndex( L, 5 );
DrawRectangleGradientEx( rect, color1, color2, color3, color4 );
- lua_pushboolean( L, true );
- return 1;
+ return 0;
}
/*
-> success = RL.DrawRectangleLines( Rectangle rec, Color color )
+> RL.DrawRectangleLines( Rectangle rec, Color color )
Draw rectangle outline
-
-- Failure return false
-- Success return true
*/
int lshapesDrawRectangleLines( lua_State *L ) {
- if ( !lua_istable( L, 1 ) || !lua_istable( L, 2 ) ) {
- TraceLog( state->logLevelInvalid, "%s", "Bad call of function. RL.DrawRectangleLines( Rectangle rec, Color color )" );
- lua_pushboolean( L, false );
- return 1;
- }
Rectangle rect = uluaGetRectangleIndex( L, 1 );
Color color = uluaGetColorIndex( L, 2 );
DrawRectangleLines( rect.x, rect.y, rect.width, rect.height, color );
- lua_pushboolean( L, true );
- return 1;
+ return 0;
}
/*
-> success = RL.DrawRectangleLinesEx( Rectangle rec, int lineThick, Color color )
+> RL.DrawRectangleLinesEx( Rectangle rec, int lineThick, Color color )
Draw rectangle outline with extended parameters
-
-- Failure return false
-- Success return true
*/
int lshapesDrawRectangleLinesEx( lua_State *L ) {
- if ( !lua_istable( L, 1 ) || !lua_isnumber( L, 2 ) || !lua_istable( L, 3 ) ) {
- TraceLog( state->logLevelInvalid, "%s", "Bad call of function. RL.DrawRectangleLinesEx( Rectangle rec, int lineThick, Color color )" );
- lua_pushboolean( L, false );
- return 1;
- }
Rectangle rect = uluaGetRectangleIndex( L, 1 );
- int lineThick = lua_tointeger( L, 2 );
+ int lineThick = luaL_checkinteger( L, 2 );
Color color = uluaGetColorIndex( L, 3 );
DrawRectangleLinesEx( rect, lineThick, color );
- lua_pushboolean( L, true );
- return 1;
+ return 0;
}
/*
-> success = RL.DrawRectangleRounded( Rectangle rec, float roundness, int segments, Color color )
+> RL.DrawRectangleRounded( Rectangle rec, float roundness, int segments, Color color )
Draw rectangle with rounded edges
-
-- Failure return false
-- Success return true
*/
int lshapesDrawRectangleRounded( lua_State *L ) {
- if ( !lua_istable( L, 1 ) || !lua_isnumber( L, 2 ) || !lua_isnumber( L, 3 ) || !lua_istable( L, 4 ) ) {
- TraceLog( state->logLevelInvalid, "%s", "Bad call of function. RL.DrawRectangleRounded( Rectangle rec, float roundness, int segments, Color color )" );
- lua_pushboolean( L, false );
- return 1;
- }
Rectangle rect = uluaGetRectangleIndex( L, 1 );
- float roundness = lua_tonumber( L, 2 );
- int segments = lua_tointeger( L, 3 );
+ float roundness = luaL_checknumber( L, 2 );
+ int segments = luaL_checkinteger( L, 3 );
Color color = uluaGetColorIndex( L, 4 );
DrawRectangleRounded( rect, roundness, segments, color );
- lua_pushboolean( L, true );
- return 1;
+ return 0;
}
/*
-> success = RL.DrawRectangleRoundedLines( Rectangle rec, float roundness, int segments, int lineThick, Color color )
+> RL.DrawRectangleRoundedLines( Rectangle rec, float roundness, int segments, int lineThick, Color color )
Draw rectangle with rounded edges outline
-
-- Failure return false
-- Success return true
*/
int lshapesDrawRectangleRoundedLines( lua_State *L ) {
- if ( !lua_istable( L, 1 ) || !lua_isnumber( L, 2 ) || !lua_isnumber( L, 3 )
- || !lua_isnumber( L, 4 ) || !lua_istable( L, 5 ) ) {
- TraceLog( state->logLevelInvalid, "%s", "Bad call of function. RL.DrawRectangleRoundedLines( Rectangle rec, float roundness, int segments, int lineThick, Color color )" );
- lua_pushboolean( L, false );
- return 1;
- }
Rectangle rect = uluaGetRectangleIndex( L, 1 );
- float roundness = lua_tonumber( L, 2 );
- int segments = lua_tointeger( L, 3 );
- int lineThick = lua_tointeger( L, 4 );
+ float roundness = luaL_checknumber( L, 2 );
+ int segments = luaL_checkinteger( L, 3 );
+ int lineThick = luaL_checkinteger( L, 4 );
Color color = uluaGetColorIndex( L, 5 );
DrawRectangleRoundedLines( rect, roundness, segments, lineThick, color );
- lua_pushboolean( L, true );
- return 1;
+ return 0;
}
/*
-> success = RL.DrawTriangle( Vector2 v1, Vector2 v2, Vector2 v3, Color color )
+> RL.DrawTriangle( Vector2 v1, Vector2 v2, Vector2 v3, Color color )
-Draw a color-filled triangle ( Vertex in counter-clockwise order! )
-
-- Failure return false
-- Success return true
+Draw a color-filled triangle (Vertex in counter-clockwise order!)
*/
int lshapesDrawTriangle( lua_State *L ) {
- if ( !lua_istable( L, 1 ) || !lua_istable( L, 2 ) || !lua_istable( L, 3 ) || !lua_istable( L, 4 ) ) {
- TraceLog( state->logLevelInvalid, "%s", "Bad call of function. RL.DrawTriangle( Vector2 v1, Vector2 v2, Vector2 v3, Color color )" );
- lua_pushboolean( L, false );
- return 1;
- }
Vector2 v1 = uluaGetVector2Index( L, 1 );
Vector2 v2 = uluaGetVector2Index( L, 2 );
Vector2 v3 = uluaGetVector2Index( L, 3 );
Color color = uluaGetColorIndex( L, 4 );
DrawTriangle( v1, v2, v3, color );
- lua_pushboolean( L, true );
- return 1;
+ return 0;
}
/*
-> success = RL.DrawTriangleLines( Vector2 v1, Vector2 v2, Vector2 v3, Color color )
+> RL.DrawTriangleLines( Vector2 v1, Vector2 v2, Vector2 v3, Color color )
-Draw triangle outline ( Vertex in counter-clockwise order! )
-
-- Failure return false
-- Success return true
+Draw triangle outline (Vertex in counter-clockwise order!)
*/
int lshapesDrawTriangleLines( lua_State *L ) {
- if ( !lua_istable( L, 1 ) || !lua_istable( L, 2 ) || !lua_istable( L, 3 ) || !lua_istable( L, 4 ) ) {
- TraceLog( state->logLevelInvalid, "%s", "Bad call of function. RL.DrawTriangleLines( Vector2 v1, Vector2 v2, Vector2 v3, Color color )" );
- lua_pushboolean( L, false );
- return 1;
- }
Vector2 v1 = uluaGetVector2Index( L, 1 );
Vector2 v2 = uluaGetVector2Index( L, 2 );
Vector2 v3 = uluaGetVector2Index( L, 3 );
Color color = uluaGetColorIndex( L, 4 );
DrawTriangleLines( v1, v2, v3, color );
- lua_pushboolean( L, true );
- return 1;
+ return 0;
}
/*
-> success = RL.DrawTriangleFan( Vector2{} points, Color color )
-
-Draw a triangle fan defined by points ( first vertex is the center )
+> RL.DrawTriangleFan( Vector2{} points, Color color )
-- Failure return false
-- Success return true
+Draw a triangle fan defined by points (first vertex is the center)
*/
int lshapesDrawTriangleFan( lua_State *L ) {
- if ( !lua_istable( L, 1 ) || !lua_istable( L, 2 ) ) {
- TraceLog( state->logLevelInvalid, "%s", "Bad call of function. RL.DrawTriangleFan( Vector2{} points, Color color )" );
- lua_pushboolean( L, false );
- return 1;
- }
int pointsCount = uluaGetTableLenIndex( L, 1 );
Color color = uluaGetColorIndex( L, 2 );
@@ -724,27 +473,17 @@ int lshapesDrawTriangleFan( lua_State *L ) {
i++;
lua_pop( L, 1 );
}
-
DrawTriangleFan( points, pointsCount, color );
- lua_pushboolean( L, true );
- return 1;
+ return 0;
}
/*
-> success = RL.DrawTriangleStrip( Vector2{} points, Color color )
+> RL.DrawTriangleStrip( Vector2{} points, Color color )
Draw a triangle strip defined by points
-
-- Failure return false
-- Success return true
*/
int lshapesDrawTriangleStrip( lua_State *L ) {
- if ( !lua_istable( L, 1 ) || !lua_istable( L, 2 ) ) {
- TraceLog( state->logLevelInvalid, "%s", "Bad call of function. RL.DrawTriangleStrip( Vector2{} points, Color color )" );
- lua_pushboolean( L, false );
- return 1;
- }
int pointsCount = uluaGetTableLenIndex( L, 1 );
Color color = uluaGetColorIndex( L, 2 );
@@ -759,93 +498,61 @@ int lshapesDrawTriangleStrip( lua_State *L ) {
i++;
lua_pop( L, 1 );
}
-
DrawTriangleStrip( points, pointsCount, color );
- lua_pushboolean( L, true );
- return 1;
+ return 0;
}
/*
-> success = RL.DrawPoly( Vector2 center, int sides, float radius, float rotation, Color color )
-
-Draw a regular polygon ( Vector version )
+> RL.DrawPoly( Vector2 center, int sides, float radius, float rotation, Color color )
-- Failure return false
-- Success return true
+Draw a regular polygon (Vector version)
*/
int lshapesDrawPoly( lua_State *L ) {
- if ( !lua_istable( L, 1 ) || !lua_isnumber( L, 2 ) || !lua_isnumber( L, 3 )
- || !lua_isnumber( L, 4 ) || !lua_istable( L, 5 ) ) {
- TraceLog( state->logLevelInvalid, "%s", "Bad call of function. RL.DrawPoly( Vector2 center, int sides, float radius, float rotation, Color color )" );
- lua_pushboolean( L, false );
- return 1;
- }
Vector2 center = uluaGetVector2Index( L, 1 );
- int sides = lua_tointeger( L, 2 );
- float radius = lua_tonumber( L, 3 );
- float rotation = lua_tonumber( L, 4 );
+ int sides = luaL_checkinteger( L, 2 );
+ float radius = luaL_checknumber( L, 3 );
+ float rotation = luaL_checknumber( L, 4 );
Color color = uluaGetColorIndex( L, 5 );
DrawPoly( center, sides, radius, rotation, color );
- lua_pushboolean( L, true );
- return 1;
+ return 0;
}
/*
-> success = RL.DrawPolyLines( Vector2 center, int sides, float radius, float rotation, Color color )
+> RL.DrawPolyLines( Vector2 center, int sides, float radius, float rotation, Color color )
Draw a polygon outline of n sides
-
-- Failure return false
-- Success return true
*/
int lshapesDrawPolyLines( lua_State *L ) {
- if ( !lua_istable( L, 1 ) || !lua_isnumber( L, 2 ) || !lua_isnumber( L, 3 )
- || !lua_isnumber( L, 4 ) || !lua_istable( L, 5 ) ) {
- TraceLog( state->logLevelInvalid, "%s", "Bad call of function. RL.DrawPolyLines( Vector2 center, int sides, float radius, float rotation, Color color )" );
- lua_pushboolean( L, false );
- return 1;
- }
Vector2 center = uluaGetVector2Index( L, 1 );
- int sides = lua_tointeger( L, 2 );
- float radius = lua_tonumber( L, 3 );
- float rotation = lua_tonumber( L, 4 );
+ int sides = luaL_checkinteger( L, 2 );
+ float radius = luaL_checknumber( L, 3 );
+ float rotation = luaL_checknumber( L, 4 );
Color color = uluaGetColorIndex( L, 5 );
DrawPolyLines( center, sides, radius, rotation, color );
- lua_pushboolean( L, true );
- return 1;
+ return 0;
}
/*
-> success = RL.DrawPolyLinesEx( Vector2 center, int sides, float radius, float rotation, float lineThick, Color color )
+> RL.DrawPolyLinesEx( Vector2 center, int sides, float radius, float rotation, float lineThick, Color color )
Draw a polygon outline of n sides with extended parameters
-
-- Failure return false
-- Success return true
*/
int lshapesDrawPolyLinesEx( lua_State *L ) {
- if ( !lua_istable( L, 1 ) || !lua_isnumber( L, 2 ) || !lua_isnumber( L, 3 ) ||
- !lua_isnumber( L, 4 ) || !lua_isnumber( L, 5 ) || !lua_istable( L, 6 ) ) {
- TraceLog( state->logLevelInvalid, "%s", "Bad call of function. RL.DrawPolyLinesEx( Vector2 center, int sides, float radius, float rotation, float lineThick, Color color )" );
- lua_pushboolean( L, false );
- return 1;
- }
Vector2 center = uluaGetVector2Index( L, 1 );
- int sides = lua_tointeger( L, 2 );
- float radius = lua_tonumber( L, 3 );
- float rotation = lua_tonumber( L, 4 );
- float lineThick = lua_tonumber( L, 5 );
+ int sides = luaL_checkinteger( L, 2 );
+ float radius = luaL_checknumber( L, 3 );
+ float rotation = luaL_checknumber( L, 4 );
+ float lineThick = luaL_checknumber( L, 5 );
Color color = uluaGetColorIndex( L, 6 );
DrawPolyLinesEx( center, sides, radius, rotation, lineThick, color );
- lua_pushboolean( L, true );
- return 1;
+ return 0;
}
/*
@@ -857,15 +564,9 @@ int lshapesDrawPolyLinesEx( lua_State *L ) {
Check collision between two rectangles
-- Failure return nil
- Success return bool
*/
int lshapesCheckCollisionRecs( lua_State *L ) {
- if ( !lua_istable( L, 1 ) || !lua_istable( L, 2 ) ) {
- TraceLog( state->logLevelInvalid, "%s", "Bad call of function. RL.CheckCollisionRecs( Rectangle rec1, Rectangle rec2 )" );
- lua_pushnil( L );
- return 1;
- }
Rectangle rect1 = uluaGetRectangleIndex( L, 1 );
Rectangle rect2 = uluaGetRectangleIndex( L, 2 );
@@ -879,19 +580,13 @@ int lshapesCheckCollisionRecs( lua_State *L ) {
Check collision between two circles
-- Failure return nil
- Success return bool
*/
int lshapesCheckCollisionCircles( lua_State *L ) {
- if ( !lua_istable( L, 1 ) || !lua_isnumber( L, 2 ) || !lua_istable( L, 3 ) || !lua_isnumber( L, 4 ) ) {
- TraceLog( state->logLevelInvalid, "%s", "Bad call of function. RL.CheckCollisionCircles( Vector2 center1, float radius1, Vector2 center2, float radius2 )" );
- lua_pushnil( L );
- return 1;
- }
Vector2 center1 = uluaGetVector2Index( L, 1 );
- float radius1 = lua_tonumber( L, 2 );
+ float radius1 = luaL_checknumber( L, 2 );
Vector2 center2 = uluaGetVector2Index( L, 3 );
- float radius2 = lua_tonumber( L, 4 );
+ float radius2 = luaL_checknumber( L, 4 );
lua_pushboolean( L, CheckCollisionCircles( center1, radius1, center2, radius2 ) );
@@ -903,17 +598,11 @@ int lshapesCheckCollisionCircles( lua_State *L ) {
Check collision between circle and rectangle
-- Failure return nil
- Success return bool
*/
int lshapesCheckCollisionCircleRec( lua_State *L ) {
- if ( !lua_istable( L, 1 ) || !lua_isnumber( L, 2 ) || !lua_istable( L, 3 ) ) {
- TraceLog( state->logLevelInvalid, "%s", "Bad call of function. RL.CheckCollisionCircleRec( Vector2 center, float radius, Rectangle rec )" );
- lua_pushnil( L );
- return 1;
- }
Vector2 center = uluaGetVector2Index( L, 1 );
- float radius = lua_tonumber( L, 2 );
+ float radius = luaL_checknumber( L, 2 );
Rectangle rec = uluaGetRectangleIndex( L, 3 );
lua_pushboolean( L, CheckCollisionCircleRec( center, radius, rec ) );
@@ -926,15 +615,9 @@ int lshapesCheckCollisionCircleRec( lua_State *L ) {
Check if point is inside rectangle
-- Failure return nil
- Success return bool
*/
int lshapesCheckCollisionPointRec( lua_State *L ) {
- if ( !lua_istable( L, 1 ) || !lua_istable( L, 2 ) ) {
- TraceLog( state->logLevelInvalid, "%s", "Bad call of function. RL.CheckCollisionPointRec( Vector2 point, Rectangle rec )" );
- lua_pushnil( L );
- return 1;
- }
Vector2 point = uluaGetVector2Index( L, 1 );
Rectangle rec = uluaGetRectangleIndex( L, 2 );
@@ -948,18 +631,12 @@ int lshapesCheckCollisionPointRec( lua_State *L ) {
Check if point is inside circle
-- Failure return nil
- Success return bool
*/
int lshapesCheckCollisionPointCircle( lua_State *L ) {
- if ( !lua_istable( L, 1 ) || !lua_istable( L, 2 ) || !lua_isnumber( L, 3 ) ) {
- TraceLog( state->logLevelInvalid, "%s", "Bad call of function. RL.CheckCollisionPointCircle( Vector2 point, Vector2 center, float radius )" );
- lua_pushnil( L );
- return 1;
- }
Vector2 point = uluaGetVector2Index( L, 1 );
Vector2 center = uluaGetVector2Index( L, 2 );
- float radius = lua_tonumber( L, 3 );
+ float radius = luaL_checknumber( L, 3 );
lua_pushboolean( L, CheckCollisionPointCircle( point, center, radius ) );
@@ -971,15 +648,9 @@ int lshapesCheckCollisionPointCircle( lua_State *L ) {
Check if point is inside a triangle
-- Failure return nil
- Success return bool
*/
int lshapesCheckCollisionPointTriangle( lua_State *L ) {
- if ( !lua_istable( L, 1 ) || !lua_istable( L, 2 ) || !lua_istable( L, 3 ) || !lua_istable( L, 4 ) ) {
- TraceLog( state->logLevelInvalid, "%s", "Bad call of function. RL.CheckCollisionPointTriangle( Vector2 point, Vector2 p1, Vector2 p2, Vector2 p3 )" );
- lua_pushnil( L );
- return 1;
- }
Vector2 point = uluaGetVector2Index( L, 1 );
Vector2 p1 = uluaGetVector2Index( L, 2 );
Vector2 p2 = uluaGetVector2Index( L, 3 );
@@ -995,15 +666,9 @@ int lshapesCheckCollisionPointTriangle( lua_State *L ) {
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, 1 ) || !lua_istable( L, 2 ) ) {
- TraceLog( state->logLevelInvalid, "%s", "Bad call of function. RL.CheckCollisionPointPoly( Vector2 point, Vector2{} points )" );
- lua_pushnil( L );
- return 1;
- }
Vector2 point = uluaGetVector2Index( L, 1 );
int pointCount = uluaGetTableLenIndex( L, 2 );
Vector2 points[ pointCount ];
@@ -1017,7 +682,6 @@ int lshapesCheckCollisionPointPoly( lua_State *L ) {
i++;
lua_pop( L, 1 );
}
-
lua_pushboolean( L, CheckCollisionPointPoly( point, points, pointCount ) );
return 1;
@@ -1028,15 +692,9 @@ int lshapesCheckCollisionPointPoly( lua_State *L ) {
Check the collision between two lines defined by two points each, returns collision point by reference
-- Failure return nil
- Success return bool, Vector2
*/
int lshapesCheckCollisionLines( lua_State *L ) {
- if ( !lua_istable( L, 1 ) || !lua_istable( L, 2 ) || !lua_istable( L, 3 ) || !lua_istable( L, 4 ) ) {
- TraceLog( state->logLevelInvalid, "%s", "Bad call of function. RL.CheckCollisionLines( Vector2 startPos1, Vector2 endPos1, Vector2 startPos2, Vector2 endPos2 )" );
- lua_pushnil( L );
- return 1;
- }
Vector2 startPos1 = uluaGetVector2Index( L, 1 );
Vector2 endPos1 = uluaGetVector2Index( L, 2 );
Vector2 startPos2 = uluaGetVector2Index( L, 3 );
@@ -1055,19 +713,13 @@ int lshapesCheckCollisionLines( lua_State *L ) {
Check if point belongs to line created between two points [p1] and [p2] with defined margin in pixels [threshold]
-- Failure return nil
- Success return bool
*/
int lshapesCheckCollisionPointLine( lua_State *L ) {
- if ( !lua_istable( L, 1 ) || !lua_istable( L, 2 ) || !lua_istable( L, 3 ) || !lua_isnumber( L, 4 ) ) {
- TraceLog( state->logLevelInvalid, "%s", "Bad call of function. RL.CheckCollisionPointLine( Vector2 point, Vector2 p1, Vector2 p2, int threshold )" );
- lua_pushnil( L );
- return 1;
- }
Vector2 point = uluaGetVector2Index( L, 1 );
Vector2 p1 = uluaGetVector2Index( L, 2 );
Vector2 p2 = uluaGetVector2Index( L, 3 );
- int threshold = lua_tointeger( L, 4 );
+ int threshold = luaL_checkinteger( L, 4 );
lua_pushboolean( L, CheckCollisionPointLine( point, p1, p2, threshold ) );
@@ -1079,15 +731,9 @@ int lshapesCheckCollisionPointLine( lua_State *L ) {
Get collision rectangle for two rectangles collision
-- Failure return nil
- Success return Rectangle
*/
int lshapesGetCollisionRec( lua_State *L ) {
- if ( !lua_istable( L, 1 ) || !lua_istable( L, 2 ) ) {
- TraceLog( state->logLevelInvalid, "%s", "Bad call of function. RL.GetCollisionRec( Rectangle rec1, Rectangle rec2 )" );
- lua_pushnil( L );
- return 1;
- }
Rectangle rec1 = uluaGetRectangleIndex( L, 1 );
Rectangle rec2 = uluaGetRectangleIndex( L, 2 );