Available since LÖVE 11.0
This function replaces Image:refresh.
Replace the contents of an Image.
Image:replacePixels( data, slice, mipmap, x, y, reloadmipmaps )
ImageData datanumber slicenumber mipmap (1)number x (0)number y (0)boolean reloadmipmapsNothing.
function love.load()
imagedata = love.image.newImageData("pig.png")
image = love.graphics.newImage(imagedata)
end
function love.draw()
love.graphics.draw(image)
end
function love.keypressed(key)
if key == "e" then
-- Modify the original ImageData and apply the changes to the Image.
imagedata:mapPixel(function(x, y, r, g, b, a) return r/2, g/2, b/2, a/2 end)
image:replacePixels(imagedata)
end
end
© 2006–2020 LÖVE Development Team
Licensed under the GNU Free Documentation License, Version 1.3.
https://love2d.org/wiki/(Image):replacePixels