aseprite/data/scripts/white_to_alpha.lua
2018-08-22 14:54:51 -03:00

18 lines
395 B
Lua

-- Aseprite
-- Copyright (C) 2015-2018 by David Capello
local pc = app.pixelColor
local img = app.activeImage
for y=0,img.height-1 do
for x=0,img.width-1 do
local c = img:getPixel(x, y)
local r = pc.rgbaR(c)
local g = pc.rgbaG(c)
local b = pc.rgbaB(c)
local a = pc.rgbaA(c)
if a > 0 then a = 255 - (r+g+b)/3 end
img:putPixel(x, y, pc.rgba(r, g, b, a))
end
end