Canvas:renderTo

Canvas:renderTo

Available since LÖVE 0.8.0
It has been renamed from Framebuffer:renderTo.

Render to the Canvas using a function.

This is a shortcut to love.graphics.setCanvas:

canvas:renderTo( func )

is the same as

love.graphics.setCanvas( canvas )
func()
love.graphics.setCanvas()

Function

Synopsis

Canvas:renderTo( func )

Arguments

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.

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

See Also

© 2006–2016 LÖVE Development Team
Licensed under the GNU Free Documentation License, Version 1.3.
https://love2d.org/wiki/Canvas:renderTo

在线笔记
App下载
App下载

扫描二维码

下载编程狮App

公众号
微信公众号

编程狮公众号

意见反馈
返回顶部