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
ColCharto say exactly what each pixel should look like and what colour it should be. That is, theView’s canvas is just a vector ofColChars under the hood.ColCharhas thetext_charandmodifierproperties.text_charis the single ascii character used as the “pixel” when theViewis rendered, whereasmodifiercan 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
Viewwhich auto resizes to fit the terminal window - A pair of
isizeused for coordinates, size or direction on a 2D plane - The View struct is the canvas on which you will print all of your
ViewElements. In normal use, you would clear the View,blitall yourViewElements 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
Modifierenum 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.Modifieris primarily used byColCharas 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§
ViewElementis a trait that must be implemented by any element that can be blitted to aView