initial images doc proposal
[nikiroo-utils.git] / docs / images.md

Next-Gen Multimedia Standard - Proposed Design Document

Purpose

TODO: Crib text from the first message of https://gitlab.freedesktop.org/terminal-wg/specifications/issues/12 as to why people want images in their terminals.

The same mechanism that can put raster-based images on the screen is easily generalizable to other media types such as vector-based images, animations, and embedded GUI widgets. This document is thus a “multimedia” proposal, not just “simple images”.

Acknowledgements

This proposal has been informed from the following prior work:

Design Goals - Core

The core (“must-have”) design goals are:

Design Goals - Secondary

The secondary (“nice-to-have”) design goals are:

Out Of Scope

The following items are out of scope for this standard:

Definitions

Terminal - The hardware, or a program that simulates hardware, comprising a keyboard, screen, and mouse.

Application - A program that utilizes the terminal for its input/output with the user.

Multiplexer - A special case of an application that simulates one or more “inner” terminals for other applications to use, and composes these inner terminals into a combined screen to emit to one or more “outer” terminals that obtain input/output from the user. Multiplexers are thus both applications and terminals.

X - The column coordinate of a cell. This standard is 0-based: the left-most column of the screen is numbered 0.

Y - The row coordinate of a cell. This standard is 0-based: the top-most row of the screen is numbered 0.

Z - The layer that text or multimedia is placed on. This proposal uses a right-hand coordinate system with (X, Y, Z) = (0, 0, 0) defined as the top-left corner on the default layer: positive Z projects “away” from the user and “into” or “behind” the screen. Rendering the Cells on the screen must produce the same result as painter’s algorithm (see Rendering section below).

Cell - A fixed-width-and-height rectangle on the screen. The cells of the screen are arranged in a grid of X columns and Y rows. A Cell has dimensions of cellWidth and cellHeight, which can be measured in either pixels or points. Every Cell has a coordinate of (X, Y, Z).

Tile - One or more contiguous Cells with data to be displayed. The data can be text or image data, but not both. A Tile has width of 1, 2, or more, and a coordinate of (X, Y, Z) that is the same as its left-most (first) Cell’s (X, Y, Z). In practice, Tiles are typically one Cell wide for ASCII and Latin language glyphs, and two Cells wide for “fullwidth” glyphs as used in Asian langauges, emojis, and symbols. This standard does not preclude Tiles from encompassing entire grapheme clusters.

Layer - A screen-sized grid of Cells that have the same Z coordinate. Layers are drawn to the screen in descending Z order. Layers may have optional additional attributes such as transparency.

Rendering

A terminal will display its Cells such that the screen will look as if it was rendered in the following pseudo-code manner:

for each layer Z, in descending order from maxZ to minZ: for each row Y, in ascending order from minY to maxY: for each column X, in ascending order from minX to maxX: draw tile at (X, Y, Z) advance X by tile width next column advance Y by 1 next row decrease Z by 1 next layer

A terminal is free to optimize its rendering as it sees fit, so long as the final screen output looks equivalent to the above method.

Terminal State

Terminal Reports

Error Handling

Cursor Position

Wire Formats

Optimizations

Examples