New raylib 5.5 functions.

This commit is contained in:
jussi
2024-11-21 00:11:31 +02:00
parent 479726a5e4
commit 4c0eb17a9c
22 changed files with 1121 additions and 187 deletions

View File

@@ -559,6 +559,19 @@ int lcoreGetClipboardText( lua_State* L ) {
return 1;
}
/*
> image = RL.GetClipboardImage()
Get clipboard image content
- Success return Image
*/
int lcoreGetClipboardImage( lua_State* L ) {
uluaPushImage( L, GetClipboardImage() );
return 1;
}
/*
> RL.EnableEventWaiting()
@@ -1782,6 +1795,60 @@ int lcoreGetApplicationDirectory( lua_State* L ) {
return 1;
}
/*
> success = RL.MakeDirectory( string dirPath )
Create directories (including full path requested), returns 0 on success
- Success return int
*/
int lcoreMakeDirectory( lua_State* L ) {
const char *dirPath = luaL_checkstring( L, 1 );
lua_pushinteger( L, MakeDirectory( dirPath ) );
return 1;
}
/*
> success = RL.ChangeDirectory( string directory )
Change working directory, return true on success
- Success return bool
*/
int lcoreChangeDirectory( lua_State* L ) {
lua_pushboolean( L, ChangeDirectory( luaL_checkstring( L, 1 ) ) );
return 1;
}
/*
> isFile = RL.IsPathFile( string path )
Check if a given path is a file or a directory
- Success return bool
*/
int lcoreIsPathFile( lua_State* L ) {
lua_pushboolean( L, IsPathFile( luaL_checkstring( L, 1 ) ) );
return 1;
}
/*
> isValid = RL.IsFileNameValid( string fileName )
Check if fileName is valid for the platform/OS
- Success return bool
*/
int lcoreIsFileNameValid( lua_State* L ) {
lua_pushboolean( L, IsFileNameValid( luaL_checkstring( L, 1 ) ) );
return 1;
}
/*
> fileNames = RL.LoadDirectoryFiles( string dirPath )
@@ -1831,32 +1898,6 @@ int lcoreLoadDirectoryFilesEx( lua_State* L ) {
return 1;
}
/*
> success = RL.ChangeDirectory( string directory )
Change working directory, return true on success
- Success return bool
*/
int lcoreChangeDirectory( lua_State* L ) {
lua_pushboolean( L, ChangeDirectory( luaL_checkstring( L, 1 ) ) );
return 1;
}
/*
> isFile = RL.IsPathFile( string path )
Check if a given path is a file or a directory
- Success return bool
*/
int lcoreIsPathFile( lua_State* L ) {
lua_pushboolean( L, IsPathFile( luaL_checkstring( L, 1 ) ) );
return 1;
}
/*
> iSFileDropped = RL.IsFileDropped()
@@ -1997,6 +2038,81 @@ int lcoreDecodeDataBase64( lua_State* L ) {
return 2;
}
/*
> code = RL.ComputeCRC32( Buffer data )
Compute CRC32 hash code. Note! Buffer should be type BUFFER_UNSIGNED_CHAR
- Failure return false
- Success return int
*/
int lcoreComputeCRC32( lua_State* L ) {
Buffer* buffer = uluaGetBuffer( L, 1 );
if ( buffer->type == BUFFER_UNSIGNED_CHAR ) {
lua_pushinteger( L, ComputeCRC32( buffer->data, buffer->size ) );
}
else {
lua_pushboolean( L, false );
}
return 1;
}
/*
> code = RL.ComputeMD5( Buffer data )
Compute MD5 hash code, returns static int[4] (16 bytes). Note! Buffer should be type BUFFER_UNSIGNED_CHAR
- Failure return false
- Success return int{4}
*/
int lcoreComputeMD5( lua_State* L ) {
Buffer* buffer = uluaGetBuffer( L, 1 );
if ( buffer->type == BUFFER_UNSIGNED_CHAR ) {
unsigned int* code = ComputeMD5( buffer->data, buffer->size );
lua_createtable( L, 4, 0 );
for ( unsigned int i = 0; i < 4; i++ ) {
lua_pushinteger( L, code[i] );
lua_rawseti( L, -2, i + 1 );
}
}
else {
lua_pushboolean( L, false );
}
return 1;
}
/*
> code = RL.ComputeSHA1( Buffer data )
Compute SHA1 hash code, returns static int[5] (20 bytes). Note! Buffer should be type BUFFER_UNSIGNED_CHAR
- Failure return false
- Success return int{5}
*/
int lcoreComputeSHA1( lua_State* L ) {
Buffer* buffer = uluaGetBuffer( L, 1 );
if ( buffer->type == BUFFER_UNSIGNED_CHAR ) {
unsigned int* code = ComputeSHA1( buffer->data, buffer->size );
lua_createtable( L, 5, 0 );
for ( unsigned int i = 0; i < 5; i++ ) {
lua_pushinteger( L, code[i] );
lua_rawseti( L, -2, i + 1 );
}
}
else {
lua_pushboolean( L, false );
}
return 1;
}
/*
## Core - Automation events functionality
*/
@@ -2490,6 +2606,22 @@ int lcoreSetGamepadMappings( lua_State* L ) {
return 1;
}
/*
> RL.SetGamepadVibration( int gamepad, float leftMotor, float rightMotor, float duration )
Set gamepad vibration for both motors (duration in seconds)
*/
int lcoreSetGamepadVibration( lua_State* L ) {
int gamepad = luaL_checkinteger( L, 1 );
float leftMotor = luaL_checknumber( L, 2 );
float rightMotor = luaL_checknumber( L, 2 );
float duration = luaL_checknumber( L, 2 );
SetGamepadVibration( gamepad, leftMotor, rightMotor, duration );
return 0;
}
/*
## Core - Input-related functions: mouse
*/

