snakia.core.tui.canvas

Classes

Canvas(width, height[, default_value])

A canvas is a 2D array of characters.

CanvasChar([char, fg_color, bg_color, bold, ...])

class snakia.core.tui.canvas.Canvas(width, height, default_value=CanvasChar(' '))[source]

Bases: object

A canvas is a 2D array of characters.

__init__(width, height, default_value=CanvasChar(' '))[source]
clear()[source]

Clear the canvas.

Return type:

None

copy_from(other, x=0, y=0)[source]

Copy the given canvas to the current canvas.

Return type:

None

draw_filled_rect(x, y, width, height, char)[source]

Draw a filled rectangle.

Return type:

None

draw_line_h(x, y, length, char)[source]

Draw a horizontal line.

Return type:

None

draw_line_v(x, y, length, char)[source]

Draw a vertical line.

Return type:

None

draw_rect(x, y, width, height, char)[source]

Draw a rectangle.

Return type:

None

draw_text(x, y, text, char)[source]

Draw text on the canvas.

Return type:

None

fill(value, /)[source]

Fill the canvas with the given value.

Return type:

None

get(x, y, /)[source]

Get the character at the given position.

Return type:

CanvasChar

get_column(x, /)[source]

Get the column at the given position.

Return type:

Iterable[CanvasChar]

get_row(y, /)[source]

Get the row at the given position.

Return type:

Iterable[CanvasChar]

get_subcanvas(x, y, width, height)[source]

Get a subcanvas from the current canvas.

Return type:

Canvas

height: Final[int]
is_valid_position(x, y)[source]

Check if the given position is valid.

Return type:

bool

set(x, y, value, /)[source]

Set the character at the given position.

Return type:

None

set_area(x, y, width, height, value)[source]

Set the area at the given position.

Return type:

None

set_column(x, value, /)[source]

Set the column at the given position.

Return type:

None

set_row(y, value, /)[source]

Set the row at the given position.

Return type:

None

property total: int
width: Final[int]