Show a picture¶
A how-to guide: convert a picture — poster art, a bold graphic — to teletext cells with sextants and show it full-screen on a page.
import sextants
from sextile import OnOneFrame, Page, PageLayout, PageRequest, PageRouter, Sextile
from sextile.viewdata.tiles import Tile
router = PageRouter()
_graphic = sextants.PRESETS["graphic"]
_CELLS = sextants.convert_fragment(
"docs/_static/national-parks-wildlife.jpg",
40,
20,
fit=sextants.Fit.PAD,
preprocess=_graphic.preprocess,
solve=_graphic.solve,
).data
@router.page("1", name="picture", title="National parks")
async def picture(request: PageRequest) -> Page:
return PageLayout(parts=[OnOneFrame(Tile.from_bytes(_CELLS, 40))]).build(request)
app = Sextile(name="Gallery", pages=[*router])
NATIONAL PARKS 1a 🬂🬒🬰🬴█🬸🬰🬰🬰🬴🬰🬰🬸🬰🬸🬰🬰🬸 █████████🬎🬎🬬🬬 ██████████▌ 🬓🬦 🬎🬎🬎 🬆🬆🬂🬂🬘🬺🬴🬏 🬎🬬 ▐ ▌▌🬦🬭🬝🬥█🬝🬓🬂🬆🬆🬷█ 🬏🬏🬏🬕🬉🬎🬆🬆🬞🬺 🬞🬞 🬺🬺🬏🬞🬏🬟🬞🬷🬝🬀🬁🬬█ █████████▌🬷█▐ 🬡🬹 🬏🬁 █████████▌🬆🬒 🬵🬬🬹█🬄 🬨 ███████🬝🬀 🬻🬮🬜███🬒 🬎🬎🬎🬝🬝🬀🬇🬋🬩🬅🬂🬂 🬞🬞🬇🬋🬋 🬂🬂🬊🬎█🬆 🬹█🬂 🬌🬎 🬭🬭🬭🬚 🬋🬩🬬█🬓 🬇🬹🬺🬞 ██🬕 🬢🬯🬰🬎🬎🬋 🬁🬊🬞 🬏🬏 🬂🬢 🬺🬺 🬁🬢 🬞 🬎🬀🬊🬁 0 index
sextants solves an image into teletext
cells; convert_fragment(image, 40, 20, fit=Fit.PAD) fills the 40×20 content
area between the page’s furniture, and Tile.from_bytes(data, width) reads its
row-major bytes onto a Tile the page places as a part. Sextile never imports
sextants — it only places the cells the solver hands it, charging nothing for the
attributes it already spent.
The graphic preset (sextants.PRESETS["graphic"]) suits flat, boldly-coloured
poster art, sharpening the edges block mosaics read best; a continuous-tone
photograph wants a different one, in Show a photograph. Draw a tile at an
exact spot with canvas.place(tile, row=, column=) (Draw a custom frame),
and a chart or an icon rather than a picture is Draw a chart and
Draw an icon.