View File

@@ -16,7 +16,7 @@
#include "bitwiseOp.h"
#ifdef PLATFORM_DESKTOP
#include "platforms/core_desktop.c"
#include "platforms/core_desktop_glfw.c"
#elif PLATFORM_DESKTOP_SDL
#include "platforms/core_desktop_sdl.c"
#elif PLATFORM_WEB
@@ -1310,6 +1310,7 @@ void luaRegister() {
assingGlobalFunction( "GetMonitorName", lcoreGetMonitorName );
assingGlobalFunction( "SetClipboardText", lcoreSetClipboardText );
assingGlobalFunction( "GetClipboardText", lcoreGetClipboardText );
assingGlobalFunction( "GetClipboardImage", lcoreGetClipboardImage );
assingGlobalFunction( "EnableEventWaiting", lcoreEnableEventWaiting );
assingGlobalFunction( "DisableEventWaiting", lcoreDisableEventWaiting );
/* Cursor-related functions. */
@@ -1401,10 +1402,12 @@ void luaRegister() {
assingGlobalFunction( "GetPrevDirectoryPath", lcoreGetPrevDirectoryPath );
assingGlobalFunction( "GetWorkingDirectory", lcoreGetWorkingDirectory );
assingGlobalFunction( "GetApplicationDirectory", lcoreGetApplicationDirectory );
assingGlobalFunction( "LoadDirectoryFiles", lcoreLoadDirectoryFiles );
assingGlobalFunction( "LoadDirectoryFilesEx", lcoreLoadDirectoryFilesEx );
assingGlobalFunction( "MakeDirectory", lcoreMakeDirectory );
assingGlobalFunction( "ChangeDirectory", lcoreChangeDirectory );
assingGlobalFunction( "IsPathFile", lcoreIsPathFile );
assingGlobalFunction( "IsFileNameValid", lcoreIsFileNameValid );
assingGlobalFunction( "LoadDirectoryFiles", lcoreLoadDirectoryFiles );
assingGlobalFunction( "LoadDirectoryFilesEx", lcoreLoadDirectoryFilesEx );
assingGlobalFunction( "IsFileDropped", lcoreIsFileDropped );
assingGlobalFunction( "LoadDroppedFiles", lcoreLoadDroppedFiles );
assingGlobalFunction( "GetFileModTime", lcoreGetFileModTime );
@@ -1413,6 +1416,9 @@ void luaRegister() {
assingGlobalFunction( "DecompressData", lcoreDecompressData );
assingGlobalFunction( "EncodeDataBase64", lcoreEncodeDataBase64 );
assingGlobalFunction( "DecodeDataBase64", lcoreDecodeDataBase64 );
assingGlobalFunction( "ComputeCRC32", lcoreComputeCRC32 );
assingGlobalFunction( "ComputeMD5", lcoreComputeMD5 );
assingGlobalFunction( "ComputeSHA1", lcoreComputeSHA1 );
/* Automation events functionality. */
assingGlobalFunction( "LoadAutomationEventList", lcoreLoadAutomationEventList );
assingGlobalFunction( "UnloadAutomationEventList", lcoreUnloadAutomationEventList );
@@ -1448,6 +1454,7 @@ void luaRegister() {
assingGlobalFunction( "GetGamepadAxisCount", lcoreGetGamepadAxisCount );
assingGlobalFunction( "GetGamepadAxisMovement", lcoreGetGamepadAxisMovement );
assingGlobalFunction( "SetGamepadMappings", lcoreSetGamepadMappings );
assingGlobalFunction( "SetGamepadVibration", lcoreSetGamepadVibration );
/* Input-related functions: mouse. */
assingGlobalFunction( "IsMouseButtonPressed", lcoreIsMouseButtonPressed );
assingGlobalFunction( "IsMouseButtonDown", lcoreIsMouseButtonDown );
@@ -1531,6 +1538,8 @@ void luaRegister() {
/* Shapes. */
/* Basic shapes drawing functions. */
assingGlobalFunction( "SetShapesTexture", lshapesSetShapesTexture );
assingGlobalFunction( "GetShapesTexture", lshapesGetShapesTexture );
assingGlobalFunction( "GetShapesTextureRectangle", lshapesGetShapesTextureRectangle );
assingGlobalFunction( "DrawPixel", lshapesDrawPixel );
assingGlobalFunction( "DrawLine", lshapesDrawLine );
assingGlobalFunction( "DrawLineBezier", lshapesDrawLineBezier );
@@ -1582,6 +1591,7 @@ void luaRegister() {
assingGlobalFunction( "CheckCollisionRecs", lshapesCheckCollisionRecs );
assingGlobalFunction( "CheckCollisionCircles", lshapesCheckCollisionCircles );
assingGlobalFunction( "CheckCollisionCircleRec", lshapesCheckCollisionCircleRec );
assingGlobalFunction( "CheckCollisionCircleLine", lshapesCheckCollisionCircleLine );
assingGlobalFunction( "CheckCollisionPointRec", lshapesCheckCollisionPointRec );
assingGlobalFunction( "CheckCollisionPointCircle", lshapesCheckCollisionPointCircle );
assingGlobalFunction( "CheckCollisionPointTriangle", lshapesCheckCollisionPointTriangle );
@@ -1595,6 +1605,7 @@ void luaRegister() {
assingGlobalFunction( "LoadImage", ltexturesLoadImage );
assingGlobalFunction( "LoadImageRaw", ltexturesLoadImageRaw );
assingGlobalFunction( "LoadImageAnim", ltexturesLoadImageAnim );
assingGlobalFunction( "LoadImageAnimFromMemory", ltexturesLoadImageAnimFromMemory );
assingGlobalFunction( "LoadImageFromMemory", ltexturesLoadImageFromMemory );
assingGlobalFunction( "LoadImageFromData", ltexturesLoadImageFromData );
assingGlobalFunction( "LoadImageFromTexture", ltexturesLoadImageFromTexture );
@@ -1617,6 +1628,7 @@ void luaRegister() {
/* Image manipulation functions. */
assingGlobalFunction( "ImageCopy", ltexturesImageCopy );
assingGlobalFunction( "ImageFromImage", ltexturesImageFromImage );
assingGlobalFunction( "ImageFromChannel", ltexturesImageFromChannel );
assingGlobalFunction( "ImageText", ltexturesImageText );
assingGlobalFunction( "ImageTextEx", ltexturesImageTextEx );
assingGlobalFunction( "ImageFormat", ltexturesImageFormat );
@@ -1627,6 +1639,7 @@ void luaRegister() {
assingGlobalFunction( "ImageAlphaMask", ltexturesImageAlphaMask );
assingGlobalFunction( "ImageAlphaPremultiply", ltexturesImageAlphaPremultiply );
assingGlobalFunction( "ImageBlurGaussian", ltexturesImageBlurGaussian );
assingGlobalFunction( "ImageKernelConvolution", ltexturesImageKernelConvolution );
assingGlobalFunction( "ImageResize", ltexturesImageResize );
assingGlobalFunction( "ImageResizeNN", ltexturesImageResizeNN );
assingGlobalFunction( "ImageResizeCanvas", ltexturesImageResizeCanvas );
@@ -1656,10 +1669,16 @@ void luaRegister() {
assingGlobalFunction( "ImageClearBackground", ltexturesImageClearBackground );
assingGlobalFunction( "ImageDrawPixel", ltexturesImageDrawPixel );
assingGlobalFunction( "ImageDrawLine", ltexturesImageDrawLine );
assingGlobalFunction( "ImageDrawLineEx", ltexturesImageDrawLineEx );
assingGlobalFunction( "ImageDrawCircle", ltexturesImageDrawCircle );
assingGlobalFunction( "ImageDrawCircleLines", ltexturesImageDrawCircleLines );
assingGlobalFunction( "ImageDrawRectangle", ltexturesImageDrawRectangle );
assingGlobalFunction( "ImageDrawRectangleLines", ltexturesImageDrawRectangleLines );
assingGlobalFunction( "ImageDrawTriangle", ltexturesImageDrawTriangle );
assingGlobalFunction( "ImageDrawTriangleEx", ltexturesImageDrawTriangleEx );
assingGlobalFunction( "ImageDrawTriangleLines", ltexturesImageDrawTriangleLines );
assingGlobalFunction( "ImageDrawTriangleFan", ltexturesImageDrawTriangleFan );
assingGlobalFunction( "ImageDrawTriangleStrip", ltexturesImageDrawTriangleStrip );
assingGlobalFunction( "ImageDraw", ltexturesImageDraw );
assingGlobalFunction( "ImageDrawText", ltexturesImageDrawText );
assingGlobalFunction( "ImageDrawTextEx", ltexturesImageDrawTextEx );
@@ -1697,6 +1716,7 @@ void luaRegister() {
assingGlobalFunction( "GetRenderTextureTexture", ltexturesGetRenderTextureTexture );
assingGlobalFunction( "GetRenderTextureDepthTexture", ltexturesGetRenderTextureDepthTexture );
/* Color/pixel related functions */
assingGlobalFunction( "ColorIsEqual", ltexturesColorIsEqual );
assingGlobalFunction( "Fade", ltexturesFade );
assingGlobalFunction( "ColorToInt", ltexturesColorToInt );
assingGlobalFunction( "ColorNormalize", ltexturesColorNormalize );
@@ -1708,6 +1728,7 @@ void luaRegister() {
assingGlobalFunction( "ColorContrast", ltexturesColorContrast );
assingGlobalFunction( "ColorAlpha", ltexturesColorAlpha );
assingGlobalFunction( "ColorAlphaBlend", ltexturesColorAlphaBlend );
assingGlobalFunction( "ColorLerp", ltexturesColorLerp );
assingGlobalFunction( "GetColor", ltexturesGetColor );
assingGlobalFunction( "GetPixelDataSize", ltexturesGetPixelDataSize );
@@ -1759,6 +1780,8 @@ void luaRegister() {
assingGlobalFunction( "DrawModelEx", lmodelsDrawModelEx );
assingGlobalFunction( "DrawModelWires", lmodelsDrawModelWires );
assingGlobalFunction( "DrawModelWiresEx", lmodelsDrawModelWiresEx );
assingGlobalFunction( "DrawModelPoints", lmodelsDrawModelPoints );
assingGlobalFunction( "DrawModelPointsEx", lmodelsDrawModelPointsEx );
assingGlobalFunction( "DrawBoundingBox", lmodelsDrawBoundingBox );
assingGlobalFunction( "DrawBillboard", lmodelsDrawBillboard );
assingGlobalFunction( "DrawBillboardRec", lmodelsDrawBillboardRec );
@@ -1770,6 +1793,7 @@ void luaRegister() {
assingGlobalFunction( "DrawMeshInstanced", lmodelsDrawMeshInstanced );
assingGlobalFunction( "SetMeshColor", lmodelsSetMeshColor );
assingGlobalFunction( "ExportMesh", lmodelsExportMesh );
assingGlobalFunction( "ExportMeshAsCode", lmodelsExportMeshAsCode );
assingGlobalFunction( "GetMeshBoundingBox", lmodelsGetMeshBoundingBox );
assingGlobalFunction( "GenMeshTangents", lmodelsGenMeshTangents );
assingGlobalFunction( "GetMeshData", lmodelsGetMeshData );
@@ -1806,6 +1830,7 @@ void luaRegister() {
/* Model animations management functions. */
assingGlobalFunction( "LoadModelAnimations", lmodelsLoadModelAnimations );
assingGlobalFunction( "UpdateModelAnimation", lmodelsUpdateModelAnimation );
assingGlobalFunction( "UpdateModelAnimationBones", lmodelsUpdateModelAnimationBones );
assingGlobalFunction( "UnloadModelAnimation", lmodelsUnloadModelAnimation );
assingGlobalFunction( "UnloadModelAnimations", lmodelsUnloadModelAnimations );
assingGlobalFunction( "IsModelAnimationValid", lmodelsIsModelAnimationValid );
@@ -1891,6 +1916,8 @@ void luaRegister() {
assingGlobalFunction( "TextSplit", ltextTextSplit );
assingGlobalFunction( "TextFindIndex", ltextTextFindIndex );
assingGlobalFunction( "TextToPascal", ltextTextToPascal );
assingGlobalFunction( "TextToSnake", ltextTextToSnake );
assingGlobalFunction( "TextToCamel", ltextTextToCamel );
/* Audio. */
/* Audio device management functions. */
@@ -3423,6 +3450,17 @@ AutomationEventList* uluaGetAutomationEventList( lua_State* L, int index ) {
}
}
void getVector2Array( lua_State* L, int index, Vector2 points[] ) {
int t = index, i = 0;
lua_pushnil( L );
while ( lua_next( L, t ) != 0 ) {
points[i] = uluaGetVector2( L, lua_gettop( L ) );
i++;
lua_pop( L, 1 );
}
}
/* Push types. */
void uluaPushColor( lua_State* L, Color color ) {

View File

@@ -982,6 +982,40 @@ int lmodelsDrawModelWiresEx( lua_State* L ) {
return 0;
}
/*
> RL.DrawModelPoints( Model model, Vector3 position, float scale, Color tint )
Draw a model as points
*/
int lmodelsDrawModelPoints( lua_State* L ) {
Model* model = uluaGetModel( L, 1 );
Vector3 position = uluaGetVector3( L, 2 );
float scale = luaL_checknumber( L, 3 );
Color tint = uluaGetColor( L, 4 );
DrawModelPoints( *model, position, scale, tint );
return 0;
}
/*
> RL.DrawModelPointsEx( Model model, Vector3 position, Vector3 rotationAxis, float rotationAngle, Vector3 scale, Color tint )
Draw a model as points with extended parameters
*/
int lmodelsDrawModelPointsEx( lua_State* L ) {
Model* model = uluaGetModel( L, 1 );
Vector3 position = uluaGetVector3( L, 2 );
Vector3 rotationAxis = uluaGetVector3( L, 3 );
float rotationAngle = luaL_checknumber( L, 4 );
Vector3 scale = uluaGetVector3( L, 5 );
Color tint = uluaGetColor( L, 6 );
DrawModelPointsEx( *model, position, rotationAxis, rotationAngle, scale, tint );
return 0;
}
/*
> RL.DrawBoundingBox( BoundingBox box, Color color )
@@ -1286,6 +1320,21 @@ int lmodelsExportMesh( lua_State* L ) {
return 1;
}
/*
> success = RL.ExportMeshAsCode( Mesh mesh, string fileName )
Export mesh as code file (.h) defining multiple arrays of vertex attributes
- Success return bool
*/
int lmodelsExportMeshAsCode( lua_State* L ) {
Mesh* mesh = uluaGetMesh( L, 1 );
lua_pushboolean( L, ExportMeshAsCode( *mesh, luaL_checkstring( L, 2 ) ) );
return 1;
}
/*
> boundingBox = RL.GetMeshBoundingBox( Mesh mesh )
@@ -2190,6 +2239,21 @@ int lmodelsUpdateModelAnimation( lua_State* L ) {
return 0;
}
/*
> RL.UpdateModelAnimationBones( Model model, ModelAnimation animation, int frame )
Update model animation mesh bone matrices (GPU skinning)
*/
int lmodelsUpdateModelAnimationBones( lua_State* L ) {
Model* model = uluaGetModel( L, 1 );
ModelAnimation* animation = uluaGetModelAnimation( L, 2 );
int frame = luaL_checkinteger( L, 3 );
UpdateModelAnimationBones( *model, *animation, frame );
return 0;
}
/*
> RL.UnloadModelAnimation( ModelAnimation animation )

View File

@@ -4,17 +4,6 @@
#include "lua_core.h"
#include "textures.h"
static inline void getVector2Array( lua_State* L, int index, Vector2 points[] ) {
int t = index, i = 0;
lua_pushnil( L );
while ( lua_next( L, t ) != 0 ) {
points[i] = uluaGetVector2( L, lua_gettop( L ) );
i++;
lua_pop( L, 1 );
}
}
/*
## Shapes - Basic shapes drawing functions
*/
@@ -30,11 +19,39 @@ int lshapesSetShapesTexture( lua_State* L ) {
Texture* texture = uluaGetTexture( L, 1 );
Rectangle source = uluaGetRectangle( L, 2 );
state->shapesTexture = *texture;
SetShapesTexture( *texture, source );
return 0;
}
/*
> texture = RL.GetShapesTexture()
Get texture that is used for shapes drawing. Return as lightuserdata
- Success return Texture
*/
int lshapesGetShapesTexture( lua_State* L ) {
lua_pushlightuserdata( L, &state->shapesTexture );
return 1;
}
/*
> source = RL.GetShapesTextureRectangle()
Get texture source rectangle that is used for shapes drawing
- Success return Rectangle
*/
int lshapesGetShapesTextureRectangle( lua_State* L ) {
uluaPushRectangle( L, GetShapesTextureRectangle() );
return 1;
}
/*
> RL.DrawPixel( Vector2 pos, Color color )
@@ -874,6 +891,24 @@ int lshapesCheckCollisionCircleRec( lua_State* L ) {
return 1;
}
/*
> collision = RL.CheckCollisionCircleLine( Vector2 center, float radius, Vector2 p1, Vector2 p2 )
Check if circle collides with a line created betweeen two points [p1] and [p2]
- Success return bool
*/
int lshapesCheckCollisionCircleLine( lua_State* L ) {
Vector2 center = uluaGetVector2( L, 1 );
float radius = luaL_checknumber( L, 2 );
Vector2 p1 = uluaGetVector2( L, 3 );
Vector2 p2 = uluaGetVector2( L, 4 );
lua_pushboolean( L, CheckCollisionCircleLine( center, radius, p1, p2 ) );
return 1;
}
/*
> collision = RL.CheckCollisionPointRec( Vector2 point, Rectangle rec )

View File

@@ -35,6 +35,7 @@ bool stateInit( int argn, const char** argc, const char* basePath ) {
state->guiFont = GuiGetFont();
state->defaultMaterial = LoadMaterialDefault();
state->defaultTexture = (Texture){ 1, 1, 1, 1, 7 };
state->shapesTexture = (Texture){ 1, 1, 1, 1, 7 };
state->RLGLcurrentShaderLocs = malloc( RL_MAX_SHADER_LOCATIONS * sizeof( int ) );
int* defaultShaderLocs = rlGetShaderLocsDefault();

View File

@@ -1242,3 +1242,33 @@ int ltextTextToPascal( lua_State* L ) {
return 1;
}
/*
> text = RL.TextToSnake( string text )
Get Snake case notation version of provided string
- Success return string
*/
int ltextTextToSnake( lua_State* L ) {
const char* text = luaL_checkstring( L, 1 );
lua_pushstring( L, TextToSnake( text ) );
return 1;
}
/*
> text = RL.TextToCamel( string text )
Get Camel case notation version of provided string
- Success return string
*/
int ltextTextToCamel( lua_State* L ) {
const char* text = luaL_checkstring( L, 1 );
lua_pushstring( L, TextToCamel( text ) );
return 1;
}

View File

@@ -77,6 +77,24 @@ int ltexturesLoadImageAnim( lua_State* L ) {
return 1;
}
/*
> image, frameCount = RL.LoadImageAnimFromMemory( string fileType, Buffer fileData )
Load image sequence from memory buffer. All frames are returned in RGBA format
- Success return Image, int
*/
int ltexturesLoadImageAnimFromMemory( lua_State* L ) {
const char* fileType = luaL_checkstring( L, 1 );
Buffer* buffer = uluaGetBuffer( L, 2 );
int frameCount = 0;
uluaPushImage( L, LoadImageAnimFromMemory( fileType, buffer->data, buffer->size, &frameCount ) );
lua_pushinteger( L, frameCount );
return 2;
}
/*
> image, frameCount = RL.LoadImageFromMemory( string fileType, Buffer data )
@@ -417,6 +435,22 @@ int ltexturesImageFromImage( lua_State* L ) {
return 1;
}
/*
> image = RL.ImageFromChannel( Image image, int selectedChannel )
Create an image from a selected channel of another image (GRAYSCALE)
- Success return Image
*/
int ltexturesImageFromChannel( lua_State* L ) {
Image* image = uluaGetImage( L, 1 );
int selectedChannel = luaL_checkinteger( L, 2 );
uluaPushImage( L, ImageFromChannel( *image, selectedChannel ) );
return 1;
}
/*
> image = RL.ImageText( string text, int fontSize, Color tint )
@@ -565,6 +599,32 @@ int ltexturesImageBlurGaussian( lua_State* L ) {
return 0;
}
/*
> RL.ImageKernelConvolution( Image image, float{} kernel )
Apply custom square convolution kernel to image
*/
int ltexturesImageKernelConvolution( lua_State* L ) {
Image* image = uluaGetImage( L, 1 );
int kernelSize = uluaGetTableLen( L, 2 );
float kernel[ kernelSize ];
int t = lua_gettop( L );
int i = 0;
lua_pushnil( L );
while ( lua_next( L, t ) != 0 ) {
kernel[i] = lua_tonumber( L, -1 );
i++;
lua_pop( L, 1 );
}
ImageKernelConvolution( image, kernel, kernelSize );
return 0;
}
/*
> RL.ImageResize( Image image, Vector2 size )
@@ -971,7 +1031,7 @@ int ltexturesImageDrawPixel( lua_State* L ) {
}
/*
> RL.ImageDrawLine( Image dst, Vector2 a, Vector2 b, Color color )
> RL.ImageDrawLine( Image dst, Vector2 start, Vector2 end, Color color )
Draw line within an image
*/
@@ -986,6 +1046,23 @@ int ltexturesImageDrawLine( lua_State* L ) {
return 0;
}
/*
> RL.ImageDrawLineEx( Image dst, Vector2 start, Vector2 end, int thick, Color color )
Draw a line defining thickness within an image
*/
int ltexturesImageDrawLineEx( lua_State* L ) {
Image* image = uluaGetImage( L, 1 );
Vector2 start = uluaGetVector2( L, 2 );
Vector2 end = uluaGetVector2( L, 3 );
int thick = luaL_checkinteger( L, 4 );
Color color = uluaGetColor( L, 5 );
ImageDrawLineEx( image, start, end, thick, color );
return 0;
}
/*
> RL.ImageDrawCircle( Image dst, Vector2 center, int radius, Color color )
@@ -1049,6 +1126,93 @@ int ltexturesImageDrawRectangleLines( lua_State* L ) {
return 0;
}
/*
> RL.ImageDrawTriangle( Image *dst, Vector2 v1, Vector2 v2, Vector2 v3, Color color )
Draw triangle within an image
*/
int ltexturesImageDrawTriangle( lua_State* L ) {
Image* image = uluaGetImage( L, 1 );
Vector2 v1 = uluaGetVector2( L, 2 );
Vector2 v2 = uluaGetVector2( L, 3 );
Vector2 v3 = uluaGetVector2( L, 4 );
Color color = uluaGetColor( L, 5 );
ImageDrawTriangle( image, v1, v2, v3, color );
return 0;
}
/*
> RL.ImageDrawTriangleEx( Image *dst, Vector2 v1, Vector2 v2, Vector2 v3, Color c1, Color c2, Color c3 )
Draw triangle with interpolated colors within an image
*/
int ltexturesImageDrawTriangleEx( lua_State* L ) {
Image* image = uluaGetImage( L, 1 );
Vector2 v1 = uluaGetVector2( L, 2 );
Vector2 v2 = uluaGetVector2( L, 3 );
Vector2 v3 = uluaGetVector2( L, 4 );
Color c1 = uluaGetColor( L, 5 );
Color c2 = uluaGetColor( L, 6 );
Color c3 = uluaGetColor( L, 7 );
ImageDrawTriangleEx( image, v1, v2, v3, c1, c2, c3 );
return 0;
}
/*
> RL.ImageDrawTriangleLines( Image *dst, Vector2 v1, Vector2 v2, Vector2 v3, Color color )
Draw triangle outline within an image
*/
int ltexturesImageDrawTriangleLines( lua_State* L ) {
Image* image = uluaGetImage( L, 1 );
Vector2 v1 = uluaGetVector2( L, 2 );
Vector2 v2 = uluaGetVector2( L, 3 );
Vector2 v3 = uluaGetVector2( L, 4 );
Color color = uluaGetColor( L, 5 );
ImageDrawTriangleLines( image, v1, v2, v3, color );
return 0;
}
/*
> RL.ImageDrawTriangleFan( Image *dst, Vector2{} points, Color color )
Draw a triangle fan defined by points within an image (first vertex is the center)
*/
int ltexturesImageDrawTriangleFan( lua_State* L ) {
Image* image = uluaGetImage( L, 1 );
int pointCount = uluaGetTableLen( L, 2 );
Vector2 points[ pointCount ];
getVector2Array( L, 2, points );
Color color = uluaGetColor( L, 3 );
ImageDrawTriangleFan( image, points, pointCount, color );
return 0;
}
/*
> RL.ImageDrawTriangleStrip( Image *dst, Vector2{} points, Color color )
Draw a triangle strip defined by points within an image
*/
int ltexturesImageDrawTriangleStrip( lua_State* L ) {
Image* image = uluaGetImage( L, 1 );
int pointCount = uluaGetTableLen( L, 2 );
Vector2 points[ pointCount ];
getVector2Array( L, 2, points );
Color color = uluaGetColor( L, 3 );
ImageDrawTriangleStrip( image, points, pointCount, color );
return 0;
}
/*
> RL.ImageDraw( Image dst, Image src, Rectangle srcRec, Rectangle dstRec, Color tint )
@@ -1855,6 +2019,22 @@ int ltexturesGetRenderTextureDepthTexture( lua_State* L ) {
## Textures - Color/pixel related functions
*/
/*
> isEqual = RL.ColorIsEqual( Color col1, Color col2 )
Check if two colors are equal
- Success return bool
*/
int ltexturesColorIsEqual( lua_State* L ) {
Color col1 = uluaGetColor( L, 1 );
Color col2 = uluaGetColor( L, 2 );
lua_pushboolean( L, ColorIsEqual( col1, col2 ) );
return 1;
}
/*
> color = RL.Fade( Color color, float alpha )
@@ -2029,6 +2209,23 @@ int ltexturesColorAlphaBlend( lua_State* L ) {
return 1;
}
/*
> color = RL.ColorLerp( Color color1, Color color2, float factor )
Get color lerp interpolation between two colors, factor [0.0f..1.0f]
- Success return Color
*/
int ltexturesColorLerp( lua_State* L ) {
Color color1 = uluaGetColor( L, 1 );
Color color2 = uluaGetColor( L, 2 );
float factor = luaL_checknumber( L, 3 );
uluaPushColor( L, ColorLerp( color1, color2, factor ) );
return 1;
}
/*
> color = RL.GetColor( int hexValue )