Skip to content

Drawing#

Draw overlay primitives during on_render(). All functions are in the xenon::Draw namespace.

Basics#

Drawing is immediate-mode: you issue draw calls every frame in on_render(), and they appear as an overlay on top of the game. There's no retained state — if you stop calling a draw function, it stops appearing.

extern "C" void on_render()
{
    Draw::Text(100, 50, Color::White(), "Always visible");
    Draw::Circle(ScreenCenter(), 20.f, Color::Green());
}

Primitives#

Lines#

Draw::Line(100, 100, 300, 300, Color::Red());
Draw::Line(100, 100, 300, 300, Color::Red(), 3.f);  // 3px thick

Common use: snaplines from screen center to a target.

Vector2 center = ScreenCenter();
Draw::Line(center, targetScreen, Color::White());

Circles#

Draw::Circle(500, 500, 50, Color::Green());          // Outline
Draw::CircleFilled(500, 500, 50, Color::Green());    // Filled

Common use: head dots on enemies.

Vector2 screen;
if (WorldToScreen(enemy.GetBonePos(Bone::Head), screen))
    Draw::CircleFilled(screen, 5.f, Color::Red());

Rectangles#

Draw::Rect(100, 100, 200, 100, Color::White());        // Outline
Draw::RectFilled(100, 100, 200, 100, Color(0, 0, 0, 128)); // Filled, semi-transparent

Parameters are (x, y, width, height)not min/max corners.

Text#

Draw::Text(100, 100, Color::White(), "Hello");
Draw::Text(100, 130, Color::Yellow(), "Big text", 24);  // Custom font size

Health Bars#

Draw::HealthBar draws a filled bar with automatic color gradient:

float hp = enemy.GetHealthPercent();  // 0-100
Draw::HealthBar(x, y, 50, 4, hp);

The fill color transitions automatically: green at 100%, yellow at 50%, red at 0%.

You can customize the background and border colors:

Draw::HealthBar(x, y, 50, 4, hp,
    Color(20, 20, 20),    // Dark background
    Color::Green(),        // (unused — color is auto-computed)
    Color(100, 100, 100)); // Gray border

Color#

Colors use ARGB format. Create them in several ways:

Color::Red()                          // Preset
Color(255, 128, 0)                    // RGB (alpha = 255)
Color(255, 128, 0, 200)              // RGBA
Color(0x80FF0000)                     // Raw ARGB hex
Color::Red().WithAlpha(128)           // Modify alpha

See the full Color API for all presets.

Practical Pattern: ESP Dots#

A typical ESP overlay pattern:

extern "C" void on_render()
{
    Vector2 center = ScreenCenter();

    for (Entity player : Players())
    {
        if (!player.IsAlive() || !player.IsEnemy()) continue;

        Vector3 headWorld = player.GetBonePos(Bone::Head);
        Vector2 headScreen;
        if (!WorldToScreen(headWorld, headScreen))
            continue;

        Color color = player.IsVisible() ? Color::Red() : Color::Orange();

        // Head dot
        Draw::CircleFilled(headScreen, 5.f, color);

        // Health bar
        Draw::HealthBar(headScreen.x - 25, headScreen.y + 10, 50, 4,
                        player.GetHealthPercent());

        // Snapline from screen center
        Draw::Line(center, headScreen, color.WithAlpha(128));
    }
}

Higher-Level Helpers#

The SDK includes convenience wrappers for common drawing patterns.

Shadowed Text#

Draw::TextShadow renders text with a 1px offset shadow for readability against any background:

Draw::TextShadow(100, 100, Color::White(), "Always readable");

Centered Text#

Draw::TextCentered combines centering and shadow in one call — ideal for labels above bounding boxes:

Draw::TextCentered(boxCenterX, boxTop - 15, Color::White(), heroName);

Corner Brackets#

Draw::RectCorners draws tactical corner marks instead of a full rectangle:

Draw::RectCorners(minX, minY, width, height, Color::White(), 1.5f);

Health Gradient Color#

Color::HealthGradient returns a smooth red→yellow→green color based on a 0.0–1.0 health fraction:

Color healthCol = Color::HealthGradient(hp / 100.f);
Draw::RectFilled(x, y, barWidth * (hp / 100.f), barHeight, healthCol);

Text Formatting#

Since printf is not available in freestanding WASM, use TextBuilder to combine text and numbers:

TextBuilder<32> buf;
buf.putInt(static_cast<int>(enemy.GetDistance())).put("m");
Draw::Text(x, y, Color::White(), buf.c_str());

See the Format & Strings API for all formatting functions.

See Also#