diff options
| -rw-r--r-- | API.md | 16 | ||||
| -rw-r--r-- | ReiLua_API.lua | 26 | ||||
| -rw-r--r-- | changelog | 1 | ||||
| -rw-r--r-- | devnotes | 1 | ||||
| -rw-r--r-- | include/textures.h | 1 | ||||
| -rw-r--r-- | src/lua_core.c | 1 | ||||
| -rw-r--r-- | src/textures.c | 28 |
7 files changed, 54 insertions, 20 deletions
@@ -7398,6 +7398,12 @@ Get image pixel color at (x, y) position --- +> RL.SetImageData( Image image, Buffer data ) + +Set image data from Buffer + +--- + > imageData = RL.GetImageData( Image image ) Get image data as Buffer @@ -7482,31 +7488,31 @@ Draw rectangle lines within an image --- -> RL.ImageDrawTriangle( Image *dst, Vector2 v1, Vector2 v2, Vector2 v3, Color color ) +> RL.ImageDrawTriangle( Image dst, Vector2 v1, Vector2 v2, Vector2 v3, Color color ) Draw triangle within an image --- -> RL.ImageDrawTriangleEx( Image *dst, Vector2 v1, Vector2 v2, Vector2 v3, Color c1, Color c2, Color c3 ) +> RL.ImageDrawTriangleEx( Image dst, Vector2 v1, Vector2 v2, Vector2 v3, Color c1, Color c2, Color c3 ) Draw triangle with interpolated colors within an image --- -> RL.ImageDrawTriangleLines( Image *dst, Vector2 v1, Vector2 v2, Vector2 v3, Color color ) +> RL.ImageDrawTriangleLines( Image dst, Vector2 v1, Vector2 v2, Vector2 v3, Color color ) Draw triangle outline within an image --- -> RL.ImageDrawTriangleFan( Image *dst, Vector2{} points, Color color ) +> RL.ImageDrawTriangleFan( Image dst, Vector2{} points, Color color ) Draw a triangle fan defined by points within an image (first vertex is the center) --- -> RL.ImageDrawTriangleStrip( Image *dst, Vector2{} points, Color color ) +> RL.ImageDrawTriangleStrip( Image dst, Vector2{} points, Color color ) Draw a triangle strip defined by points within an image diff --git a/ReiLua_API.lua b/ReiLua_API.lua index 0d21202..e9c37a6 100644 --- a/ReiLua_API.lua +++ b/ReiLua_API.lua @@ -3914,6 +3914,12 @@ function RL.GetImageColor( image, pixelPos ) end -- Textures - Image configuration functions +---Set image data from Buffer +---@param image any +---@param data any +---@return any RL.SetImageData +function RL.SetImageData( image, data ) end + ---Get image data as Buffer ---- Success return Buffer ---@param image any @@ -4002,16 +4008,16 @@ function RL.ImageDrawRectangle( dst, rec, color ) end function RL.ImageDrawRectangleLines( dst, rec, thick, color ) end ---Draw triangle within an image ----@param *dst any +---@param dst any ---@param v1 table ---@param v2 table ---@param v3 table ---@param color table ---@return any RL.ImageDrawTriangle -function RL.ImageDrawTriangle( *dst, v1, v2, v3, color ) end +function RL.ImageDrawTriangle( dst, v1, v2, v3, color ) end ---Draw triangle with interpolated colors within an image ----@param *dst any +---@param dst any ---@param v1 table ---@param v2 table ---@param v3 table @@ -4019,30 +4025,30 @@ function RL.ImageDrawTriangle( *dst, v1, v2, v3, color ) end ---@param c2 table ---@param c3 table ---@return any RL.ImageDrawTriangleEx -function RL.ImageDrawTriangleEx( *dst, v1, v2, v3, c1, c2, c3 ) end +function RL.ImageDrawTriangleEx( dst, v1, v2, v3, c1, c2, c3 ) end ---Draw triangle outline within an image ----@param *dst any +---@param dst any ---@param v1 table ---@param v2 table ---@param v3 table ---@param color table ---@return any RL.ImageDrawTriangleLines -function RL.ImageDrawTriangleLines( *dst, v1, v2, v3, color ) end +function RL.ImageDrawTriangleLines( dst, v1, v2, v3, color ) end ---Draw a triangle fan defined by points within an image (first vertex is the center) ----@param *dst any +---@param dst any ---@param points table ---@param color table ---@return any RL.ImageDrawTriangleFan -function RL.ImageDrawTriangleFan( *dst, points, color ) end +function RL.ImageDrawTriangleFan( dst, points, color ) end ---Draw a triangle strip defined by points within an image ----@param *dst any +---@param dst any ---@param points table ---@param color table ---@return any RL.ImageDrawTriangleStrip -function RL.ImageDrawTriangleStrip( *dst, points, color ) end +function RL.ImageDrawTriangleStrip( dst, points, color ) end ---Draw a source image within a destination image (Tint applied to source) ---@param dst any @@ -45,6 +45,7 @@ DETAILED CHANGES: - ADDED: SDL3 Events. - ADDED: Fast tilemap example. - ADDED: RectPack using stbrp_pack_rects. Atlas packer tutorial. + - ADDED: SetImageData. ------------------------------------------------------------------------ Release: ReiLua version 0.8.0 Using Raylib 5.0 and Forked Raygui 4.0 @@ -1,4 +1,5 @@ Current { + * Check if DrawTextBoxedEx works correctly. } Backlog { diff --git a/include/textures.h b/include/textures.h index 9f71ba0..46da5ff 100644 --- a/include/textures.h +++ b/include/textures.h @@ -60,6 +60,7 @@ int ltexturesLoadImagePalette( lua_State* L ); int ltexturesGetImageAlphaBorder( lua_State* L ); int ltexturesGetImageColor( lua_State* L ); /* Image configuration functions. */ +int ltexturesSetImageData( lua_State* L ); int ltexturesGetImageData( lua_State* L ); int ltexturesGetImageSize( lua_State* L ); int ltexturesGetImageMipmaps( lua_State* L ); diff --git a/src/lua_core.c b/src/lua_core.c index 29a6bf8..e29b2ee 100644 --- a/src/lua_core.c +++ b/src/lua_core.c @@ -1916,6 +1916,7 @@ void luaRegister() { assingGlobalFunction( "GetImageAlphaBorder", ltexturesGetImageAlphaBorder ); assingGlobalFunction( "GetImageColor", ltexturesGetImageColor ); /* Image configuration functions. */ + assingGlobalFunction( "SetImageData", ltexturesSetImageData ); assingGlobalFunction( "GetImageData", ltexturesGetImageData ); assingGlobalFunction( "GetImageSize", ltexturesGetImageSize ); assingGlobalFunction( "GetImageMipmaps", ltexturesGetImageMipmaps ); diff --git a/src/textures.c b/src/textures.c index 89b6e8f..b6ddcb7 100644 --- a/src/textures.c +++ b/src/textures.c @@ -3,6 +3,7 @@ #include "textures.h" #include "text.h" #include "lua_core.h" +#include "rmath.h" /* ## Textures - Image loading functions @@ -931,6 +932,23 @@ int ltexturesGetImageColor( lua_State* L ) { */ /* +> RL.SetImageData( Image image, Buffer data ) + +Set image data from Buffer +*/ +int ltexturesSetImageData( lua_State* L ) { + Image* image = uluaGetImage( L, 1 ); + Buffer* data = uluaGetBuffer( L, 2 ); + + memcpy( image->data, data->data, imin( + GetPixelDataSize( image->width, image->height, image->format ), + data->size + ) ); + + return 0; +} + +/* > imageData = RL.GetImageData( Image image ) Get image data as Buffer @@ -1127,7 +1145,7 @@ int ltexturesImageDrawRectangleLines( lua_State* L ) { } /* -> RL.ImageDrawTriangle( Image *dst, Vector2 v1, Vector2 v2, Vector2 v3, Color color ) +> RL.ImageDrawTriangle( Image dst, Vector2 v1, Vector2 v2, Vector2 v3, Color color ) Draw triangle within an image */ @@ -1144,7 +1162,7 @@ int ltexturesImageDrawTriangle( lua_State* L ) { } /* -> RL.ImageDrawTriangleEx( Image *dst, Vector2 v1, Vector2 v2, Vector2 v3, Color c1, Color c2, Color c3 ) +> RL.ImageDrawTriangleEx( Image dst, Vector2 v1, Vector2 v2, Vector2 v3, Color c1, Color c2, Color c3 ) Draw triangle with interpolated colors within an image */ @@ -1163,7 +1181,7 @@ int ltexturesImageDrawTriangleEx( lua_State* L ) { } /* -> RL.ImageDrawTriangleLines( Image *dst, Vector2 v1, Vector2 v2, Vector2 v3, Color color ) +> RL.ImageDrawTriangleLines( Image dst, Vector2 v1, Vector2 v2, Vector2 v3, Color color ) Draw triangle outline within an image */ @@ -1180,7 +1198,7 @@ int ltexturesImageDrawTriangleLines( lua_State* L ) { } /* -> RL.ImageDrawTriangleFan( Image *dst, Vector2{} points, Color color ) +> RL.ImageDrawTriangleFan( Image dst, Vector2{} points, Color color ) Draw a triangle fan defined by points within an image (first vertex is the center) */ @@ -1197,7 +1215,7 @@ int ltexturesImageDrawTriangleFan( lua_State* L ) { } /* -> RL.ImageDrawTriangleStrip( Image *dst, Vector2{} points, Color color ) +> RL.ImageDrawTriangleStrip( Image dst, Vector2{} points, Color color ) Draw a triangle strip defined by points within an image */ |
