Texture:replacePixels
Available since LÖVE 12.0 |
This function replaces Image:replacePixels. |
Replace the contents of a Texture with the contents of the given ImageData.
Function
Synopsis
Texture:replacePixels( data, slice, mipmap, x, y, reloadmipmaps )
Arguments
ImageData data
- The new ImageData to replace the contents with.
number slice (nil)
- Which cubemap face, array index, or volume layer to replace, if applicable; the value is ignored otherwise.
number mipmap (1)
- The mimap level to replace, if the Texture has mipmaps.
number x (0)
- The x-offset in pixels from the top-left of the texture to replace. The given ImageData's width plus this value must not be greater than the pixel width of the Texture's specified mipmap level.
number y (0)
- The y-offset in pixels from the top-left of the texture to replace. The given ImageData's height plus this value must not be greater than the pixel height of the Texture's specified mipmap level.
boolean reloadmipmaps (true/false)
- Whether to generate new mipmaps after replacing the Texture's pixels. True by default if the Texture was created with automatically generated mipmaps, false by default otherwise.
Returns
Nothing.
Examples
function love.load()
imagedata = love.image.newImageData("pig.png")
texture = love.graphics.newImage(imagedata)
end
function love.draw()
love.graphics.draw(texture)
end
function love.keypressed(key)
if key == "e" then
-- Modify the original ImageData and apply the changes to the Texture.
imagedata:mapPixel(function(x, y, r, g, b, a) return r/2, g/2, b/2, a/2 end)
texture:replacePixels(imagedata)
end
end
See Also
Other Languages
Dansk –
Deutsch –
English –
Español –
Français –
Indonesia –
Italiano –
Lietuviškai –
Magyar –
Nederlands –
Polski –
Português –
Română –
Slovenský –
Suomi –
Svenska –
Türkçe –
Česky –
Ελληνικά –
Български –
Русский –
Српски –
Українська –
עברית –
ไทย –
日本語 –
正體中文 –
简体中文 –
Tiếng Việt –
한국어
More info