wijjit.elements.display.chart_utils.BrailleCanvas

class wijjit.elements.display.chart_utils.BrailleCanvas(width, height)[source]

A canvas for drawing using braille characters.

Each character cell represents a 2x4 grid of dots, providing higher resolution plotting within terminal constraints.

Parameters:
  • width (int) – Width in terminal characters

  • height (int) – Height in terminal characters

Variables:
  • width (int) – Canvas width in characters

  • height (int) – Canvas height in characters

  • pixel_width (int) – Canvas width in braille dots (width * 2)

  • pixel_height (int) – Canvas height in braille dots (height * 4)

Examples

Create a canvas and plot points:

>>> canvas = BrailleCanvas(20, 5)
>>> canvas.set_pixel(0, 0)  # Top-left dot
>>> canvas.set_pixel(39, 19)  # Bottom-right dot
>>> lines = canvas.to_lines()
__init__(width, height)[source]
Parameters:
Return type:

None

Methods

__init__(width, height)

clear()

Clear the canvas.

draw_line(x0, y0, x1, y1)

Draw a line between two points using Bresenham's algorithm.

fill_below(x, y)

Fill all pixels below the given point to the bottom.

get_pixel(x, y)

Check if a pixel is set.

set_pixel(x, y)

Set a pixel (dot) at the given coordinates.

to_lines()

Convert the canvas to a list of braille character strings.

unset_pixel(x, y)

Unset a pixel (dot) at the given coordinates.

clear()[source]

Clear the canvas.

Return type:

None

set_pixel(x, y)[source]

Set a pixel (dot) at the given coordinates.

Parameters:
  • x (int) – X coordinate in pixels (0 to pixel_width-1)

  • y (int) – Y coordinate in pixels (0 to pixel_height-1)

Return type:

None

Notes

Coordinates outside the canvas bounds are silently ignored.

unset_pixel(x, y)[source]

Unset a pixel (dot) at the given coordinates.

Parameters:
  • x (int) – X coordinate in pixels

  • y (int) – Y coordinate in pixels

Return type:

None

get_pixel(x, y)[source]

Check if a pixel is set.

Parameters:
  • x (int) – X coordinate in pixels

  • y (int) – Y coordinate in pixels

Returns:

True if pixel is set, False otherwise

Return type:

bool

draw_line(x0, y0, x1, y1)[source]

Draw a line between two points using Bresenham’s algorithm.

Parameters:
  • x0 (int) – Starting point coordinates

  • y0 (int) – Starting point coordinates

  • x1 (int) – Ending point coordinates

  • y1 (int) – Ending point coordinates

Return type:

None

fill_below(x, y)[source]

Fill all pixels below the given point to the bottom.

Parameters:
  • x (int) – X coordinate

  • y (int) – Y coordinate to start filling from

Return type:

None

to_lines()[source]

Convert the canvas to a list of braille character strings.

Returns:

Lines of braille characters representing the canvas

Return type:

list of str