Difference between revisions of "(Image):refresh"

(Edited example to involve less unnecessary concepts)
(Added new sub-rectangle variant in 0.10.0.)
Line 10: Line 10:
 
=== Returns ===
 
=== Returns ===
 
Nothing.
 
Nothing.
 +
 +
== Function ==
 +
{{newin|[[0.10.0]]|100|type=variant}}
 +
=== Synopsis ===
 +
<source lang="lua">
 +
Image:refresh( x, y, width, height )
 +
</source>
 +
=== Arguments ===
 +
{{param|number|x|The x-axis of the top-left corner of the area within the Image to reload.}}
 +
{{param|number|y|The y-axis of the top-left corner of the area within the Image to reload.}}
 +
{{param|number|width|The width of the area within the Image to reload.}}
 +
{{param|number|height|The height of the area within the Image to reload.}}
  
 
== Examples ==
 
== Examples ==

Revision as of 08:33, 24 November 2015

Available since LÖVE 0.9.0
This function is not supported in earlier versions.

Reloads the Image's contents from the ImageData or CompressedData used to create the image.

Function

Synopsis

Image:refresh( )

Arguments

None.

Returns

Nothing.

Function

Available since LÖVE 0.10.0
This variant is not supported in earlier versions.

Synopsis

Image:refresh( x, y, width, height )

Arguments

number x
The x-axis of the top-left corner of the area within the Image to reload.
number y
The y-axis of the top-left corner of the area within the Image to reload.
number width
The width of the area within the Image to reload.
number height
The height of the area within the Image to reload.

Examples

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:refresh()
    end
end

See Also

Other Languages