Just thought I'd share my horizontal image reversing program I made. I've included a flaming horse image in it, so all you have to do is run the .love file. (But you can also specify your own image via the terminal) Here's the code:
function love.load(args)
data = love.image.newImageData(args[2] or 'flaming_horse.jpg')
half = {}
for x = 0, data:getWidth() / 2 - 1 do
half[x] = {}
for y = 0, data:getHeight() - 1 do
r, g, b, a = data:getPixel(x, y)
half[x][y] = { r, g, b, a }
end
end
data:mapPixel(function(x, y, r, g, b, a)
if x < data:getWidth() / 2 then
return data:getPixel(data:getWidth() - x - 1, y)
else
return unpack(half[data:getWidth() - x - 1][y])
end
end)
img = love.graphics.newImage(data)
img2 = love.graphics.newImage(args[2] or 'flaming_horse.jpg')
end
function love.draw()
love.graphics.draw(img)
love.graphics.draw(img2, 270)
end
Thanks. I honestly forgot about a negative scale, however I didn't do this for any purpose... apart from the desire to do some image manipulation. The main thing you could use this for, is reversing images for saving them, rather than displaying them.