aseprite/data/scripts/white_to_alpha.js
David Capello bcf7efc9bb Replace duktape with mujs
Added other classes like Rectangle, Size, and Point.
2017-08-11 17:22:28 -03:00

21 lines
478 B
JavaScript

// Aseprite
// Copyright (C) 2015-2017 by David Capello
var col = app.pixelColor
var img = app.activeImage
for (var y=0; y<img.height; ++y) {
for (var 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))
}
}