sextile.viewdata.drawing¶
One-call conveniences for putting things on a frame.
There are two writers a page draws through: Composition, the declarative one, which takes a whole row and works the attributes out at once; and RowWriter, the sequential one, which writes a row left to right. These functions are the small operations every page turns out to want – centring a heading, ruling a line, drawing a gauge – each built once on whichever of the two fits, so there is one way to do each rather than a twin on every writer.
centred and centred_double and the rules go through Composition, since centring is accounting about attributes and that is what a composition is for. bar and key_row go through RowWriter, being a run laid down a cell at a time. All are free functions rather than methods, so a service can write its own beside them; they take a canvas and a row, and none of them knows what a page is.
The block characters are how the rules and the gauge are drawn: the G1 set gives each cell a 2x3 grid of blocks, so a frame is 80x72 addressable points, and bar is the one-dimensional case of plotting into that. The two-dimensional case – reading a bitmap into cells and placing it – is blocks.py and composition.py, with lettering.py on top for text.
- sextile.viewdata.drawing.bar(canvas, row, *, colour, column=0, cells=None, lit=None, separated=False)[source]¶
Draw a run of mosaic cells,
litof them solid and the rest blank.- Parameters:
canvas (
Canvas) – The frame to draw on.row (
int) – The row to draw on.colour (
Colour) – The colour of the lit cells.column (
int) – The cell the run begins at, after its colour attribute.cells (
int|None) – How many cells the run has, or the rest of the row from column.lit (
int|None) – How many are solid, from the left, or all of them.separated (
bool) – Whether the blocks are drawn separated, not contiguous.
- Raises:
ValueError – If there is no room for the run.
- Return type:
A rule is the whole run lit; a gauge some of it. Unlit cells are written blank, not left alone, so a bar drawn over a longer one shortens rather than failing to lengthen.
- sextile.viewdata.drawing.centred(canvas, row, text, colour=None)[source]¶
Write text across the middle of a row.
- Parameters:
- Return type:
The middle is the composition’s to work out: what a style costs in cells decides where the middle is.
- sextile.viewdata.drawing.centred_double(canvas, row, text, colour=None)[source]¶
Write text centred at twice the height, which costs the row below too.
- sextile.viewdata.drawing.key_row(row, key, meaning, *, column)[source]¶
Write a key on the left and what it does on the right, in two columns.
- Parameters:
row (
RowWriter) – The row writer to draw on.key (
str) – The key, in yellow, or empty to indent to the meaning column and carry a meaning too long for one row onto the next.meaning (
str) – What the key does, in white.column (
int) – The cell the meaning column begins at, given so several frames of one table line up.
- Return type:
- sextile.viewdata.drawing.rule(canvas, row, colour=Colour.BLUE)[source]¶
Draw a rule in separated mosaic graphics across the middle of a row.
- Parameters:
- Return type:
The widest a rule can be and stay centred is the row less the two attribute cells at each end; inset at one end and flush at the other reads as a mistake.
- sextile.viewdata.drawing.thin_rule(canvas, row, colour=Colour.BLUE)[source]¶
Draw a lighter rule, one block thick, across the middle of a row.
- Parameters:
- Return type:
A sixth of the ink of rule: a bar reads as a page edge, so a divider inside a page, between two things that are both content, is drawn lighter.