Raxol.Plugins.Visualization.DrawingUtils (Raxol v0.3.0)

View Source

Utility functions for drawing basic shapes and text onto a cell grid. Used by visualization renderers.

Summary

Functions

Draws box borders onto an existing grid.

Draws a simple box with optional text centered inside. Returns a grid of cells. Expects bounds map: %{width: w, height: h}.

Draws text onto a grid at a specific coordinate. Truncates if text exceeds grid width. Uses optional style.

Draws text centered horizontally on a specific row in the grid. Truncates text if it exceeds grid width.

Safely gets a cell from the grid. Returns nil if coordinates are out of bounds.

Safely puts a cell into the grid (list of lists). Handles out-of-bounds coordinates gracefully (no-op).

Functions

draw_box_borders(grid, y, x, width, height, style)

Draws box borders onto an existing grid.

draw_box_with_text(text, bounds)

Draws a simple box with optional text centered inside. Returns a grid of cells. Expects bounds map: %{width: w, height: h}.

draw_text(grid, y, x, text, style \\ Style.new())

Draws text onto a grid at a specific coordinate. Truncates if text exceeds grid width. Uses optional style.

draw_text_centered(grid, y, text)

Draws text centered horizontally on a specific row in the grid. Truncates text if it exceeds grid width.

get_cell(grid, x, y)

Safely gets a cell from the grid. Returns nil if coordinates are out of bounds.

put_cell(grid, y, x, cell)

Safely puts a cell into the grid (list of lists). Handles out-of-bounds coordinates gracefully (no-op).