diff options
| author | jussi | 2024-11-21 00:11:31 +0200 |
|---|---|---|
| committer | jussi | 2024-11-21 00:11:31 +0200 |
| commit | 4c0eb17a9c234bfee73af408faa38e38f2e450d9 (patch) | |
| tree | 4aea4fe804a63ed13a1d092aada0ba5925dcf05f /src/textures.c | |
| parent | 479726a5e468a2f4d0f9337f082889082e535bfb (diff) | |
| download | reilua-enhanced-4c0eb17a9c234bfee73af408faa38e38f2e450d9.tar.gz reilua-enhanced-4c0eb17a9c234bfee73af408faa38e38f2e450d9.tar.bz2 reilua-enhanced-4c0eb17a9c234bfee73af408faa38e38f2e450d9.zip | |
New raylib 5.5 functions.
Diffstat (limited to 'src/textures.c')
| -rw-r--r-- | src/textures.c | 199 |
1 files changed, 198 insertions, 1 deletions
diff --git a/src/textures.c b/src/textures.c index d571a32..eaf2284 100644 --- a/src/textures.c +++ b/src/textures.c @@ -78,6 +78,24 @@ int ltexturesLoadImageAnim( lua_State* L ) { } /* +> 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 ) Load image from memory buffer, fileType refers to extension: i.e. '.png' @@ -418,6 +436,22 @@ int ltexturesImageFromImage( lua_State* L ) { } /* +> 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 ) Create an image from text (default font) @@ -566,6 +600,32 @@ int ltexturesImageBlurGaussian( lua_State* L ) { } /* +> 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 ) Resize image (Bicubic scaling algorithm) @@ -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 */ @@ -987,6 +1047,23 @@ int ltexturesImageDrawLine( lua_State* L ) { } /* +> 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 ) Draw circle within an image @@ -1050,6 +1127,93 @@ int ltexturesImageDrawRectangleLines( lua_State* L ) { } /* +> 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 ) Draw a source image within a destination image (Tint applied to source) @@ -1856,6 +2020,22 @@ int ltexturesGetRenderTextureDepthTexture( lua_State* L ) { */ /* +> 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 ) Returns color with alpha applied, alpha goes from 0.0f to 1.0f @@ -2030,6 +2210,23 @@ int ltexturesColorAlphaBlend( lua_State* L ) { } /* +> 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 ) Get Color structure from hexadecimal value |
