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, the View’s canvas is just a vector of ColChars under the hood. ColChar has the text_char and modifier properties. text_char is the single ascii character used as the “pixel” when the View is rendered, whereas modifier 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.
  • The Pixel holds a single Vec2D (the coordinates at which it is printed when blit to a View) and a ColChar
  • 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 ViewElements. In normal use, you would clear the View, blit all your ViewElements 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 by ColChar 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 a View

Type Aliases§

  • PointDeprecated
    Old name for Pixel, this is now deprecated