Available since LÖVE 0.8.0 and removed in LÖVE 0.10.0
It has been replaced by love.graphics.clear.
Clears the contents of a Canvas to a specific color.
Calling this function directly after the Canvas becomes active (via love.graphics.setCanvas or Canvas:renderTo) is more efficient than calling it when the Canvas isn't active, especially on mobile devices.
love.graphics.setScissor will restrict the area of the Canvas that this function affects.
Clear the canvas to transparent black: (0, 0, 0, 0).
Canvas:clear( )
None.
Nothing.
Clear the canvas to a specific color.
Canvas:clear( red, green, blue, alpha )
number red
number green
number blue
number alpha (255)
Nothing.
Canvas:clear( rgba )
table rgba
Nothing.
If the c-key is pressed the canvas will be cleared before drawing a new line on the screen.
local canvas = love.graphics.newCanvas() local clear function love.update() -- Use an anonymous function to draw lines on our canvas. canvas:renderTo(function() if clear then canvas:clear() end -- Clear the canvas before drawing lines. 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 function love.keypressed(key) if key == "c" then clear = not clear end end
© 2006–2016 LÖVE Development Team
Licensed under the GNU Free Documentation License, Version 1.3.
https://love2d.org/wiki/Canvas:clear