Skip to content

Instantly share code, notes, and snippets.

@oeloeloel
Last active July 2, 2021 20:41
Show Gist options
  • Save oeloeloel/afa9d36e8d39d71167a00a7b7fb27a2c to your computer and use it in GitHub Desktop.
Save oeloeloel/afa9d36e8d39d71167a00a7b7fb27a2c to your computer and use it in GitHub Desktop.
Remove specified background colour from sprite/spritesheet
# 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