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 [[love.graphics.setScissor|scissor area]] bounds the cleared region.

バージョン [[11.0 (日本語)|11.0]] まで、色成分値は 0 〜 1 (小数値) ではなく 0 〜 255 (整数値) の範囲内です。

In versions prior to [[0.10.0]], this function clears the screen to the currently set [[love.graphics.setBackgroundColor|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.
=== 概要 ===
<source lang="lua">
love.graphics.clear( )
</source>
=== 引数 ===
なし。
=== 返値 ===
ありません。

== 関数 ==
{{newin (日本語)|[[0.10.0 (日本語)|0.10.0]]|100|type=異形}}
Clears the screen or active [[Canvas]] to the specified color.
=== 概要 ===
<source lang="lua">
love.graphics.clear( r, g, b, a, clearstencil, cleardepth )
</source>
=== 引数 ===
{{param (日本語)|number|r|The red channel of the color to clear the screen to.}}
{{param (日本語)|number|g|The green channel of the color to clear the screen to.}}
{{param (日本語)|number|b|The blue channel of the color to clear the screen to.}}
{{param (日本語)|number|a (1)|The alpha channel of the color to clear the screen to.}}
{{New feature (日本語)|11.0|
{{param (日本語)|boolean|clearstencil (true)|Whether to clear the active stencil buffer, [[love.graphics.setCanvas|if present]]. It can also be an integer between 0 and 255 to clear the stencil buffer to a specific value.}}
{{param (日本語)|boolean|cleardepth (true)|Whether to clear the active depth buffer, [[love.graphics.setCanvas|if present]]. It can also be a number between 0 and 1 to clear the depth buffer to a specific value.}}
}}

=== 返値 ===
ありません。

== 関数 ==
{{newin (日本語)|[[0.10.0 (日本語)|0.10.0]]|100|type=異形}}
Clears multiple active [[Canvas]]es to different colors, if multiple Canvases are active at once via [[love.graphics.setCanvas]].
=== 概要 ===
<source lang="lua">
love.graphics.clear( color, ..., clearstencil, cleardepth )
</source>
=== 引数 ===
{{param (日本語)|table|color|A table in the form of <code>{r, g, b, a}</code> containing the color to clear the first active Canvas to.}}
{{param (日本語)|table|...|Additional tables for each active Canvas.}}
{{New feature (日本語)|11.0|
{{param (日本語)|boolean|clearstencil (true)|Whether to clear the active stencil buffer, [[love.graphics.setCanvas|if present]]. It can also be an integer between 0 and 255 to clear the stencil buffer to a specific value.}}
{{param (日本語)|boolean|cleardepth (true)|Whether to clear the active depth buffer, [[love.graphics.setCanvas|if present]]. It can also be a number between 0 and 1 to clear the depth buffer to a specific value.}}
}}
=== 返値 ===
ありません。
=== 注釈 ===
A color must be specified for each active Canvas, when this function variant is used.

== 関数 ==
{{newin (日本語)|[[11.0 (日本語)|11.0]]|110|type=異形}}
Clears the stencil or depth buffers without having to clear the color canvas as well.
=== 概要 ===
<source lang="lua">
love.graphics.clear( clearcolor, clearstencil, cleardepth )
</source>
=== 引数 ===
{{param (日本語)|boolean|clearcolor|Whether to clear the active color canvas to transparent black (<code>0, 0, 0, 0</code>). Typically this should be set to false with this variant of the function.}}
{{param (日本語)|boolean|clearstencil|Whether to clear the active stencil buffer, [[love.graphics.setCanvas|if present]]. It can also be an integer between 0 and 255 to clear the stencil buffer to a specific value.}}
{{param (日本語)|boolean|cleardepth|Whether to clear the active depth buffer, [[love.graphics.setCanvas|if present]]. It can also be a number between 0 and 1 to clear the depth buffer to a specific value.}}
=== 返値 ===
ありません。

== 用例 ==
== 用例 ==
スクリーンへの線描前に C キーを押すと Canvas を消去します。
<source lang="lua">
local canvas = love.graphics.newCanvas()
local clear

function love.update()
    -- 匿名関数で 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
</source>

== 関連 ==
* [[love.graphics.present (日本語)]]
* [[love.graphics.setBackgroundColor (日本語)]]
* [[love.graphics.setScissor (日本語)]]
* [[love.graphics.setCanvas (日本語)]]
* [[parent::love.graphics (日本語)]]
[[Category:Functions (日本語)]]
[[Sub-Category::Drawing (日本語)| ]]
{{#set:Description=Clears the screen or active [[Canvas]] to the specified color.}}
{{#set:Since=000}}
== そのほかの言語 ==
{{i18n (日本語)|love.graphics.clear}}