GenImagePerlinNoise and GenImageText. Get indexed functions for types.
This commit is contained in:
18
API.md
18
API.md
@@ -2982,6 +2982,15 @@ Generate image: white noise
|
||||
|
||||
---
|
||||
|
||||
> image = RL.GenImagePerlinNoise( Vector2 size, Vector2 offset, float factor )
|
||||
|
||||
Generate image: perlin noise
|
||||
|
||||
- Failure return -1
|
||||
- Success return int
|
||||
|
||||
---
|
||||
|
||||
> image = RL.GenImageCellular( Vector2 size, int tileSize )
|
||||
|
||||
Generate image: cellular algorithm. Bigger tileSize means bigger cells
|
||||
@@ -2991,6 +3000,15 @@ Generate image: cellular algorithm. Bigger tileSize means bigger cells
|
||||
|
||||
---
|
||||
|
||||
> image = RL.GenImageText( Vector2 size, string text )
|
||||
|
||||
Generate image: grayscale image from text data
|
||||
|
||||
- Failure return -1
|
||||
- Success return int
|
||||
|
||||
---
|
||||
|
||||
## Textures - Image Manipulation Functions
|
||||
|
||||
---
|
||||
|
||||
@@ -2127,6 +2127,15 @@ function RL.GenImageChecked( size, checks, col1, col2 ) end
|
||||
---@return any image
|
||||
function RL.GenImageWhiteNoise( size, factor ) end
|
||||
|
||||
---Generate image: perlin noise
|
||||
---- Failure return -1
|
||||
---- Success return int
|
||||
---@param size table
|
||||
---@param offset table
|
||||
---@param factor number
|
||||
---@return any image
|
||||
function RL.GenImagePerlinNoise( size, offset, factor ) end
|
||||
|
||||
---Generate image: cellular algorithm. Bigger tileSize means bigger cells
|
||||
---- Failure return -1
|
||||
---- Success return int
|
||||
@@ -2135,6 +2144,14 @@ function RL.GenImageWhiteNoise( size, factor ) end
|
||||
---@return any image
|
||||
function RL.GenImageCellular( size, tileSize ) end
|
||||
|
||||
---Generate image: grayscale image from text data
|
||||
---- Failure return -1
|
||||
---- Success return int
|
||||
---@param size table
|
||||
---@param text string
|
||||
---@return any image
|
||||
function RL.GenImageText( size, text ) end
|
||||
|
||||
-- Textures - Image Manipulation Functions
|
||||
|
||||
---Create an image duplicate ( useful for transformations )
|
||||
|
||||
@@ -28,6 +28,8 @@ Detailed changes:
|
||||
- ADDED: ColorTint
|
||||
- ADDED: ColorBrightness
|
||||
- ADDED: ColorContrast
|
||||
- ADDED: GenImagePerlinNoise
|
||||
- ADDED: GenImageText
|
||||
|
||||
------------------------------------------------------------------------
|
||||
Release: ReiLua version 0.4.0 Using Raylib 4.2
|
||||
|
||||
2
devnotes
2
devnotes
@@ -17,8 +17,6 @@ Backlog {
|
||||
* Compression/Encoding functionality.
|
||||
* SetWindowIcons.
|
||||
* Textures
|
||||
* GenImagePerlinNoise
|
||||
* GenImageText
|
||||
* ImageDrawCircleLines
|
||||
* ImageBlurGaussian
|
||||
* Models
|
||||
|
||||
@@ -9,15 +9,35 @@ void luaCallExit();
|
||||
void luaRegister();
|
||||
/* Lua Util functions */
|
||||
Color uluaGetColor( lua_State *L );
|
||||
/* Only works with positive index. */
|
||||
Color uluaGetColorIndex( lua_State *L, int index );
|
||||
Vector2 uluaGetVector2( lua_State *L );
|
||||
/* Only works with positive index. */
|
||||
Vector2 uluaGetVector2Index( lua_State *L, int index );
|
||||
Vector3 uluaGetVector3( lua_State *L );
|
||||
/* Only works with positive index. */
|
||||
Vector3 uluaGetVector3Index( lua_State *L, int index );
|
||||
Vector4 uluaGetVector4( lua_State *L );
|
||||
/* Only works with positive index. */
|
||||
Vector4 uluaGetVector4Index( lua_State *L, int index );
|
||||
Rectangle uluaGetRectangle( lua_State *L );
|
||||
/* Only works with positive index. */
|
||||
Rectangle uluaGetRectangleIndex( lua_State *L, int index );
|
||||
Quaternion uluaGetQuaternion( lua_State *L );
|
||||
/* Only works with positive index. */
|
||||
Quaternion uluaGetQuaternionIndex( lua_State *L, int index );
|
||||
Matrix uluaGetMatrix( lua_State *L );
|
||||
/* Only works with positive index. */
|
||||
Matrix uluaGetMatrixIndex( lua_State *L, int index );
|
||||
BoundingBox uluaGetBoundingBox( lua_State *L );
|
||||
/* Only works with positive index. */
|
||||
BoundingBox uluaGetBoundingBoxIndex( lua_State *L, int index );
|
||||
Ray uluaGetRay( lua_State *L );
|
||||
/* Only works with positive index. */
|
||||
Ray uluaGetRayIndex( lua_State *L, int index );
|
||||
NPatchInfo uluaGetNPatchInfo( lua_State *L );
|
||||
/* Only works with positive index. */
|
||||
NPatchInfo uluaGetNPatchInfoIndex( lua_State *L, int index );
|
||||
|
||||
void uluaPushColor( lua_State *L, Color color );
|
||||
void uluaPushVector2( lua_State *L, Vector2 vector );
|
||||
|
||||
@@ -22,7 +22,9 @@ int ltexturesGenImageGradientH( lua_State *L );
|
||||
int ltexturesGenImageGradientRadial( lua_State *L );
|
||||
int ltexturesGenImageChecked( lua_State *L );
|
||||
int ltexturesGenImageWhiteNoise( lua_State *L );
|
||||
int ltexturesGenImagePerlinNoise( lua_State *L );
|
||||
int ltexturesGenImageCellular( lua_State *L );
|
||||
int ltexturesGenImageText( lua_State *L );
|
||||
/* Image Manipulation Functions. */
|
||||
int ltexturesImageCopy( lua_State *L );
|
||||
int ltexturesImageFromImage( lua_State *L );
|
||||
|
||||
@@ -934,7 +934,9 @@ void luaRegister() {
|
||||
assingGlobalFunction( "GenImageGradientRadial", ltexturesGenImageGradientRadial );
|
||||
assingGlobalFunction( "GenImageChecked", ltexturesGenImageChecked );
|
||||
assingGlobalFunction( "GenImageWhiteNoise", ltexturesGenImageWhiteNoise );
|
||||
assingGlobalFunction( "GenImagePerlinNoise", ltexturesGenImagePerlinNoise );
|
||||
assingGlobalFunction( "GenImageCellular", ltexturesGenImageCellular );
|
||||
assingGlobalFunction( "GenImageText", ltexturesGenImageText );
|
||||
/* Image Manipulation Functions. */
|
||||
assingGlobalFunction( "ImageCopy", ltexturesImageCopy );
|
||||
assingGlobalFunction( "ImageFromImage", ltexturesImageFromImage );
|
||||
@@ -1380,13 +1382,18 @@ void luaRegister() {
|
||||
/* Lua util functions. */
|
||||
|
||||
Color uluaGetColor( lua_State *L ) {
|
||||
return uluaGetColorIndex( L, lua_gettop( L ) );
|
||||
}
|
||||
|
||||
Color uluaGetColorIndex( lua_State *L, int index ) {
|
||||
Color color = { 0, 0, 0, 255 };
|
||||
|
||||
if ( !lua_istable( L, -1 ) ) {
|
||||
if ( !lua_istable( L, index ) ) {
|
||||
TraceLog( LOG_WARNING, "%s", "Error. Wrong color value. Returning { 0, 0, 0, 255 }" );
|
||||
return color;
|
||||
}
|
||||
int t = lua_gettop( L ), i = 0;
|
||||
// int t = lua_gettop( L ), i = 0;
|
||||
int t = index, i = 0;
|
||||
lua_pushnil( L );
|
||||
|
||||
while ( lua_next( L, t ) != 0 ) {
|
||||
@@ -1431,13 +1438,17 @@ Color uluaGetColor( lua_State *L ) {
|
||||
}
|
||||
|
||||
Vector2 uluaGetVector2( lua_State *L ) {
|
||||
return uluaGetVector2Index( L, lua_gettop( L ) );
|
||||
}
|
||||
|
||||
Vector2 uluaGetVector2Index( lua_State *L, int index ) {
|
||||
Vector2 vector = { 0.0f, 0.0f };
|
||||
|
||||
if ( !lua_istable( L, -1 ) ) {
|
||||
if ( !lua_istable( L, index ) ) {
|
||||
TraceLog( LOG_WARNING, "%s", "Error. Wrong vector2 value. Returning { 0, 0 }" );
|
||||
return vector;
|
||||
}
|
||||
int t = lua_gettop( L ), i = 0;
|
||||
int t = index, i = 0;
|
||||
lua_pushnil( L );
|
||||
|
||||
while ( lua_next( L, t ) != 0 ) {
|
||||
@@ -1470,13 +1481,17 @@ Vector2 uluaGetVector2( lua_State *L ) {
|
||||
}
|
||||
|
||||
Vector3 uluaGetVector3( lua_State *L ) {
|
||||
return uluaGetVector3Index( L, lua_gettop( L ) );
|
||||
}
|
||||
|
||||
Vector3 uluaGetVector3Index( lua_State *L, int index ) {
|
||||
Vector3 vector = { 0.0f, 0.0f, 0.0f };
|
||||
|
||||
if ( !lua_istable( L, -1 ) ) {
|
||||
if ( !lua_istable( L, index ) ) {
|
||||
TraceLog( LOG_WARNING, "%s", "Error. Wrong vector3 value. Returning { 0, 0, 0 }" );
|
||||
return vector;
|
||||
}
|
||||
int t = lua_gettop( L ), i = 0;
|
||||
int t = index, i = 0;
|
||||
lua_pushnil( L );
|
||||
|
||||
while ( lua_next( L, t ) != 0 ) {
|
||||
@@ -1515,13 +1530,17 @@ Vector3 uluaGetVector3( lua_State *L ) {
|
||||
}
|
||||
|
||||
Vector4 uluaGetVector4( lua_State *L ) {
|
||||
return uluaGetVector4Index( L, lua_gettop( L ) );
|
||||
}
|
||||
|
||||
Vector4 uluaGetVector4Index( lua_State *L, int index ) {
|
||||
Vector4 vector = { 0.0f, 0.0f, 0.0f, 0.0f };
|
||||
|
||||
if ( !lua_istable( L, -1 ) ) {
|
||||
if ( !lua_istable( L, index ) ) {
|
||||
TraceLog( LOG_WARNING, "%s", "Error. Wrong vector4 value. Returning { 0, 0, 0, 0 }" );
|
||||
return vector;
|
||||
}
|
||||
int t = lua_gettop( L ), i = 0;
|
||||
int t = index, i = 0;
|
||||
lua_pushnil( L );
|
||||
|
||||
while ( lua_next( L, t ) != 0 ) {
|
||||
@@ -1566,13 +1585,18 @@ Vector4 uluaGetVector4( lua_State *L ) {
|
||||
}
|
||||
|
||||
Rectangle uluaGetRectangle( lua_State *L ) {
|
||||
return uluaGetRectangleIndex( L, lua_gettop( L ) );
|
||||
}
|
||||
|
||||
Rectangle uluaGetRectangleIndex( lua_State *L, int index ) {
|
||||
Rectangle rect = { 0.0f, 0.0f, 0.0f, 0.0f };
|
||||
|
||||
if ( !lua_istable( L, -1 ) ) {
|
||||
if ( !lua_istable( L, index ) ) {
|
||||
TraceLog( LOG_WARNING, "%s", "Error. Wrong rectangle value. Returning { 0, 0, 0, 0 }" );
|
||||
return rect;
|
||||
}
|
||||
int t = lua_gettop( L ), i = 0;
|
||||
|
||||
int t = index, i = 0;
|
||||
lua_pushnil( L );
|
||||
|
||||
while ( lua_next( L, t ) != 0 ) {
|
||||
@@ -1617,13 +1641,17 @@ Rectangle uluaGetRectangle( lua_State *L ) {
|
||||
}
|
||||
|
||||
Quaternion uluaGetQuaternion( lua_State *L ) {
|
||||
return uluaGetQuaternionIndex( L, lua_gettop( L ) );
|
||||
}
|
||||
|
||||
Quaternion uluaGetQuaternionIndex( lua_State *L, int index ) {
|
||||
Quaternion quaternion = { 0.0f, 0.0f, 0.0f, 0.0f };
|
||||
|
||||
if ( !lua_istable( L, -1 ) ) {
|
||||
if ( !lua_istable( L, index ) ) {
|
||||
TraceLog( LOG_WARNING, "%s", "Error. Wrong quaternion value. Returning { 0, 0, 0, 0 }" );
|
||||
return quaternion;
|
||||
}
|
||||
int t = lua_gettop( L ), i = 0;
|
||||
int t = index, i = 0;
|
||||
lua_pushnil( L );
|
||||
|
||||
while ( lua_next( L, t ) != 0 ) {
|
||||
@@ -1668,14 +1696,18 @@ Quaternion uluaGetQuaternion( lua_State *L ) {
|
||||
}
|
||||
|
||||
Matrix uluaGetMatrix( lua_State *L ) {
|
||||
return uluaGetMatrixIndex( L, lua_gettop( L ) );
|
||||
}
|
||||
|
||||
Matrix uluaGetMatrixIndex( lua_State *L, int index ) {
|
||||
Matrix matrix = { 0.0f };
|
||||
float m[4][4];
|
||||
|
||||
if ( !lua_istable( L, -1 ) ) {
|
||||
if ( !lua_istable( L, index ) ) {
|
||||
TraceLog( LOG_WARNING, "%s", "Error. Wrong matrix value. Returning MatrixIdentity." );
|
||||
return MatrixIdentity();
|
||||
}
|
||||
int t = lua_gettop( L ), i = 0;
|
||||
int t = index, i = 0;
|
||||
lua_pushnil( L );
|
||||
|
||||
while ( lua_next( L, t ) != 0 ) {
|
||||
@@ -1703,13 +1735,17 @@ Matrix uluaGetMatrix( lua_State *L ) {
|
||||
}
|
||||
|
||||
BoundingBox uluaGetBoundingBox( lua_State *L ) {
|
||||
return uluaGetBoundingBoxIndex( L, lua_gettop( L ) );
|
||||
}
|
||||
|
||||
BoundingBox uluaGetBoundingBoxIndex( lua_State *L, int index ) {
|
||||
BoundingBox box = { .min = { 0.0, 0.0, 0.0 }, .max = { 0.0, 0.0, 0.0 } };
|
||||
|
||||
if ( !lua_istable( L, -1 ) ) {
|
||||
if ( !lua_istable( L, index ) ) {
|
||||
TraceLog( LOG_WARNING, "%s", "Error. Wrong boundingbox value. Returning { min{ 0, 0, 0 }, max{ 0, 0, 0 } }." );
|
||||
return box;
|
||||
}
|
||||
int t = lua_gettop( L ), i = 0;
|
||||
int t = index, i = 0;
|
||||
lua_pushnil( L );
|
||||
|
||||
while ( lua_next( L, t ) != 0 ) {
|
||||
@@ -1743,13 +1779,17 @@ BoundingBox uluaGetBoundingBox( lua_State *L ) {
|
||||
}
|
||||
|
||||
Ray uluaGetRay( lua_State *L ) {
|
||||
return uluaGetRayIndex( L, lua_gettop( L ) );
|
||||
}
|
||||
|
||||
Ray uluaGetRayIndex( lua_State *L, int index ) {
|
||||
Ray ray = { .position = { 0.0, 0.0, 0.0 }, .direction = { 0.0, 0.0, 0.0 } };
|
||||
|
||||
if ( !lua_istable( L, -1 ) ) {
|
||||
if ( !lua_istable( L, index ) ) {
|
||||
TraceLog( LOG_WARNING, "%s", "Error. Wrong ray value. Returning { position{ 0, 0, 0 }, direction{ 0, 0, 0 } }." );
|
||||
return ray;
|
||||
}
|
||||
int t = lua_gettop( L ), i = 0;
|
||||
int t = index, i = 0;
|
||||
lua_pushnil( L );
|
||||
|
||||
while ( lua_next( L, t ) != 0 ) {
|
||||
@@ -1783,13 +1823,17 @@ Ray uluaGetRay( lua_State *L ) {
|
||||
}
|
||||
|
||||
NPatchInfo uluaGetNPatchInfo( lua_State *L ) {
|
||||
return uluaGetNPatchInfoIndex( L, lua_gettop( L ) );
|
||||
}
|
||||
|
||||
NPatchInfo uluaGetNPatchInfoIndex( lua_State *L, int index ) {
|
||||
NPatchInfo npatch = { .source = { 0.0, 0.0, 0.0, 0.0 }, .left = 0, .top = 0, .right = 0, .bottom = 0, .layout = NPATCH_NINE_PATCH };
|
||||
|
||||
if ( !lua_istable( L, -1 ) ) {
|
||||
if ( !lua_istable( L, index ) ) {
|
||||
TraceLog( LOG_WARNING, "%s", "Error. Wrong ray value. Returning { source = { 0.0, 0.0, 0.0, 0.0 }, left = 0, top = 0, right = 0, bottom = 0, layout = NPATCH_NINE_PATCH }." );
|
||||
return npatch;
|
||||
}
|
||||
int t = lua_gettop( L ), i = 0;
|
||||
int t = index, i = 0;
|
||||
lua_pushnil( L );
|
||||
|
||||
while ( lua_next( L, t ) != 0 ) {
|
||||
|
||||
176
src/textures.c
176
src/textures.c
@@ -144,15 +144,15 @@ Load image from file into CPU memory ( RAM )
|
||||
- Success return int
|
||||
*/
|
||||
int ltexturesLoadImage( lua_State *L ) {
|
||||
if ( !lua_isstring( L, -1 ) ) {
|
||||
if ( !lua_isstring( L, 1 ) ) {
|
||||
TraceLog( LOG_WARNING, "%s", "Bad call of function. RL.LoadImage( string fileName )" );
|
||||
lua_pushinteger( L, -1 );
|
||||
return 1;
|
||||
}
|
||||
|
||||
if ( FileExists( lua_tostring( L, -1 ) ) ) {
|
||||
if ( FileExists( lua_tostring( L, 1 ) ) ) {
|
||||
int i = newImage();
|
||||
*state->images[i] = LoadImage( lua_tostring( L, -1 ) );
|
||||
*state->images[i] = LoadImage( lua_tostring( L, 1 ) );
|
||||
lua_pushinteger( L, i );
|
||||
|
||||
return 1;
|
||||
@@ -172,12 +172,12 @@ Load image from GPU texture data
|
||||
- Success return int
|
||||
*/
|
||||
int ltexturesLoadImageFromTexture( lua_State *L ) {
|
||||
if ( !lua_isnumber( L, -1 ) ) {
|
||||
if ( !lua_isnumber( L, 1 ) ) {
|
||||
TraceLog( LOG_WARNING, "%s", "Bad call of function. RL.LoadImageFromTexture( Texture2D texture )" );
|
||||
lua_pushinteger( L, -1 );
|
||||
return 1;
|
||||
}
|
||||
size_t texId = lua_tointeger( L, -1 );
|
||||
size_t texId = lua_tointeger( L, 1 );
|
||||
|
||||
if ( !validSourceTexture( texId ) ) {
|
||||
lua_pushinteger( L, -1 );
|
||||
@@ -214,12 +214,12 @@ Unload image from CPU memory ( RAM )
|
||||
- Success return true
|
||||
*/
|
||||
int ltexturesUnloadImage( lua_State *L ) {
|
||||
if ( !lua_isnumber( L, -1 ) ) {
|
||||
if ( !lua_isnumber( L, 1 ) ) {
|
||||
TraceLog( LOG_WARNING, "%s", "Bad call of function. RL.UnloadImage( Image image )" );
|
||||
lua_pushboolean( L, false );
|
||||
return 1;
|
||||
}
|
||||
size_t id = lua_tointeger( L, -1 );
|
||||
size_t id = lua_tointeger( L, 1 );
|
||||
|
||||
if ( !validImage( id ) ) {
|
||||
lua_pushboolean( L, false );
|
||||
@@ -241,18 +241,18 @@ Export image data to file, returns true on success
|
||||
- Success return bool
|
||||
*/
|
||||
int ltexturesExportImage( lua_State *L ) {
|
||||
if ( !lua_isnumber( L, -2 ) || !lua_isstring( L, -1 ) ) {
|
||||
if ( !lua_isnumber( L, 1 ) || !lua_isstring( L, 2 ) ) {
|
||||
TraceLog( LOG_WARNING, "%s", "Bad call of function. RL.ExportImage( Image image, string fileName )" );
|
||||
lua_pushnil( L );
|
||||
return 1;
|
||||
}
|
||||
size_t id = lua_tointeger( L, -2 );
|
||||
size_t id = lua_tointeger( L, 1 );
|
||||
|
||||
if ( !validImage( id ) ) {
|
||||
lua_pushnil( L );
|
||||
return 1;
|
||||
}
|
||||
lua_pushboolean( L, ExportImage( *state->images[ id ], lua_tostring( L, -1 ) ) );
|
||||
lua_pushboolean( L, ExportImage( *state->images[ id ], lua_tostring( L, 2 ) ) );
|
||||
|
||||
return 1;
|
||||
}
|
||||
@@ -266,18 +266,18 @@ Export image as code file defining an array of bytes, returns true on success
|
||||
- Success return bool
|
||||
*/
|
||||
int ltexturesExportImageAsCode( lua_State *L ) {
|
||||
if ( !lua_isnumber( L, -2 ) || !lua_isstring( L, -1 ) ) {
|
||||
if ( !lua_isnumber( L, 1 ) || !lua_isstring( L, 2 ) ) {
|
||||
TraceLog( LOG_WARNING, "%s", "Bad call of function. RL.ExportImageAsCode( Image image, string fileName )" );
|
||||
lua_pushnil( L );
|
||||
return 1;
|
||||
}
|
||||
size_t id = lua_tointeger( L, -2 );
|
||||
size_t id = lua_tointeger( L, 1 );
|
||||
|
||||
if ( !validImage( id ) ) {
|
||||
lua_pushnil( L );
|
||||
return 1;
|
||||
}
|
||||
lua_pushboolean( L, ExportImageAsCode( *state->images[ id ], lua_tostring( L, -1 ) ) );
|
||||
lua_pushboolean( L, ExportImageAsCode( *state->images[ id ], lua_tostring( L, 2 ) ) );
|
||||
|
||||
return 1;
|
||||
}
|
||||
@@ -295,16 +295,14 @@ Generate image: plain color
|
||||
- Success return int
|
||||
*/
|
||||
int ltexturesGenImageColor( lua_State *L ) {
|
||||
if ( !lua_isnumber( L, -3 ) || !lua_isnumber( L, -2 ) || !lua_istable( L, -1 ) ) {
|
||||
if ( !lua_isnumber( L, 1 ) || !lua_isnumber( L, 2 ) || !lua_istable( L, 3 ) ) {
|
||||
TraceLog( LOG_WARNING, "%s", "Bad call of function. RL.GenImageColor( int width, int height, Color color )" );
|
||||
lua_pushinteger( L, -1 );
|
||||
return 1;
|
||||
}
|
||||
Color color = uluaGetColor( L );
|
||||
lua_pop( L, 1 );
|
||||
int height = lua_tointeger( L, -1 );
|
||||
lua_pop( L, 1 );
|
||||
int width = lua_tointeger( L, -1 );
|
||||
int width = lua_tointeger( L, 1 );
|
||||
int height = lua_tointeger( L, 2 );
|
||||
Color color = uluaGetColorIndex( L, 3 );
|
||||
|
||||
int i = newImage();
|
||||
*state->images[i] = GenImageColor( width, height, color );
|
||||
@@ -322,16 +320,14 @@ Generate image: vertical gradient
|
||||
- Success return int
|
||||
*/
|
||||
int ltexturesGenImageGradientV( lua_State *L ) {
|
||||
if ( !lua_istable( L, -3 ) || !lua_istable( L, -2 ) || !lua_istable( L, -1 ) ) {
|
||||
if ( !lua_istable( L, 1 ) || !lua_istable( L, 2 ) || !lua_istable( L, 3 ) ) {
|
||||
TraceLog( LOG_WARNING, "%s", "Bad call of function. RL.GenImageGradientV( Vector2 size, Color top, Color bottom )" );
|
||||
lua_pushinteger( L, -1 );
|
||||
return 1;
|
||||
}
|
||||
Color bottom = uluaGetColor( L );
|
||||
lua_pop( L, 1 );
|
||||
Color top = uluaGetColor( L );
|
||||
lua_pop( L, 1 );
|
||||
Vector2 size = uluaGetVector2( L );
|
||||
Vector2 size = uluaGetVector2Index( L, 1 );
|
||||
Color top = uluaGetColorIndex( L, 2 );
|
||||
Color bottom = uluaGetColorIndex( L, 3 );
|
||||
|
||||
int i = newImage();
|
||||
*state->images[i] = GenImageGradientV( (int)size.x, (int)size.y, top, bottom );
|
||||
@@ -405,18 +401,15 @@ Generate image: checked
|
||||
- Success return int
|
||||
*/
|
||||
int ltexturesGenImageChecked( lua_State *L ) {
|
||||
if ( !lua_istable( L, -4 ) || !lua_istable( L, -3 ) || !lua_istable( L, -2 ) || !lua_istable( L, -1 ) ) {
|
||||
if ( !lua_istable( L, 1 ) || !lua_istable( L, 2 ) || !lua_istable( L, 3 ) || !lua_istable( L, 4 ) ) {
|
||||
TraceLog( LOG_WARNING, "%s", "Bad call of function. RL.GenImageChecked( Vector2 size, Vector2 checks, Color col1, Color col2 )" );
|
||||
lua_pushinteger( L, -1 );
|
||||
return 1;
|
||||
}
|
||||
Color col2 = uluaGetColor( L );
|
||||
lua_pop( L, 1 );
|
||||
Color col1 = uluaGetColor( L );
|
||||
lua_pop( L, 1 );
|
||||
Vector2 checks = uluaGetVector2( L );
|
||||
lua_pop( L, 1 );
|
||||
Vector2 size = uluaGetVector2( L );
|
||||
Vector2 size = uluaGetVector2Index( L, 1 );
|
||||
Vector2 checks = uluaGetVector2Index( L, 2 );
|
||||
Color col1 = uluaGetColorIndex( L, 3 );
|
||||
Color col2 = uluaGetColorIndex( L, 4 );
|
||||
|
||||
int i = newImage();
|
||||
*state->images[i] = GenImageChecked( (int)size.x, (int)size.y, (int)checks.x, (int)checks.y, col1, col2 );
|
||||
@@ -434,14 +427,13 @@ Generate image: white noise
|
||||
- Success return int
|
||||
*/
|
||||
int ltexturesGenImageWhiteNoise( lua_State *L ) {
|
||||
if ( !lua_istable( L, -2 ) || !lua_isnumber( L, -1 ) ) {
|
||||
if ( !lua_istable( L, 1 ) || !lua_isnumber( L, 2 ) ) {
|
||||
TraceLog( LOG_WARNING, "%s", "Bad call of function. RL.GenImageWhiteNoise( Vector2 size, float factor )" );
|
||||
lua_pushinteger( L, -1 );
|
||||
return 1;
|
||||
}
|
||||
float factor = lua_tonumber( L, -1 );
|
||||
lua_pop( L, 1 );
|
||||
Vector2 size = uluaGetVector2( L );
|
||||
Vector2 size = uluaGetVector2Index( L, 1 );
|
||||
float factor = lua_tonumber( L, 2 );
|
||||
|
||||
int i = newImage();
|
||||
*state->images[i] = GenImageWhiteNoise( (int)size.x, (int)size.y, factor );
|
||||
@@ -450,6 +442,30 @@ int ltexturesGenImageWhiteNoise( lua_State *L ) {
|
||||
return 1;
|
||||
}
|
||||
|
||||
/*
|
||||
> image = RL.GenImagePerlinNoise( Vector2 size, Vector2 offset, float factor )
|
||||
|
||||
Generate image: perlin noise
|
||||
|
||||
- Failure return -1
|
||||
- Success return int
|
||||
*/
|
||||
int ltexturesGenImagePerlinNoise( lua_State *L ) {
|
||||
if ( !lua_istable( L, 1 ) || !lua_istable( L, 2 ) || !lua_isnumber( L, 3 ) ) {
|
||||
TraceLog( LOG_WARNING, "%s", "Bad call of function. RL.GenImagePerlinNoise( Vector2 size, Vector2 offset, float factor )" );
|
||||
lua_pushinteger( L, -1 );
|
||||
return 1;
|
||||
}
|
||||
Vector2 size = uluaGetVector2Index( L, 1 );
|
||||
Vector2 offset = uluaGetVector2Index( L, 2 );
|
||||
|
||||
int i = newImage();
|
||||
*state->images[i] = GenImagePerlinNoise( (int)size.x, (int)size.y, (int)offset.x, (int)offset.y, lua_tonumber( L, 3 ) );
|
||||
lua_pushinteger( L, i );
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
/*
|
||||
> image = RL.GenImageCellular( Vector2 size, int tileSize )
|
||||
|
||||
@@ -459,17 +475,38 @@ Generate image: cellular algorithm. Bigger tileSize means bigger cells
|
||||
- Success return int
|
||||
*/
|
||||
int ltexturesGenImageCellular( lua_State *L ) {
|
||||
if ( !lua_istable( L, -2 ) || !lua_isnumber( L, -1 ) ) {
|
||||
if ( !lua_istable( L, 1 ) || !lua_isnumber( L, 2 ) ) {
|
||||
TraceLog( LOG_WARNING, "%s", "Bad call of function. RL.GenImageCellular( Vector2 size, int tileSize )" );
|
||||
lua_pushinteger( L, -1 );
|
||||
return 1;
|
||||
}
|
||||
int tileSize = lua_tointeger( L, -1 );
|
||||
lua_pop( L, 1 );
|
||||
Vector2 size = uluaGetVector2( L );
|
||||
|
||||
int i = newImage();
|
||||
*state->images[i] = GenImageCellular( (int)size.x, (int)size.y, tileSize );
|
||||
*state->images[i] = GenImageCellular( (int)size.x, (int)size.y, lua_tointeger( L, 2 ) );
|
||||
lua_pushinteger( L, i );
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
/*
|
||||
> image = RL.GenImageText( Vector2 size, string text )
|
||||
|
||||
Generate image: grayscale image from text data
|
||||
|
||||
- Failure return -1
|
||||
- Success return int
|
||||
*/
|
||||
int ltexturesGenImageText( lua_State *L ) {
|
||||
if ( !lua_istable( L, 1 ) || !lua_isstring( L, 2 ) ) {
|
||||
TraceLog( LOG_WARNING, "%s", "Bad call of function. RL.GenImageText( Vector2 size, string text )" );
|
||||
lua_pushinteger( L, -1 );
|
||||
return 1;
|
||||
}
|
||||
Vector2 size = uluaGetVector2Index( L, 1 );
|
||||
|
||||
int i = newImage();
|
||||
*state->images[i] = GenImageText( (int)size.x, (int)size.y, lua_tostring( L, 2 ) );
|
||||
lua_pushinteger( L, i );
|
||||
|
||||
return 1;
|
||||
@@ -488,12 +525,12 @@ Create an image duplicate ( useful for transformations )
|
||||
- Success return int
|
||||
*/
|
||||
int ltexturesImageCopy( lua_State *L ) {
|
||||
if ( !lua_isnumber( L, -1 ) ) {
|
||||
if ( !lua_isnumber( L, 1 ) ) {
|
||||
TraceLog( LOG_WARNING, "%s", "Bad call of function. RL.ImageCopy( Image image )" );
|
||||
lua_pushinteger( L, -1 );
|
||||
return 1;
|
||||
}
|
||||
size_t imageId = lua_tointeger( L, -1 );
|
||||
size_t imageId = lua_tointeger( L, 1 );
|
||||
|
||||
if ( !validImage( imageId ) ) {
|
||||
lua_pushinteger( L, -1 );
|
||||
@@ -515,14 +552,13 @@ Create an image from another image piece
|
||||
- Success return int
|
||||
*/
|
||||
int ltexturesImageFromImage( lua_State *L ) {
|
||||
if ( !lua_isnumber( L, -2 ) || !lua_istable( L, -1 ) ) {
|
||||
if ( !lua_isnumber( L, 1 ) || !lua_istable( L, 2 ) ) {
|
||||
TraceLog( LOG_WARNING, "%s", "Bad call of function. RL.ImageFromImage( Image image, Rectangle rec )" );
|
||||
lua_pushinteger( L, -1 );
|
||||
return 1;
|
||||
}
|
||||
Rectangle rec = uluaGetRectangle( L );
|
||||
lua_pop( L, 1 );
|
||||
size_t imageId = lua_tointeger( L, -1 );
|
||||
size_t imageId = lua_tointeger( L, 1 );
|
||||
Rectangle rec = uluaGetRectangleIndex( L, 2 );
|
||||
|
||||
if ( !validImage( imageId ) ) {
|
||||
lua_pushinteger( L, -1 );
|
||||
@@ -1941,16 +1977,14 @@ Draw a Texture2D
|
||||
- Success return true
|
||||
*/
|
||||
int ltexturesDrawTexture( lua_State *L ) {
|
||||
if ( !lua_isnumber( L, -3 ) || !lua_istable( L, -2 ) || !lua_istable( L, -1 ) ) {
|
||||
if ( !lua_isnumber( L, 1 ) || !lua_istable( L, 2 ) || !lua_istable( L, 3 ) ) {
|
||||
TraceLog( LOG_WARNING, "%s", "Bad call of function. RL.DrawTexture( Texture2D texture, Vector2 position, Color tint )" );
|
||||
lua_pushboolean( L, false );
|
||||
return 1;
|
||||
}
|
||||
Color color = uluaGetColor( L );
|
||||
lua_pop( L, 1 );
|
||||
Vector2 pos = uluaGetVector2( L );
|
||||
lua_pop( L, 1 );
|
||||
size_t texId = lua_tointeger( L, -1 );
|
||||
size_t texId = lua_tointeger( L, 1 );
|
||||
Vector2 pos = uluaGetVector2Index( L, 2 );
|
||||
Color color = uluaGetColorIndex( L, 3 );
|
||||
|
||||
if ( !validSourceTexture( texId ) ) {
|
||||
lua_pushboolean( L, false );
|
||||
@@ -1972,25 +2006,22 @@ Draw a part of a texture defined by a rectangle
|
||||
- Success return true
|
||||
*/
|
||||
int ltexturesDrawTextureRec( lua_State *L ) {
|
||||
if ( !lua_isnumber( L, -4 ) || !lua_istable( L, -3 ) || !lua_istable( L, -2 ) || !lua_istable( L, -1 ) ) {
|
||||
if ( !lua_isnumber( L, 1 ) || !lua_istable( L, 2 ) || !lua_istable( L, 3 ) || !lua_istable( L, 4 ) ) {
|
||||
TraceLog( LOG_WARNING, "%s", "Bad call of function. RL.DrawTextureRec( Texture2D texture, Rectangle source, Vector2 position, Color tint )" );
|
||||
lua_pushboolean( L, false );
|
||||
return 1;
|
||||
}
|
||||
Color color = uluaGetColor( L );
|
||||
lua_pop( L, 1 );
|
||||
Vector2 pos = uluaGetVector2( L );
|
||||
lua_pop( L, 1 );
|
||||
Rectangle srcRect = uluaGetRectangle( L );
|
||||
lua_pop( L, 1 );
|
||||
size_t texId = lua_tointeger( L, -1 );
|
||||
size_t texId = lua_tointeger( L, 1 );
|
||||
Rectangle srcRect = uluaGetRectangleIndex( L, 2 );
|
||||
Vector2 pos = uluaGetVector2Index( L, 3 );
|
||||
Color tint = uluaGetColorIndex( L, 4 );
|
||||
|
||||
if ( !validSourceTexture( texId ) ) {
|
||||
lua_pushboolean( L, false );
|
||||
return 1;
|
||||
}
|
||||
|
||||
DrawTextureRec( *texturesGetSourceTexture( texId ), srcRect, pos, color );
|
||||
DrawTextureRec( *texturesGetSourceTexture( texId ), srcRect, pos, tint );
|
||||
lua_pushboolean( L, true );
|
||||
|
||||
return 1;
|
||||
@@ -2005,23 +2036,18 @@ Draw a part of a texture defined by a rectangle with "pro" parameters
|
||||
- Success return true
|
||||
*/
|
||||
int ltexturesDrawTexturePro( lua_State *L ) {
|
||||
if ( !lua_isnumber( L, -6 ) || !lua_istable( L, -5 ) || !lua_istable( L, -4 )
|
||||
|| !lua_istable( L, -3 ) || !lua_isnumber( L, -2 ) || !lua_istable( L, -1 ) ) {
|
||||
if ( !lua_isnumber( L, 1 ) || !lua_istable( L, 2 ) || !lua_istable( L, 3 )
|
||||
|| !lua_istable( L, 4 ) || !lua_isnumber( L, 5 ) || !lua_istable( L, 6 ) ) {
|
||||
TraceLog( LOG_WARNING, "%s", "Bad call of function. RL.DrawTexturePro( Texture2D texture, Rectangle source, Rectangle dest, Vector2 origin, float rotation, Color tint )" );
|
||||
lua_pushboolean( L, false );
|
||||
return 1;
|
||||
}
|
||||
Color color = uluaGetColor( L );
|
||||
lua_pop( L, 1 );
|
||||
float rot = lua_tonumber( L, -1 );
|
||||
lua_pop( L, 1 );
|
||||
Vector2 origin = uluaGetVector2( L );
|
||||
lua_pop( L, 1 );
|
||||
Rectangle dstRect = uluaGetRectangle( L );
|
||||
lua_pop( L, 1 );
|
||||
Rectangle srcRect = uluaGetRectangle( L );
|
||||
lua_pop( L, 1 );
|
||||
size_t texId = lua_tointeger( L, -1 );
|
||||
size_t texId = lua_tointeger( L, 1 );
|
||||
Rectangle srcRect = uluaGetRectangleIndex( L, 2 );
|
||||
Rectangle dstRect = uluaGetRectangleIndex( L, 3 );
|
||||
Vector2 origin = uluaGetVector2Index( L, 4 );
|
||||
float rot = lua_tonumber( L, 5 );
|
||||
Color color = uluaGetColorIndex( L, 6 );
|
||||
|
||||
if ( !validSourceTexture( texId ) ) {
|
||||
lua_pushboolean( L, false );
|
||||
|
||||
Reference in New Issue
Block a user