Last active
July 2, 2021 20:41
-
-
Save oeloeloel/afa9d36e8d39d71167a00a7b7fb27a2c to your computer and use it in GitHub Desktop.
Remove specified background colour from sprite/spritesheet
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
# cromakey no chromakey | |
# removes a specified background colour from a spritesheet | |
# by making it transparent and exports it as a new file. | |
# change these values then run in DragonRuby | |
# path to spritesheet | |
INPUT_FILE = '/sprites/chroma-test-input.png' | |
# path to export file | |
OUTPUT_FILE = '/sprites/chroma-test-output.png' | |
# background color to make transparent | |
CHROMA_COLOR = {r: 69, g: 114, b: 227} | |
def tick args | |
wh = args.gtk.calcspritebox(INPUT_FILE) | |
rect = { | |
x: 0, y: 60, | |
w: wh[0], h: wh[1] | |
} | |
args.outputs.primitives << { | |
path: INPUT_FILE | |
}.merge(rect).sprite | |
return if args.tick_count > 1 | |
args.outputs.screenshots << { | |
path: OUTPUT_FILE, | |
a: 0 | |
}.merge(rect).merge(CHROMA_COLOR) | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment