sextile.viewdata.tiles

Placing a rectangle of pre-solved teletext cells on a frame.

A Tile is a rectangle of cells solved once – by an image-to-teletext converter such as sextants, by a teletext-art editor, or by hand – carrying its own spacing attributes at the columns the solver chose. Sextile places it as it stands and pays for nothing: the attributes are cells the solver already spent, where RowWriter.mosaic would insert and charge its own.

Distinct from viewdata.blocks, which turns bit patterns into single-colour mosaics: a Tile is finished cells, colour and hold-graphics included. A control byte is accepted bare (0x00-0x1f) or in the 0x80 | code form a solver emits, and normalised to its attribute value once so the stored form is canonical.

class sextile.viewdata.tiles.Tile(rows, align=Align.START)[source]

Bases: object

A rectangle of pre-solved teletext cells, placed once.

Build one with from_bytes or from_rows, not by hand: they check the rectangle and normalise the codes. Canvas.place puts it at a row and column, and a Tile is also a page part – parts=[tile] – placed across the frame by its align.

rows

The cells, row-major, each a stored code: a displayable character (0x20-0x7f) or a spacing attribute’s value (0x00-0x1f).

align

Where the tile sits across the frame when it is a part: an Align, or a column number. Align.START by default. Canvas.place ignores it, being told a column.

Example

A 12-cell-wide tile from a solver’s bytes, centred as a page part:

tile = Tile.from_bytes(fragment.data, fragment.width, align=Align.CENTRE)
page = PageLayout(parts=[tile]).build(request)
Parameters:
classmethod from_bytes(data, width, *, align=Align.START)[source]

A tile from a flat row-major buffer and its width in cells.

Parameters:
  • data (bytes) – The cells, row after row, as a solver such as sextants emits.

  • width (int) – The cells in a row; len(data) must be a whole multiple.

  • align (int | Align) – Where the tile sits across the frame when it is a part.

Raises:

ValueError – If width is less than one, data is not a whole number of rows, or a byte is neither a character nor a control.

Return type:

Tile

classmethod from_rows(rows, *, align=Align.START)[source]

A tile from one buffer a row, each the same width.

Raises:

ValueError – If the rows are not all one width, or a byte is neither a character nor a control.

Parameters:
Return type:

Tile

property width: int

The cells in a row.

property height: int

The rows.

crop(*, rows=None, columns=None)[source]

A smaller tile, keeping the top-left rows by columns cells.

Explicit, never a side effect of placement: a 25-row teletext page cut to a 24-row frame says so with crop(rows=24). Asking for more than there is keeps what there is.

Parameters:
Return type:

Tile

column_on(frame_columns=40)[source]

The column the tile starts at as a part, worked out from its align.

Parameters:

frame_columns (int)

Return type:

int

place(canvas, space)[source]

Draw the tile as a page part, from space.first_row.

A tile taller than the space is carried whole to the next frame, as any drawable is. Canvas.place is the direct entry where a page positions the tile itself.

Parameters:
Return type:

Placed