Difference between revisions of "love.graphics.captureScreenshot"

(Created page)
 
m (0.11.0 -> 11.0)
 
(4 intermediate revisions by one other user not shown)
Line 1: Line 1:
{{newin|[[0.11.0]]|110|type=function|This function replaces [[love.graphics.newScreenshot]].}}
+
{{newin|[[11.0]]|110|type=function|text=This function replaces [[love.graphics.newScreenshot]]}}
 
Creates a screenshot once the current frame is done (after [[love.draw]] has finished).
 
Creates a screenshot once the current frame is done (after [[love.draw]] has finished).
  
Since this function enqueues a screenshot capture, it can be called from an input callback or [[love.update]] and it will still capture all of what's drawn to the screen in that frame.
+
Since this function enqueues a screenshot capture rather than executing it immediately, it can be called from an input callback or [[love.update]] and it will still capture all of what's drawn to the screen in that frame.
  
 
{{notice|This function creates a new [[ImageData]] object and can cause love to slow down significantly if it's called every frame.}}
 
{{notice|This function creates a new [[ImageData]] object and can cause love to slow down significantly if it's called every frame.}}
Line 43: Line 43:
 
<source lang="lua">
 
<source lang="lua">
 
function love.load()
 
function love.load()
     love.filesystem.setIdentity('screenshot_example')
+
     love.filesystem.setIdentity("screenshot_example")
 
end
 
end
  
function love.keypressed()
+
function love.keypressed(key)
     love.graphics.captureScreenshot(os.time() .. ".png")
+
     if key == "c" then
 +
        love.graphics.captureScreenshot(os.time() .. ".png")
 +
    end
 +
end
 +
 
 +
function love.draw()
 +
    love.graphics.circle("fill", 400, 300, 200)
 
end
 
end
 
</source>
 
</source>

Latest revision as of 12:52, 29 December 2018

Available since LÖVE 11.0
This function replaces love.graphics.newScreenshot.

Creates a screenshot once the current frame is done (after love.draw has finished).

Since this function enqueues a screenshot capture rather than executing it immediately, it can be called from an input callback or love.update and it will still capture all of what's drawn to the screen in that frame.

O.png This function creates a new ImageData object and can cause love to slow down significantly if it's called every frame.  


Function

Capture a screenshot and save it to a file at the end of the current frame.

Synopsis

love.graphics.captureScreenshot( filename )

Arguments

string filename
The filename to save the screenshot to. The encoded image type is determined based on the extension of the filename, and must be one of the ImageFormats.

Returns

Nothing.

Function

Capture a screenshot and call a callback with the generated ImageData at the end of the current frame.

Synopsis

love.graphics.captureScreenshot( callback )

Arguments

function callback
Function which gets called once the screenshot has been captured. An ImageData is passed into the function as its only argument.

Returns

Nothing.

Function

Capture a screenshot and push the generated ImageData to a Channel at the end of the current frame.

Synopsis

love.graphics.captureScreenshot( channel )

Arguments

Channel channel
The Channel to push the generated ImageData to.

Returns

Nothing.

Examples

Create a new screenshot and write it to the save directory.

function love.load()
    love.filesystem.setIdentity("screenshot_example")
end

function love.keypressed(key)
    if key == "c" then
        love.graphics.captureScreenshot(os.time() .. ".png")
    end
end

function love.draw()
    love.graphics.circle("fill", 400, 300, 200)
end

See Also


Other Languages