Boxart.Layout.Coordinates (Boxart v0.3.2)

Copy Markdown View Source

Coordinate conversion for the layout engine.

Converts grid positions to drawing (character) coordinates and adjusts for subgraph bounds that extend into negative space.

Summary

Functions

Shift all coordinates if subgraph bounds extend into negative space.

Convert grid positions to drawing coordinates for all placements.

Functions

adjust_for_negative_bounds(layout)

@spec adjust_for_negative_bounds(Boxart.Layout.t()) :: Boxart.Layout.t()

Shift all coordinates if subgraph bounds extend into negative space.

When subgraph borders have padding that pushes them before coordinate 0, all placements and bounds are shifted rightward/downward to keep everything in positive coordinate space.

compute_draw_coords(layout)

@spec compute_draw_coords(Boxart.Layout.t()) :: Boxart.Layout.t()

Convert grid positions to drawing coordinates for all placements.

Each placement's draw_x, draw_y, draw_width, and draw_height are computed from its 3×3 grid block and the accumulated column/row sizes.