# aego/debug

> Aego 0.12.5 · development; docs build `4a32b816933e02930662f6a443cb25abe6050d090c55e237cbff5c44ae9b25f8`. [Build manifest](/docs-build.json).

Shapes last one frame unless `Pen` gives them a lifetime, and belong to a channel that the Debug Draw panel turns on and off. In the documentation sandbox nothing is drawn; the example logs what it draws. See [Debug Draw](/debug.md).

## Example

```aes run
package demo

import (
    "aego/debug"
    "aego/log"
)

script Patrol {
    @export var Goal Vec2 = Vec2{4, 0}
    @export var Speed float = 2

    var frames int

    func Ready() {
        debug.Pen("ai.goal", -1)
        debug.Cross(Goal, 0.5, Color{1, 0, 1, 1})
        debug.Rect(Rect{-1, -1, 6, 2}, Color{1, 1, 1, 1})
    }

    func Update(dt float) {
        p := node.WorldPosition()
        step := Vec2{Speed * dt, 0}
        if p.X < Goal.X {
            node.SetPosition(node.Position() + step)
        }
        debug.Pen("ai.path", 0)
        debug.Arrow(p, Goal, Color{0, 1, 0, 1})
        debug.Circle(p, 0.5, Color{0, 0.6, 1, 1})
        debug.Text(p, "x " + string(p.X), Color{1, 1, 1, 1})
        frames++
        if frames % 30 == 0 {
            log.Info("drawing at x=" + string(p.X))
        }
        if frames == 90 {
            debug.Clear("ai")
            log.Info("cleared the ai channels")
        }
    }
}
```

## Arrow

```
func Arrow(from Vec2, to Vec2, color Color)
```

Draws an arrow from one point to another.

## Circle

```
func Circle(center Vec2, radius float, color Color)
```

Draws a circle outline with radius r in world units.

## Clear

```
func Clear(channel string)
```

Removes every primitive whose channel starts with prefix.

## Cross

```
func Cross(p Vec2, size float, color Color)
```

Draws a cross of the given size in world units.

## Line

```
func Line(a Vec2, b Vec2, color Color)
```

Draws a line in world units. It lasts one frame unless Pen sets a lifetime.

## Pen

```
func Pen(channel string, ttl float)
```

Sets the channel and the lifetime of the next primitives this script draws. A ttl of 0 lasts one frame, a positive ttl that many game seconds, a negative ttl until Clear.

## PenUnscaled

```
func PenUnscaled(channel string, ttl float)
```

Is Pen with a lifetime in real seconds; such primitives fade out while the game is paused.

## Point

```
func Point(p Vec2, color Color)
```

Marks a point with a small cross of constant screen size.

## Ray

```
func Ray(origin Vec2, dir Vec2, color Color)
```

Draws an arrow from origin along dir; the length of dir is the length of the arrow.

## Rect

```
func Rect(rect Rect, color Color)
```

Draws a rectangle outline.

## Text

```
func Text(p Vec2, text string, color Color)
```

Draws a label at a world position; it keeps its screen size at any zoom.
