Difference between revisions of "love.graphics.setScissor"

m
(See Also)
 
(7 intermediate revisions by 5 users not shown)
Line 1: Line 1:
 +
{{newin|[[0.4.0]]|040|type=function}}
 
Sets or disables scissor.
 
Sets or disables scissor.
  
 
The scissor limits the drawing area to a specified rectangle. This affects all graphics calls, including [[love.graphics.clear]].  
 
The scissor limits the drawing area to a specified rectangle. This affects all graphics calls, including [[love.graphics.clear]].  
  
The dimensions of the scissor is unaffected by graphical transformations (translate, scale, ...).
+
The dimensions of the scissor are unaffected by graphical transformations (translate, scale, ...), and it operates on whole pixels rather than having sub-pixel precision.
 +
 
 
== Function ==
 
== Function ==
 +
Limits the drawing area to a specified rectangle.
 
=== Synopsis ===
 
=== Synopsis ===
 
<source lang="lua">
 
<source lang="lua">
Line 10: Line 13:
 
</source>
 
</source>
 
=== Arguments ===
 
=== Arguments ===
{{param|number|x|x coordinate of upper left corner.}}
+
{{param|number|x|The x-coordinate of the upper left corner of the clipping rectangle.}}
{{param|number|y|y coordinate of upper left corner.}}
+
{{param|number|y|The y-coordinate of the upper left corner of the clipping rectangle.}}
{{param|number|width|width of clipping rectangle.}}
+
{{param|number|width|The width of the clipping rectangle.}}
{{param|number|height|height of clipping rectangle.}}
+
{{param|number|height|The height of the clipping rectangle.}}
 
=== Returns ===
 
=== Returns ===
 
Nothing.
 
Nothing.
 +
 
== Function ==
 
== Function ==
 +
Disables scissor.
 
=== Synopsis ===
 
=== Synopsis ===
 
<source lang="lua">
 
<source lang="lua">
Line 25: Line 30:
 
=== Returns ===
 
=== Returns ===
 
Nothing.
 
Nothing.
=== Notes ===
+
 
Disables scissor.
+
== Examples ==
 +
=== Only draw on the left side of the screen ===
 +
<source lang="lua">
 +
function love.draw()
 +
local windowWidth, windowHeight = love.graphics.getDimensions()
 +
 
 +
love.graphics.setScissor(0,0, windowWidth/2,windowHeight)
 +
love.graphics.clear(0, 0, .5)
 +
love.graphics.circle("fill", windowWidth/2,windowHeight/2, 100)
 +
end
 +
</source>
 +
 
 
== See Also ==
 
== See Also ==
 
* [[parent::love.graphics]]
 
* [[parent::love.graphics]]
 
* [[love.graphics.getScissor]]
 
* [[love.graphics.getScissor]]
 +
* [[love.graphics.intersectScissor]]
 +
* [[love.graphics.stencil]]
 +
 +
== Other Languages ==
 +
{{i18n|love.graphics.setScissor}}
 +
 
[[Category:Functions]]
 
[[Category:Functions]]
 
{{#set:Description=Sets or disables scissor.}}
 
{{#set:Description=Sets or disables scissor.}}
{{#set:Since=040}}
 
 
{{#set:Sub-Category=State}}
 
{{#set:Sub-Category=State}}
== Other Languages ==
 
{{i18n|love.graphics.setScissor}}
 

Latest revision as of 20:43, 19 May 2023

Available since LÖVE 0.4.0
This function is not supported in earlier versions.

Sets or disables scissor.

The scissor limits the drawing area to a specified rectangle. This affects all graphics calls, including love.graphics.clear.

The dimensions of the scissor are unaffected by graphical transformations (translate, scale, ...), and it operates on whole pixels rather than having sub-pixel precision.

Function

Limits the drawing area to a specified rectangle.

Synopsis

love.graphics.setScissor( x, y, width, height )

Arguments

number x
The x-coordinate of the upper left corner of the clipping rectangle.
number y
The y-coordinate of the upper left corner of the clipping rectangle.
number width
The width of the clipping rectangle.
number height
The height of the clipping rectangle.

Returns

Nothing.

Function

Disables scissor.

Synopsis

love.graphics.setScissor( )

Arguments

None.

Returns

Nothing.

Examples

Only draw on the left side of the screen

function love.draw()
	local windowWidth, windowHeight = love.graphics.getDimensions()

	love.graphics.setScissor(0,0, windowWidth/2,windowHeight)
	love.graphics.clear(0, 0, .5)
	love.graphics.circle("fill", windowWidth/2,windowHeight/2, 100)
end

See Also

Other Languages