# `BB.Camera.Annotation.Layer`
[🔗](https://github.com/beam-bots/bb_camera/blob/main/lib/bb/camera/annotation/layer.ex#L5)

What a viewer draws over a camera's video for one message.

Every coordinate in `primitives` is in pixels of a frame `width` by `height`,
the frame the message describes - not the size the video happens to be
displayed at, which the viewer scales to. Primitives are drawn in order, so
a later one is on top of an earlier one.

`lifetime` is how long the layer stays up with nothing newer to replace it,
counted from the message's capture time, or `:infinity` to stay until
replaced. A layer with no primitives clears what was there. See
`BB.Camera.Annotation` for how a viewer treats a layer.

The primitives follow Foxglove's `ImageAnnotations`: `BB.Camera.Annotation.Points`,
`BB.Camera.Annotation.Circle` and `BB.Camera.Annotation.Text`. Foxglove keeps
them in a list per kind and draws the kinds in a fixed order; one list
here lets the implementation choose what goes on top.

# `primitive`

```elixir
@type primitive() ::
  BB.Camera.Annotation.Points.t()
  | BB.Camera.Annotation.Circle.t()
  | BB.Camera.Annotation.Text.t()
```

# `t`

```elixir
@type t() :: %BB.Camera.Annotation.Layer{
  height: pos_integer(),
  lifetime: Localize.Unit.t() | :infinity,
  primitives: [primitive()],
  width: pos_integer()
}
```

# `new`

```elixir
@spec new(keyword()) :: {:ok, t()} | {:error, term()}
```

Build a layer.

# `new!`

```elixir
@spec new!(keyword()) :: t()
```

Like `new/1`, but raises.

---

*Consult [api-reference.md](api-reference.md) for complete listing*
