{{newinoldin|[[0.8.0]]|080|[[0.10.0]]|100|type=function|text=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.
== Function ==
Clear the canvas to transparent black: (0, 0, 0, 0).
=== Synopsis ===
<source lang="lua">
Canvas:clear( )
</source>
=== Arguments ===
None.
=== Returns ===
Nothing.

== Function ==
Clear the canvas to a specific color.
=== Synopsis ===
<source lang="lua">
Canvas:clear( red, green, blue, alpha )
</source>
=== Arguments ===
{{param|number|red|Red component of the clear color (0-255).}}
{{param|number|green|Green component of the clear color (0-255).}}
{{param|number|blue|Blue component of the clear color (0-255).}}
{{param|number|alpha (255)|Alpha component of the clear color (0-255).}}
=== Returns ===
Nothing.

== Function ==
=== Synopsis ===
<source lang="lua">
Canvas:clear( rgba )
</source>
=== Arguments ===
{{param|table|rgba|A [[sequence]] with the red, green, blue and alpha values as numbers (alpha may be ommitted).}}
=== Returns ===
Nothing.

== Examples ==
=== Clear canvas before drawing ===
If the c-key is pressed the canvas will be cleared before drawing a new line on the screen.
<source lang="lua">
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
</source>

== See Also ==
* [[parent::Canvas]]
[[Category:Functions]]
{{#set:Description=Clears the contents of a Canvas to a specific color.}}
== Other Languages ==
{{i18n|Canvas:clear}}