{{newin|[[0.8.0]]|080|type=function|text=It has been renamed from [[Framebuffer:renderTo]]}}
Render to the [[Canvas]] using a function.

This is a shortcut to [[love.graphics.setCanvas]]:
<source lang="lua">
canvas:renderTo( func )
</source>
is the same as
<source lang="lua">
love.graphics.setCanvas( canvas )
func()
love.graphics.setCanvas()
</source>

== Function ==
=== Synopsis ===
<source lang="lua">
Canvas:renderTo( func )
</source>
=== Arguments ===
{{param|function|func|A function performing drawing operations.}}
=== Returns ===
Nothing.

== Examples ==
=== Using an anonymous function for drawing to a Canvas ===
This example randomly draws a bunch of red lines from the top left corner of the screen to the bottom.
<source lang="lua">
local canvas = love.graphics.newCanvas()
function love.update()
    canvas:renderTo(function()
        love.graphics.setColor(love.math.random(255), 0, 0);
        love.graphics.line(0, 0, love.math.random(0, love.graphics.getWidth()), love.math.random(0, love.graphics.getHeight()));
    end);
end

function love.draw()
    love.graphics.setColor(255, 255, 255);
    love.graphics.draw(canvas);
end
</source>

== See Also ==
* [[parent::Canvas]]
* [[love.graphics.setCanvas]]
[[Category:Functions]]
{{#set:Description=Render to a Canvas using a function.}}
== Other Languages ==
{{i18n|Canvas:renderTo}}