screen API

← screen · version 0.2.2

15 public items, in source order. Generated from the registry index, which re-derives them from the package source at publish time — so a signature here is the one that version actually ships.

pub fn open(width: integer, height: integer, scale: integer = 1, title: text = "loft", offscreen: boolean = false, fill: boolean = false) -> boolean

Open the screen for frames of width by height pixels, each shown as a scale by scale block. On a desktop that is a window of that size titled title; on a device it is the whole display, the frame centred. fill asks for the whole display where there is a choice: in a page the canvas fills the window and follows it when it is resized (read width() and height() each frame to draw at its size). offscreen keeps only the scaled image in memory — for tests, and for a machine with no screen. False where this machine has no screen (no display). Opening again closes the screen that was open.

pub fn show(pixels: const vector<i32>, width: integer, height: integer)

Show a frame: width * height RGB565 values, row by row, as tiles::pixels answers them. It is shown at the scale open asked for, or the largest whole scale that fits: a frame of the screen's own size (width() x height(), drawn at the screen's resolution) is shown as it is. A frame with fewer values than that shows nothing.

pub fn poll(wait_ms: integer = 0) -> boolean

Take what happened since the last call — keys, the window being closed — waiting up to wait_ms milliseconds for something to happen. False once the window was closed.

pub fn has_keys() -> boolean

Does this screen have keys of its own (a desktop window)? A device's keys are input's.

pub fn program_keys() -> boolean

True where the keys this screen reads are the program's, whichever of its windows is in front (macOS: one event queue for the application). False where every window has its own (X11): a second window in front then takes the keys, and this screen reads none. A game that opens a second window — a GPU view beside its frame — asks this before it relies on keys() while that window is in front.

pub fn keys() -> vector<boolean>

Which of the window's keys are down, by graphics' key codes (KEY_W = 119, KEY_UP = 128, ...): 256 flags, the form input::input_tick_from_state takes. All false where the screen has no keys.

pub fn shown(x: integer, y: integer) -> integer

The RGB565 value shown at screen pixel (x, y), or -1 outside the screen — what a test reads back.

pub fn width() -> integer

The size of the screen in pixels: the window's, or the device's display turned landscape.

pub fn height() -> integer
pub fn close()

Close the screen.

pub fn has_pointer() -> boolean

Whether this screen has a pointer: a desktop window's mouse, a page's mouse or touch. The Tanmatsu has none — a program for it works from the keyboard alone.

pub fn pointer() -> (integer, integer)

Where the pointer is, in the screen's pixels (width() x height()), as poll last saw it.

pub fn buttons() -> integer

The pointer's buttons held down: 1 the left, 2 the right, 4 the middle, added together.

pub fn wheel() -> integer

The wheel's notches since this was last asked (up is positive).

pub fn typed() -> text

The text typed since this was last asked — what the keys wrote, with the keyboard's layout and shift applied, as opposed to which keys are down.