sextile.viewdata.blocks¶
Turning a picture into the blocks a frame can draw.
A small picture is written in the source as the picture it is, which is what icon is for: an arrow, a symbol, a rule end, anything a page wants that the character set has not got. Six-bit patterns typed as numbers are write-only, and a picture drawn in a comment beside them is a copy that goes stale:
ARROW = icon("""
#
#
######
#
#
""")
A mosaic cell is a 2x3 grid of blocks, so a frame is 80x72 of them – 78 in practice, an attribute cell going on the left of each row a picture spans. This turns a bitmap into the six-bit patterns those cells carry.
Inverted is the interesting case, and it is how teletext has always done dark lettering. The SAA5050 has no alpha-black attribute: the colour codes run 0x01-0x07 and there is no way to ask for a black foreground. So a Ceefax banner of black letters on cyan is not black letters at all – it is a solid cyan field with letter-shaped holes in it, the unlit blocks showing the default black background through. It costs one graphics attribute on each row and no background attributes whatever, which is cheaper than the coloured-background version it appears to be.
That is why inverted belongs here rather than in whatever draws the letters: inverting a glyph on its own would leave the space around it black. What has to be inverted is the whole field the picture occupies.
- class sextile.viewdata.blocks.Icon(bitmap)[source]¶
Bases:
objectA small picture on the block grid, drawn in the source as itself.
- sextile.viewdata.blocks.block_runs(bitmap, *, inverted=False)[source]¶
A bitmap as six-bit cell patterns, a list of them for each row of cells.
The picture is padded out to whole cells: to a multiple of two blocks across and three down. Padding is dark in the ordinary case and lit when inverted, so that an inverted picture is a solid field rather than a solid field with a ragged edge.
- sextile.viewdata.blocks.icon(art, *, lit='#')[source]¶
A picture written out as itself, indented to suit the code around it.
Blank lines at either end go, and so does the indentation the source needed – the common part of it, so what one row is drawn further along than another survives. Anything that is not lit is a block that is off, so a picture reads whether it is drawn in dots or in spaces.
- sextile.viewdata.blocks.read_bitmap(rows, lit='#')[source]¶
Read a picture written out as characters, one character to a block.
- Parameters:
rows (
Sequence[str]) – The picture, a string a row. They need not be the same length: a short one is taken as ending in blanks.lit (
str) – Which characters mean a block that is on. Any character in this string counts, so a picture may be drawn in more than one mark where that makes it easier to read.
- Return type:
- Returns:
The picture as rows of blocks, for block_runs to pack into the six-bit cell patterns a frame carries.
Example
A picture is legible in the source it is written in:
read_bitmap([ " ## ", " #### ", "######", ])