{{newin|[[0.10.0]]|100|type=function|text=Together with [[love.graphics.stencil]], it has replaced [[love.graphics.setStencil]]}}
Configures or disables stencil testing.

ステンシルテストの有効時、全てのジオメトリは本関数の引数および形状に接触している各ピクセルのステンシル値との間による比較に基づきクリップとステンシル処理を施してから描画されます。ピクセルのステンシル値は [[love.graphics.stencil (日本語)|love.graphics.stencil]] による影響を受けます。


{{notice|1=Starting with version [[11.0]], a stencil buffer must be set or requested in [[love.graphics.setCanvas]] when using stencils with a Canvas. <code>love.graphics.setCanvas{canvas, stencil=true}</code> is an easy way to use an automatically provided temporary stencil buffer in that case.}}
== 関数 ==
=== 概要 ===
<source lang="lua">
love.graphics.setStencilTest( comparemode, comparevalue )
</source>
=== 引数 ===
{{param (日本語)|CompareMode|comparemode|The type of comparison to make for each pixel.}}
{{param (日本語)|number|comparevalue|The value to use when comparing with the stencil value of each pixel. Must be between 0 and 255.}}
=== 返値 ===
ありません。

== 関数 ==
Disables stencil testing.
=== 概要 ===
<source lang="lua">
love.graphics.setStencilTest( )
</source>
=== 引数 ===
なし。
=== 返値 ===
ありません。

== 用例 ==
=== Drawing circles masked by a rectangle ===
<source lang="lua">
local function myStencilFunction()
   love.graphics.rectangle("fill", 225, 200, 350, 300)
end

function love.draw()
    -- draw a rectangle as a stencil. Each pixel touched by the rectangle will have its stencil value set to 1. The rest will be 0.
    love.graphics.stencil(myStencilFunction, "replace", 1)

    -- Only allow rendering on pixels whose stencil value is greater than 0.
    love.graphics.setStencilTest("greater", 0)

    love.graphics.setColor(1, 0, 0, 0.45)
    love.graphics.circle("fill", 300, 300, 150, 50)

    love.graphics.setColor(0, 255, 0, 0.45)
    love.graphics.circle("fill", 500, 300, 150, 50)

    love.graphics.setColor(0, 0, 255, 0.45)
    love.graphics.circle("fill", 400, 400, 150, 50)

    love.graphics.setStencilTest()
end
</source>

=== Drawing a circle with a hole ===
<source lang="lua">
local function myStencilFunction()
   -- Draw a small circle as a stencil. This will be the hole.
   love.graphics.circle("fill", 400, 300, 50)
end

function love.draw()
   -- Each pixel touched by the circle will have its stencil value set to 1. The rest will be 0.
   love.graphics.stencil(myStencilFunction, "replace", 1)

   -- Configure the stencil test to only allow rendering on pixels whose stencil value is equal to 0.
   -- This will end up being every pixel *except* ones that were touched by the circle drawn as a stencil.
   love.graphics.setStencilTest("equal", 0)
   love.graphics.circle("fill", 400, 300, 150)
   love.graphics.setStencilTest()
end
</source>

=== Drawing two masked triangles with different colors ===
<source lang="lua">
local function myStencilFunction()
   love.graphics.circle("fill", 400, 300, 60, 25)
end

function love.draw()
   -- Each pixel touched by the circle will have its stencil value set to 1. The rest will be 0.
   love.graphics.stencil(myStencilFunction, "replace", 1)

   -- Only allow rendering on pixels whose stencil value is greater than 0.
   love.graphics.setStencilTest("greater", 0)
   love.graphics.setColor(0.6, 0, 0.5)
   love.graphics.polygon("fill", 400, 200, 486, 350, 314, 350)
 
   -- Now only allow rendering on pixels whose stencil value is equal to 0.
   love.graphics.setStencilTest("equal", 0)
   love.graphics.setColor(0.55, 0.85, 0.5)
   love.graphics.polygon("fill", 400, 200, 486, 350, 314, 350)

   love.graphics.setStencilTest()
end
</source>

The [[love.graphics.stencil]] wiki page includes more examples.

== 関連 ==
* [[parent::love.graphics (日本語)]]
* [[love.graphics.getStencilTest (日本語)]]
* [[love.graphics.stencil (日本語)]]
[[Category:Functions (日本語)]]
{{#set:Description=Configures or disables stencil testing.}}
{{#set:Sub-Category=State (日本語)}}
== そのほかの言語 ==
{{i18n (日本語)|love.graphics.setStencilTest}}