mirror of
https://github.com/aseprite/aseprite.git
synced 2024-12-26 09:19:27 +00:00
lua: Add possibility to compare two ImageSpec
This commit is contained in:
parent
259733e87d
commit
ee6b4d4d09
@ -1,4 +1,5 @@
|
||||
// Aseprite
|
||||
// Copyright (c) 2018 Igara Studio S.A.
|
||||
// Copyright (C) 2018 David Capello
|
||||
//
|
||||
// This program is distributed under the terms of
|
||||
@ -56,6 +57,14 @@ int ImageSpec_gc(lua_State* L)
|
||||
return 0;
|
||||
}
|
||||
|
||||
int ImageSpec_eq(lua_State* L)
|
||||
{
|
||||
auto a = get_obj<doc::ImageSpec>(L, 1);
|
||||
auto b = get_obj<doc::ImageSpec>(L, 2);
|
||||
lua_pushboolean(L, *a == *b);
|
||||
return 1;
|
||||
}
|
||||
|
||||
int ImageSpec_get_colorMode(lua_State* L)
|
||||
{
|
||||
const auto spec = get_obj<doc::ImageSpec>(L, 1);
|
||||
@ -114,6 +123,7 @@ int ImageSpec_set_transparentColor(lua_State* L)
|
||||
|
||||
const luaL_Reg ImageSpec_methods[] = {
|
||||
{ "__gc", ImageSpec_gc },
|
||||
{ "__eq", ImageSpec_eq },
|
||||
{ nullptr, nullptr }
|
||||
};
|
||||
|
||||
|
@ -60,6 +60,19 @@ namespace doc {
|
||||
m_height = sz.h;
|
||||
}
|
||||
|
||||
bool operator==(const ImageSpec& that) const {
|
||||
return (m_colorMode == that.m_colorMode &&
|
||||
m_width == that.m_width &&
|
||||
m_height == that.m_height &&
|
||||
m_maskColor == that.m_maskColor &&
|
||||
((!m_colorSpace && !that.m_colorSpace) ||
|
||||
(m_colorSpace && that.m_colorSpace &&
|
||||
m_colorSpace->nearlyEqual(*that.m_colorSpace))));
|
||||
}
|
||||
bool operator!=(const ImageSpec& that) const {
|
||||
return !operator==(that);
|
||||
}
|
||||
|
||||
private:
|
||||
ColorMode m_colorMode;
|
||||
int m_width;
|
||||
|
Loading…
Reference in New Issue
Block a user