Add new layer detection to keep colors mapped correctly.
This commit is contained in:
parent
ec8e131829
commit
0ed105d355
5 changed files with 78 additions and 49 deletions
|
@ -1,4 +1,28 @@
|
|||
-- Functions for modifying a sprite
|
||||
|
||||
local BASE_COLOR = Color {
|
||||
r = 0,
|
||||
g = 0,
|
||||
b = 0,
|
||||
a = 0
|
||||
}
|
||||
local IGNORE_COLOR = Color {
|
||||
gray = 100
|
||||
}
|
||||
local IGNORE_SUBCOLOR = Color {
|
||||
gray = 150
|
||||
}
|
||||
local MERGE_COLOR = Color {
|
||||
r = 200,
|
||||
g = 200,
|
||||
b = 0
|
||||
}
|
||||
local MERGE_SUBCOLOR = Color {
|
||||
r = 200,
|
||||
g = 200,
|
||||
b = 128
|
||||
}
|
||||
|
||||
-- Deletes any layers with the 'ignored' property.
|
||||
local function deleteLayers(spr, layers)
|
||||
for i, layer in ipairs(layers) do
|
||||
|
@ -44,9 +68,35 @@ local function revealLayers(layers)
|
|||
end
|
||||
end
|
||||
|
||||
-- set the color of a layer and its sublayers
|
||||
local function setColor(layer, subColor)
|
||||
if (layer.properties(extKey).ignored) then
|
||||
layer.color = IGNORE_COLOR
|
||||
subColor = IGNORE_SUBCOLOR
|
||||
elseif subColor == IGNORE_SUBCOLOR then
|
||||
layer.color = subColor
|
||||
elseif (layer.properties(extKey).exportedAsSprite) then
|
||||
layer.color = MERGE_COLOR
|
||||
subColor = MERGE_SUBCOLOR
|
||||
elseif subColor == MERGE_SUBCOLOR then
|
||||
layer.color = subColor
|
||||
else
|
||||
layer.color = BASE_COLOR
|
||||
end
|
||||
|
||||
if (layer.isGroup) then
|
||||
for i, sublayer in ipairs(layer.layers) do
|
||||
setColor(sublayer, subColor)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
|
||||
local export = {
|
||||
deleteLayers = deleteLayers,
|
||||
flattenLayers = flattenLayers,
|
||||
revealLayers = revealLayers
|
||||
revealLayers = revealLayers,
|
||||
setColor = setColor,
|
||||
}
|
||||
return export
|
Loading…
Add table
Add a link
Reference in a new issue