DRAWING FUNCTIONS

WithClipRect

Runs a callback inside the given clipping rectangle.

Syntax

ONYX.WithClipRect(x, y, w, h, callback)

Parameters

  • x, y (number) — Top-left corner of the clip region in pixels.
  • w, h (number) — Width and height of the clip region.
  • callback (function) — Function containing the draw commands to clip.

Return(s)

None

Behavior

  • Pushes a clip rect, runs the callback, then pops the clip rect.
  • Always intersects with the current clip rectangle.
  • PopClipRect is still called when the callback raises an error.

Example(s)

ONYX.WithClipRect(100, 100, 200, 150, function()
  ONYX.DrawRectFilled(50, 50, 300, 200, 1, 0, 0, 1)
end)