griddle library
Griddle is a canvas-like drawing API based on a 2D grid of cells.
Griddle has only three concepts to master:
- Cells, which a single character codes and, optionally, colors.
- Buffers, which are painting contexts made up of a 2D grid of Cells.
- Screens, which write a Buffer to an updateable (external) display.
Screen can be optionally combined with a Display for simplicty:
// NOT required, just an example to get running with a few lines of code.
import 'dart:io' show stdout;
void main() {
final screen = Screen.display(
Display.fromAnsiTerminal(
stdout,
width: () => stdout.terminalColumns,
height: () => stdout.terminalLines,
)
);
// Use your screen!
}
Or, for testing and continuous integration-like environments:
void main() {
final buffer = StringBuffer();
final screen = Screen.display(
Display.fromStringBuffer(
buffer,
/* Optionally set width: ... and height: ..., defaults to 80x25 */
),
);
// Use your screen!
}
We expect higher-level APIs to built on top of Griddle in the future!
Classes
- Buffer
- Stores a 2D buffer of cells.
- Cell
- A two-dimensional cell, sometimes called a "pixel", within a screen.
- Color
- An immutable 32-bit color value in ARGB format.
- Display
- A display is an optional external "backend" API for use with a screen.
- Screen
-
A screen is the root building block in
griddle
, a 2D grid of cells. - WritableBuffer
- Stores a writable 2D buffer of cells.