mirror of
https://github.com/aseprite/aseprite.git
synced 2025-01-16 13:14:44 +00:00
lua: the Color(integer) ctor behavior will depend on the active color mode
This commit is contained in:
parent
fdac96153b
commit
be8f026b91
@ -8,6 +8,7 @@
|
||||
#include "config.h"
|
||||
#endif
|
||||
|
||||
#include "app/app.h"
|
||||
#include "app/color.h"
|
||||
#include "app/color_utils.h"
|
||||
#include "app/script/luacpp.h"
|
||||
@ -138,10 +139,21 @@ Color Color_new(lua_State* L, int index)
|
||||
else if (!lua_isnone(L, index)) {
|
||||
if (lua_isinteger(L, index) && lua_isnone(L, index+1)) {
|
||||
doc::color_t docColor = lua_tointeger(L, index);
|
||||
color = app::Color::fromRgb(doc::rgba_getr(docColor),
|
||||
doc::rgba_getg(docColor),
|
||||
doc::rgba_getb(docColor),
|
||||
doc::rgba_geta(docColor));
|
||||
switch (app_get_current_pixel_format()) {
|
||||
case IMAGE_RGB:
|
||||
color = app::Color::fromRgb(doc::rgba_getr(docColor),
|
||||
doc::rgba_getg(docColor),
|
||||
doc::rgba_getb(docColor),
|
||||
doc::rgba_geta(docColor));
|
||||
break;
|
||||
case IMAGE_GRAYSCALE:
|
||||
color = app::Color::fromGray(doc::graya_getv(docColor),
|
||||
doc::graya_geta(docColor));
|
||||
break;
|
||||
case IMAGE_INDEXED:
|
||||
color = app::Color::fromIndex(docColor);
|
||||
break;
|
||||
}
|
||||
}
|
||||
else {
|
||||
color = app::Color::fromRgb(lua_tointeger(L, index),
|
||||
|
Loading…
Reference in New Issue
Block a user