Created
March 26, 2023 17:44
-
-
Save snrn-Pontus/ba590b3f966bdd4e3b5784dfd14410ee to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
-- Description: Duplicate a sprite and replace black with 3 different colors | |
function createSheet(data, numberOfVariants) | |
local sourceSprite = app.activeSprite | |
local sourceImage = app.activeCel.image | |
Sprite(sourceSprite.width * numberOfVariants, sourceSprite.height) | |
local outputImage = app.activeCel.image | |
for i = 0, numberOfVariants do | |
app.command.ReplaceColor { | |
ui = false, | |
from = Color(0, 0, 0), | |
to = data["color_" .. i], | |
tolerance = 0 | |
} | |
outputImage:drawImage(sourceImage, sourceSprite.width * i, 0) | |
end | |
app.refresh() | |
end | |
local data = { | |
color_0 = Color(255, 0, 0), | |
color_1 = Color(0, 255, 0), | |
color_2 = Color(0, 0, 255), | |
} | |
createSheet(data, 3) | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment