natiny.render.scissor_begin
natiny.render.scissor_begin(x, y, width, height [, fn])
Starts a scissor clip rectangle for subsequent draw calls on the currently bound render target.
Parameters
| Name | Type | Default | Description |
|---|---|---|---|
x |
number |
Left edge of the clip rectangle | |
y |
number |
Top edge of the clip rectangle | |
width |
number |
Clip rectangle width | |
height |
number |
Clip rectangle height | |
fn |
function |
nil |
Called with no arguments while the clip is in force; the clip is ended when it returns |
Example
natiny.render.scissor_begin(40, 40, 220, 120, function()
draw_content()
end)
Without the callback, end the clip by hand:
natiny.render.scissor_begin(40, 40, 220, 120)
draw_content()
natiny.render.scissor_end()
Notes
- With
fn, the clip is ended whenfnreturns, including when it raises an error - the error is re-raised afterwards. A skippedscissor_endleaves the stack one level deep for the rest of the frame, and every draw after it clipped to a rectangle nobody asked for. - Scissors form a stack. A nested rectangle is intersected with its parent, and callback forms nest the same way.
- Pair every successful begin with
natiny.render.scissor_end(); nesting is limited to 16 levels.