# BeginFrame

## Syntax

```lua
Susano.BeginFrame() -> void
```

## Parameters

{% hint style="info" %}
None
{% endhint %}

## Return(s)

{% hint style="info" %}
None
{% endhint %}

## Behavior

{% hint style="info" %}
Clears the build buffer only.

Leaves the currently displayed frame untouched.

Subsequent `Draw*` calls append to the new build buffer.

Calling it again within the same tick re-clears the build buffer.

Does not trigger rendering or a swap by itself.
{% endhint %}

## Example(s)

```lua
-- Example 1: one-time overlay (persists until you submit a new frame)
Susano.BeginFrame()
Susano.DrawLine(100,100, 300,200, 1,0,0,1, 2)
Susano.DrawRect(320,100, 120,80, 0,1,0,1, 1.5)
Susano.DrawRectFilled(460,100, 120,80, 0,0,1,0.6)
Susano.DrawCircle(620,140, 40, false, 1,1,0,1, 2, 48)
Susano.DrawText(100,260, "Overlay", 20, 1,1,1,1)
Susano.SubmitFrame()
```

```lua
-- Example 2: animated overlay (updates every frame)
Citizen.CreateThread(function()
  while true do
    local t = GetGameTimer() / 1000.0
    local x = 100 + math.floor(math.sin(t) * 50)

    Susano.BeginFrame()
    Susano.DrawLine(100,100, 300,200, 1,0,0,1, 2)
    Susano.DrawRectFilled(x, 80, 120, 30, 0,0,0,0.5)
    Susano.DrawText(x + 8, 88, ("x=%d"):format(x), 16, 1,1,1,1)
    Susano.SubmitFrame()

    Citizen.Wait(0)
  end
end)
```


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://docs.susano.re/api-reference/drawing-functions/beginframe.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
