aseprite/data/scripts/white_to_alpha.js
David Capello 956349f87b Add Image class to scripting
With this change we introduce SpriteWrap and ImageWrap to keep track
of modifications made by the script in one transaction. So we can undo
the script action as one simple action.
2016-04-06 19:05:06 -03:00

21 lines
470 B
JavaScript

// Aseprite
// Copyright (C) 2015-2016 by David Capello
var col = app.pixelColor
var img = app.activeImage
for (y=0; y<img.height; ++y) {
for (x=0; x<img.width; ++x) {
var c = img.getPixel(x, y)
var v = (col.rgbaR(c)+
col.rgbaG(c)+
col.rgbaB(c))/3
img.putPixel(x, y,
col.rgba(col.rgbaR(c),
col.rgbaG(c),
col.rgbaB(c),
255-v))
}
}