Clears the screen or active Canvas to the specified color.
This function is called automatically before love.draw in the default love.run function. See the example in love.run for a typical use of this function.
Note that the scissor area bounds the cleared region.
In versions prior to 11.0, color component values were within the range of 0 to 255 instead of 0 to 1.
In versions prior to 0.10.0, this function clears the screen to the currently set background color instead.
Clears the screen to the background color in 0.9.2 and earlier, or to transparent black (0, 0, 0, 0) in LÖVE 0.10.0 and newer.
love.graphics.clear( )
None.
Nothing.
Available since LÖVE 0.10.0 |
This variant is not supported in earlier versions. |
Clears the screen or active Canvas to the specified color.
love.graphics.clear( r, g, b, a, clearstencil, cleardepth )
number r
number g
number b
number a (1)
boolean clearstencil (true)
boolean cleardepth (true)
Nothing.
Available since LÖVE 0.10.0 |
This variant is not supported in earlier versions. |
Clears multiple active Canvases to different colors, if multiple Canvases are active at once via love.graphics.setCanvas.
love.graphics.clear( color, ..., clearstencil, cleardepth )
table color
{r, g, b, a}
containing the color to clear the first active Canvas to.table ...
boolean clearstencil (true)
boolean cleardepth (true)
Nothing.
A color must be specified for each active Canvas, when this function variant is used.
Available since LÖVE 11.0 |
This variant is not supported in earlier versions. |
Clears the stencil or depth buffers without having to clear the color canvas as well.
love.graphics.clear( clearcolor, clearstencil, cleardepth )
boolean clearcolor
0, 0, 0, 0
). Typically this should be set to false with this variant of the function.boolean clearstencil
boolean cleardepth
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 love.graphics.clear() -- Clear the canvas before drawing lines. end -- Draw lines from the screen's origin to a random x and y coordinate. local rx, ry = love.math.random( 0, love.graphics.getWidth() ), love.math.random( 0, love.graphics.getHeight() ) love.graphics.setColor( love.math.random( ), 0, 0 ) love.graphics.line( 0, 0, rx, ry ) love.graphics.setColor( 1, 1, 1 ) end) end function love.draw() love.graphics.draw( canvas ) end function love.keypressed( key ) if key == "c" then clear = not clear end end