---
title: "Projection — projection"
---

> Documentation Index
> Fetch the complete documentation index at: https://aesthetic-docs.pages.dev/llms.txt
> Use this file to discover all available pages before exploring further.

# Projection — projection

Converts world coordinates to screen coordinates (same space as the [2D canvas](/canvas)).
Call from render callbacks (`render_2d`, `render_gui`, `frame`).

| Function | Returns |
|----------|---------|
| `projection.to_screen(pos[, ignore_frustum])` | Screen `sx, sy`, or `nil` when behind the camera / out of view |
| `projection.box(min, max)` | Box on screen as `x, y, w, h`, or `nil` |
| `projection.entity_box(entity_id)` | Entity hitbox on screen as `x, y, w, h` (interpolated), or `nil` |

`ignore_frustum = true` also projects points outside the view (only fails behind the
camera) — useful for edge-of-screen indicators.

```lua
module:event("render_2d", function(render)
for _, p in ipairs(world:players()) do
    if not p:is_self() then
        local x, y, w, h = projection.entity_box(p:id())
        if x then
            render.rect(x, y, w, h, render.paint(0xFF4FF2A6):stroke(1, "inside"))
        end
    end
end
end)
```

Source: https://aesthetic-docs.pages.dev/projection/index.md
