summaryrefslogtreecommitdiff
path: root/source/modules/asura-core/graphics/binding/_image.cpp
diff options
context:
space:
mode:
authorchai <chaifix@163.com>2019-03-31 14:34:40 +0800
committerchai <chaifix@163.com>2019-03-31 14:34:40 +0800
commitfb7ae1149a80a22c77014d0ece33f6f4b965b631 (patch)
tree41540b0962be735204eb50eef54bd30e9184234a /source/modules/asura-core/graphics/binding/_image.cpp
parent8164adb15b76f537f8b6c78b9992786b61d61cc8 (diff)
*misc
Diffstat (limited to 'source/modules/asura-core/graphics/binding/_image.cpp')
-rw-r--r--source/modules/asura-core/graphics/binding/_image.cpp51
1 files changed, 33 insertions, 18 deletions
diff --git a/source/modules/asura-core/graphics/binding/_image.cpp b/source/modules/asura-core/graphics/binding/_image.cpp
index 1d43067..cc9a669 100644
--- a/source/modules/asura-core/graphics/binding/_image.cpp
+++ b/source/modules/asura-core/graphics/binding/_image.cpp
@@ -9,6 +9,8 @@ namespace AsuraEngine
LUAX_REGISTRY(Image)
{
+ LUAX_INHERIT(state, Texture);
+
LUAX_REGISTER_METHODS(state,
{ "New", _New },
{ "Refresh", _Refresh },
@@ -22,55 +24,68 @@ namespace AsuraEngine
LUAX_POSTPROCESS(Image)
{
-
}
- // Image.New()
+ // image = Image.New()
LUAX_IMPL_METHOD(Image, _New)
{
LUAX_STATE(L);
-
- return 0;
+ Image* img = new Image();
+ img->PushLuaxUserdata(state);
+ return 1;
}
- // image:Refresh()
+ // successed = image:Refresh(imgData)
LUAX_IMPL_METHOD(Image, _Refresh)
{
LUAX_PREPARE(L, Image);
-
- return 0;
+ ImageData* imgData = state.CheckUserdata<ImageData>(2);
+ bool successed = self->Refresh(imgData);
+ if (successed)
+ self->SetLuaxMemberRef(state, self->mImageDataRef, 2);
+ state.Push(successed);
+ return 1;
}
- // image:GetWidth()
+ // width = image:GetWidth()
LUAX_IMPL_METHOD(Image, _GetWidth)
{
LUAX_PREPARE(L, Image);
-
- return 0;
+ state.Push(self->GetWidth());
+ return 1;
}
- // image:GetHeight()
+ // height = image:GetHeight()
LUAX_IMPL_METHOD(Image, _GetHeight)
{
LUAX_PREPARE(L, Image);
-
- return 0;
+ state.Push(self->GetHeight());
+ return 1;
}
- // image:GetSize()
+ // width, height = image:GetSize()
LUAX_IMPL_METHOD(Image, _GetSize)
{
LUAX_PREPARE(L, Image);
-
- return 0;
+ int width = self->GetWidth();
+ int height = self->GetHeight();
+ state.Push(width);
+ state.Push(height);
+ return 2;
}
- // image:GetPixel()
+ // color32 = image:GetPixel(x, y)
LUAX_IMPL_METHOD(Image, _GetPixel)
{
LUAX_PREPARE(L, Image);
- return 0;
+ uint x, y;
+ x = state.CheckValue<uint>(2);
+ y = state.CheckValue<uint>(3);
+ Color32* c32 = new Color32();
+ c32->Set(self->GetPixel(x, y));
+ c32->PushLuaxUserdata(state);
+ return 1;
}
// image:Render()