# `Kreuzberg.BoundingBox`
[🔗](https://github.com/kreuzberg-dev/kreuzberg/blob/main/lib/kreuzberg/element.ex#L1)

Bounding box coordinates for element positioning in documents.

Represents the rectangular region where an element appears within a document,
using float coordinates for precise positioning.

## Fields

  * `:x0` - Left x-coordinate (0.0 is the left edge)
  * `:y0` - Bottom y-coordinate (0.0 is the bottom edge)
  * `:x1` - Right x-coordinate (document width is the right edge)
  * `:y1` - Top y-coordinate (document height is the top edge)

## Examples

    iex> bbox = %Kreuzberg.BoundingBox{
    ...>   x0: 10.5,
    ...>   y0: 20.5,
    ...>   x1: 100.5,
    ...>   y1: 50.5
    ...> }
    iex> bbox.x0
    10.5

# `t`

```elixir
@type t() :: %Kreuzberg.BoundingBox{
  x0: float(),
  x1: float(),
  y0: float(),
  y1: float()
}
```

# `from_map`

```elixir
@spec from_map(map()) :: t()
```

Creates a BoundingBox struct from a map.

Converts a plain map (typically from NIF/Rust) into a proper struct.

## Parameters

  * `data` - A map containing x0, y0, x1, y1 fields

## Returns

A `BoundingBox` struct with float coordinates.

## Examples

    iex> bbox_map = %{"x0" => 10.5, "y0" => 20.5, "x1" => 100.5, "y1" => 50.5}
    iex> Kreuzberg.BoundingBox.from_map(bbox_map)
    %Kreuzberg.BoundingBox{x0: 10.5, y0: 20.5, x1: 100.5, y1: 50.5}

# `height`

```elixir
@spec height(t()) :: float()
```

Calculates the height of the bounding box.

## Parameters

  * `bbox` - A `BoundingBox` struct

## Returns

The height (y1 - y0).

## Examples

    iex> bbox = %Kreuzberg.BoundingBox{x0: 10.0, y0: 20.0, x1: 110.0, y1: 70.0}
    iex> Kreuzberg.BoundingBox.height(bbox)
    50.0

# `to_map`

```elixir
@spec to_map(t()) :: map()
```

Converts a BoundingBox struct to a map.

Useful for serialization and passing to external systems.

## Parameters

  * `bbox` - A `BoundingBox` struct

## Returns

A map with string keys and float values.

## Examples

    iex> bbox = %Kreuzberg.BoundingBox{x0: 10.5, y0: 20.5, x1: 100.5, y1: 50.5}
    iex> Kreuzberg.BoundingBox.to_map(bbox)
    %{"x0" => 10.5, "y0" => 20.5, "x1" => 100.5, "y1" => 50.5}

# `width`

```elixir
@spec width(t()) :: float()
```

Calculates the width of the bounding box.

## Parameters

  * `bbox` - A `BoundingBox` struct

## Returns

The width (x1 - x0).

## Examples

    iex> bbox = %Kreuzberg.BoundingBox{x0: 10.0, y0: 20.0, x1: 110.0, y1: 50.0}
    iex> Kreuzberg.BoundingBox.width(bbox)
    100.0

---

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