Display class

The "backing store" that a renderable terminal uses to tell which glyphs actually need rendering.

Drawing a glyph on screen is the most expensive operation a terminal performs, so we want to avoid doing that when not necessary. The simplest solution is to render the glyphs that are drawn when a terminal draw call is made. However, it's common for a given terminal cell to be drawn multiple times between updates. Often, the final result is the same as what was previously on screen.

For example, consider a terminal for a game. It renders a "." floor tile, then renders the "/" on top of that for an item on the floor, then a "M" for the monster standing on that tile. The end user only sees the "M". The next frame, the process repeats and the ".", "/", and "M" are drawn.

If we render eagerly, that's a ton of wasted effort to end up with the same pixels that are on screen. What we want is to let the code modify as many glyphs as it wants as many times as it wants. Once that entire draw process is complete, we see which glyphs ended up different from the last time the terminal was shown to the user and just render those.

That's what this class does. It maintains two arrays of glyphs. One represents what was last shown to the user. The other represents what modifications have been made to the terminal since then. When the terminal is written to, this keeps track of which glyphs are actually different from the last render and which are the same.

Once that's done, you can call render. That will invoke the callback to actually draw a glyph, but only for the ones that are actually modified.

Constructors

Display(int width, int height)

Properties

hashCode int
The hash code for this object.
no setterinherited
height int
no setter
runtimeType Type
A representation of the runtime type of the object.
no setterinherited
size → Vec
no setter
width int
no setter

Methods

noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
render(RenderGlyph renderGlyph) → void
Calls renderGlyph for every glyph that has changed since the last call to render.
setGlyph(int x, int y, Glyph glyph) → void
Sets the cell at x, y, to glyph.
toString() String
A string representation of this object.
inherited

Operators

operator ==(Object other) bool
The equality operator.
inherited