I would like my little miner and the rocks without brown, just on a the grass.
Should I use:
- PixelEffect ? viewtopic.php?f=4&t=10112&hilit=transparent -> I don't understand how I could do what I want
- Convert my PNG's to 8 bit colors and replace brown (6A4C30) by alpha: How could I do this in a batch? I have too many files to do this one by one
Yes. You need to use a PNG with transparency. Löve doesn't have the "use a specific color as a transparent mask" feature that I know of. We just use PNG's with transparent backgrounds. Convert all your images now. And get used to using transparency in the future. I haven't used a colored mask since my DOOM editing days. Soooo much magenta!!!
I'd also like to point out that PNGs allows for partial transparency on the alpha channel, which can make your borders look better (unless you are going for a "pixelated" effect, of course)
local function loadTransparent(imagePath, transR, transG, transB)
local imageData = love.graphics.newImageData( imagePath )
local function mapFunction(r,g,b,a)
if r == transR and g == transG and b == trangB then a = 0 end
return r,g,b,a
end
imageData:mapPixel( mapFunction )
return love.graphics.newImage( ImageData )
end
Can remove backfround using pixel effects (much faster than mapPixel) but as pointed out before the results will most likely be unsatisfactory because of how the image was originally created (edge shading).
As always, best to start with quality rather than trying to patch.
function loadTransparent(imagePath, transR, transG, transB)
imageData = love.image.newImageData( imagePath )
function mapFunction(x, y, r, g, b, a)
if r == transR and g == transG and b == transB then a = 0 end
return r,g,b,a
end
imageData:mapPixel( mapFunction )
return love.graphics.newImage( imageData )
end