aseprite/data/scripts/white_to_alpha.js

21 lines
470 B
JavaScript
Raw Normal View History

// Aseprite
2016-04-06 18:37:13 +00:00
// Copyright (C) 2015-2016 by David Capello
2016-04-06 18:37:13 +00:00
var col = app.pixelColor
var img = app.activeImage
2016-04-06 18:37:13 +00:00
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))
}
}