summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--html/examples/render_cd_bgalpha.lua27
-rw-r--r--include/imlua.h2
2 files changed, 29 insertions, 0 deletions
diff --git a/html/examples/render_cd_bgalpha.lua b/html/examples/render_cd_bgalpha.lua
new file mode 100644
index 0000000..3cbcff9
--- /dev/null
+++ b/html/examples/render_cd_bgalpha.lua
@@ -0,0 +1,27 @@
+require"imlua"
+require"cdlua"
+require"cdluaim"
+
+local image = im.ImageCreate(500, 500, im.RGB, im.BYTE)
+image:AddAlpha()
+local canvas = image:cdCreateCanvas() -- Creates a CD_IMAGERGB canvas
+
+canvas:Activate()
+
+-- Use SetBackground instead of Background to avoid conflict with cd.QUERY
+canvas:SetBackground(cd.EncodeAlpha(cd.EncodeColor(255, 255, 255), 0)) -- full transparent white
+canvas:Clear()
+
+fgcolor = cd.EncodeAlpha(cd.EncodeColor(255, 0, 0), 50) -- semi transparent red
+canvas:Foreground(fgcolor)
+canvas:Font("Times", cd.BOLD, 24)
+canvas:Text(100, 100, "Test")
+canvas:Line(0,0,100,100)
+
+fgcolor = cd.EncodeColor(0, 0, 255)
+canvas:Foreground(fgcolor)
+canvas:Line(0,50,150,50)
+
+canvas:Kill()
+
+image:Save("new.png", "PNG")
diff --git a/include/imlua.h b/include/imlua.h
index bc07cca..ad61889 100644
--- a/include/imlua.h
+++ b/include/imlua.h
@@ -34,6 +34,7 @@ void imlua_open(void);
int imlua_open(lua_State *L);
int luaopen_imlua(lua_State *L);
+#ifdef __IM_IMAGE_H /* must include im_image.h before this */
/** Pushes an image as a metatable on the stack.
* \ingroup imlua */
void imlua_pushimage(lua_State *L, imImage* image);
@@ -41,6 +42,7 @@ void imlua_pushimage(lua_State *L, imImage* image);
/** Gets an image as a metatable from the stack, checks for correct type.
* \ingroup imlua */
imImage* imlua_checkimage(lua_State *L, int param);
+#endif
/** Initializes the Lua binding of the capture library. \n
* Returns 1 (leaves the "im" table on the top of the stack).