setScissor method

void setScissor(
  1. int x,
  2. int y,
  3. int width,
  4. int height,
)

Enables and defines a scissor rectangle for clipping rendering.

When scissor testing is enabled, rendering is confined to the specified rectangular area of the canvas.

  • x: The x-coordinate of the top-left corner of the scissor box.
  • y: The y-coordinate of the top-left corner of the scissor box.
  • width: The width of the scissor box.
  • height: The height of the scissor box.

Implementation

void setScissor(int x, int y, int width, int height) {
  flush();
  _renderState
    ..isScissorEnabled = true
    ..scissor.set(x, y, width, height);
  _renderer.setScissor(x, y, width, height);
}