diff --git a/src/app/color.cpp b/src/app/color.cpp index a8fdd97b5..aa6867a8e 100644 --- a/src/app/color.cpp +++ b/src/app/color.cpp @@ -893,6 +893,9 @@ doc::tile_t Color::getTile() const { switch (getType()) { + case Color::IndexType: + return m_value.index; + case Color::TileType: return m_value.tile; @@ -929,6 +932,9 @@ int Color::getAlpha() const return 0; } + case Color::TileType: + return 255; + } ASSERT(false); diff --git a/src/app/script/color_class.cpp b/src/app/script/color_class.cpp index a77744e20..b83451e56 100644 --- a/src/app/script/color_class.cpp +++ b/src/app/script/color_class.cpp @@ -1,5 +1,5 @@ // Aseprite -// Copyright (C) 2019-2022 Igara Studio S.A. +// Copyright (C) 2019-2023 Igara Studio S.A. // Copyright (C) 2018 David Capello // // This program is distributed under the terms of @@ -145,6 +145,16 @@ app::Color Color_new(lua_State* L, int index) } else lua_pop(L, 1); + + // Convert { tile } into a Color + if (lua_getfield(L, index, "tile") != LUA_TNIL) { + tile_t t = lua_tointeger(L, -1); + color = app::Color::fromTile(t); + lua_pop(L, 1); + return color; + } + else + lua_pop(L, 1); } // raw color into app color else if (!lua_isnone(L, index)) { diff --git a/tests/scripts/tilemap.lua b/tests/scripts/tilemap.lua index 37efe6706..80bee88b6 100644 --- a/tests/scripts/tilemap.lua +++ b/tests/scripts/tilemap.lua @@ -228,7 +228,7 @@ do app.useTool{ tool='pencil', - color=Color{ index=1 }, + color=Color{ index=1 }, -- We can use a Color{ index } to paint tiles too tilemapMode=TilemapMode.TILES, tilesetMode=TilesetMode.STACK, points={ Point(0, 16) }} -- y=16 is the first pixel of 3rd row of tiles @@ -240,7 +240,7 @@ do app.useTool{ tool='pencil', - color=Color{ index=1 }, + color=Color{ tile=1 }, -- Color{ tile } is the new constructor to paint tiles + flags tilemapMode=TilemapMode.TILES, tilesetMode=TilesetMode.STACK, points={ Point(0, 0), Point(16, 0) }} -- x=16 is the first pixel of 3rd column of tiles @@ -255,7 +255,7 @@ do expect_eq(Point{ 10, 8 }, cel.position) app.useTool{ tool='pencil', - color=Color{ index=0 }, + color=Color{ tile=0 }, tilemapMode=TilemapMode.TILES, tilesetMode=TilesetMode.STACK, points={ { 10, 8 }, { 18, 16 } }} -- {10,8} is the first existent tile in the tilemap @@ -268,7 +268,7 @@ do app.useTool{ tool='pencil', - color=Color{ index=1 }, + color=Color{ tile=1 }, tilemapMode=TilemapMode.TILES, tilesetMode=TilesetMode.STACK, points={ Point(1, 7), Point(2, 8) }} -- Tile 0,0 and 1,1