Module gemini_engine::elements::view
source · Expand description
This module is home to the View
struct, which handles the printing of pixels to an ANSI standard text output
Modules§
- A module containing various helper functions and structs
Structs§
- We use
ColChar
to say exactly what each pixel should look like and what colour it should be. That is, theView
’s canvas is just a vector ofColChar
s under the hood.ColChar
has thetext_char
andmodifier
properties.text_char
is the single ascii character used as the “pixel” when theView
is rendered, whereasmodifier
can give that pixel a colour or make it bold/italic - A struct to contain colour values. Can be created from RGB, HSV or greyscale values, but is ultimately stored as RGB.
- A wrapper around a
View
which auto resizes to fit the terminal window - A pair of
isize
used for coordinates, size or direction on a 2D plane - The View struct is the canvas on which you will print all of your
ViewElement
s. In normal use, you would clear the View,blit
all yourViewElement
s to it and then render. The following example demonstrates a piece of code that will render a View of width 9 and height 3, with a single Pixel in the middle
Enums§
- The
Modifier
enum is used for adding modifications to text such as colour, bold/italic/underline and others. It’s essentially a wrapper for\x1b[{x}m
, where {x} is a code or rgb value of some sort.Modifier
is primarily used byColChar
as one of its properties - Wrapping is used to determine how you want to handle out-of-bounds pixels during plotting pixels to the screen. Here’s how each possible value functions:
Traits§
ViewElement
is a trait that must be implemented by any element that can be blitted to aView