summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--API.md6
-rw-r--r--ReiLua_API.lua10
-rw-r--r--changelog1
-rw-r--r--include/models.h1
-rw-r--r--src/lua_core.c1
-rw-r--r--src/models.c52
6 files changed, 71 insertions, 0 deletions
diff --git a/API.md b/API.md
index e38b231..fc19591 100644
--- a/API.md
+++ b/API.md
@@ -7310,6 +7310,12 @@ Draw a grid (Centered at ( 0, 0, 0 ))
---
+> RL.DrawGridEx( Vector2 slices, Vector2 spacing, Matrix transform, Color color, Vector2|nil divider, Color|nil dividerColor )
+
+Draw a grid with extended parameters. Optionally you can define divider with different color for every n slices
+
+---
+
## Models - Model management functions
---
diff --git a/ReiLua_API.lua b/ReiLua_API.lua
index afe86e6..5a69d0e 100644
--- a/ReiLua_API.lua
+++ b/ReiLua_API.lua
@@ -4495,6 +4495,16 @@ function RL.DrawRay( ray, color ) end
---@return any RL.DrawGrid
function RL.DrawGrid( slices, spacing ) end
+---Draw a grid with extended parameters. Optionally you can define divider with different color for every n slices
+---@param slices table
+---@param spacing table
+---@param transform table
+---@param color table
+---@param divider table|nil
+---@param dividerColor table|nil
+---@return any RL.DrawGridEx
+function RL.DrawGridEx( slices, spacing, transform, color, divider, dividerColor ) end
+
-- Models - Model management functions
---Load model from files (Meshes and materials)
diff --git a/changelog b/changelog
index 228bd0e..e78d73e 100644
--- a/changelog
+++ b/changelog
@@ -65,6 +65,7 @@ DETAILED CHANGES:
- FIXED: ColorToInt cast to unsigned int.
- ADDED: Many Gui controls accept now nil for text.
- ADDED: Some raygui controls return 1 instead of 0 when pressed or scrolled.
+ - ADDED: DrawGridEx.
------------------------------------------------------------------------
Release: ReiLua version 0.7.0 Using Raylib 5.0 and Forked Raygui 4.0
diff --git a/include/models.h b/include/models.h
index 09379b9..6b35c43 100644
--- a/include/models.h
+++ b/include/models.h
@@ -27,6 +27,7 @@ int lmodelsDrawPlane( lua_State* L );
int lmodelDrawQuad3DTexture( lua_State* L );
int lmodelsDrawRay( lua_State* L );
int lmodelsDrawGrid( lua_State* L );
+int lmodelsDrawGridEx( lua_State* L );
/* Model management functions. */
int lmodelsLoadModel( lua_State* L );
int lmodelsLoadModelFromMesh( lua_State* L );
diff --git a/src/lua_core.c b/src/lua_core.c
index 0955f77..2d5ddcc 100644
--- a/src/lua_core.c
+++ b/src/lua_core.c
@@ -1726,6 +1726,7 @@ void luaRegister() {
assingGlobalFunction( "DrawQuad3DTexture", lmodelDrawQuad3DTexture );
assingGlobalFunction( "DrawRay", lmodelsDrawRay );
assingGlobalFunction( "DrawGrid", lmodelsDrawGrid );
+ assingGlobalFunction( "DrawGridEx", lmodelsDrawGridEx );
/* Model management functions. */
assingGlobalFunction( "LoadModel", lmodelsLoadModel );
assingGlobalFunction( "LoadModelFromMesh", lmodelsLoadModelFromMesh );
diff --git a/src/models.c b/src/models.c
index 61b9c2b..652a6c0 100644
--- a/src/models.c
+++ b/src/models.c
@@ -497,6 +497,58 @@ int lmodelsDrawGrid( lua_State* L ) {
}
/*
+> RL.DrawGridEx( Vector2 slices, Vector2 spacing, Matrix transform, Color color, Vector2|nil divider, Color|nil dividerColor )
+
+Draw a grid with extended parameters. Optionally you can define divider with different color for every n slices
+*/
+int lmodelsDrawGridEx( lua_State* L ) {
+ Vector2 slices = uluaGetVector2( L, 1 );
+ Vector2 spacing = uluaGetVector2( L, 2 );
+ Matrix transform = uluaGetMatrix( L, 3 );
+ Color color = uluaGetColor( L, 4 );
+
+ Vector2 divider = { 0, 0 };
+ Color divColor = WHITE;
+
+ if ( !lua_isnil( L, 5 ) && !lua_isnone( L, 5 ) ) {
+ divider = uluaGetVector2( L, 5 );
+ }
+ if ( !lua_isnil( L, 6 ) && !lua_isnone( L, 6 ) ) {
+ divColor = uluaGetColor( L, 6 );
+ }
+
+ rlPushMatrix();
+ rlMultMatrixf( MatrixToFloat( transform ) );
+
+ rlBegin( RL_LINES );
+ for ( int x = 0; x < (int)slices.x + 1; x++ ) {
+ if ( 0 < x && x < slices.x && 0 < divider.x && x % (int)divider.x == 0 ) {
+ rlColor4ub( divColor.r, divColor.g, divColor.b, divColor.a );
+ }
+ else {
+ rlColor4ub( color.r, color.g, color.b, color.a );
+ }
+
+ rlVertex3f( spacing.x * x, 0, 0 );
+ rlVertex3f( spacing.x * x, 0, slices.y * spacing.y );
+ }
+ for ( int y = 0; y < (int)slices.y + 1; y++ ) {
+ if ( 0 < y && y < slices.y && 0 < divider.y && y % (int)divider.y == 0 ) {
+ rlColor4ub( divColor.r, divColor.g, divColor.b, divColor.a );
+ }
+ else {
+ rlColor4ub( color.r, color.g, color.b, color.a );
+ }
+ rlVertex3f( 0, 0, spacing.y * y );
+ rlVertex3f( slices.x * spacing.x, 0, spacing.y * y );
+ }
+ rlEnd();
+ rlPopMatrix();
+
+ return 0;
+}
+
+/*
## Models - Model management functions
*/