Aleph-w 3.0
A C++ Library for Data Structures and Algorithms
Loading...
Searching...
No Matches
Aleph::CA::Binary_ASCII_Palette< State > Struct Template Reference

Default binary text palette. More...

#include <ca-ascii.H>

Collaboration diagram for Aleph::CA::Binary_ASCII_Palette< State >:
[legend]

Public Member Functions

std::string operator() (const State &value) const
 Map a cell state to display text.
 
std::size_t glyph_width () const noexcept
 Visible width of a single rendered cell, in columns.
 

Public Attributes

State dead {}
 state considered dead
 
std::string dead_glyph = "."
 glyph for dead cells
 
std::string alive_glyph = "#"
 glyph for live cells
 

Detailed Description

template<typename State>
struct Aleph::CA::Binary_ASCII_Palette< State >

Default binary text palette.

Cells equal to dead use dead_glyph; all other states use alive_glyph.

Template Parameters
Statecell state type.

Definition at line 81 of file ca-ascii.H.

Member Function Documentation

◆ glyph_width()

template<typename State >
std::size_t Aleph::CA::Binary_ASCII_Palette< State >::glyph_width ( ) const
inlinenoexcept

Visible width of a single rendered cell, in columns.

Used by render_ascii to size the optional +---+ border so it aligns with the glyphs. Returns max(dead_glyph.size(), alive_glyph.size()).

Returns
number of terminal columns occupied by one cell.

Definition at line 103 of file ca-ascii.H.

References Aleph::CA::Binary_ASCII_Palette< State >::alive_glyph, and Aleph::CA::Binary_ASCII_Palette< State >::dead_glyph.

◆ operator()()

template<typename State >
std::string Aleph::CA::Binary_ASCII_Palette< State >::operator() ( const State &  value) const
inline

Map a cell state to display text.

Parameters
[in]valuecell value.
Returns
glyph text.

Definition at line 91 of file ca-ascii.H.

References Aleph::CA::Binary_ASCII_Palette< State >::alive_glyph, Aleph::CA::Binary_ASCII_Palette< State >::dead, Aleph::CA::Binary_ASCII_Palette< State >::dead_glyph, and value.

Member Data Documentation

◆ alive_glyph

template<typename State >
std::string Aleph::CA::Binary_ASCII_Palette< State >::alive_glyph = "#"

◆ dead

template<typename State >
State Aleph::CA::Binary_ASCII_Palette< State >::dead {}

state considered dead

Definition at line 83 of file ca-ascii.H.

Referenced by Aleph::CA::Binary_ASCII_Palette< State >::operator()().

◆ dead_glyph

template<typename State >
std::string Aleph::CA::Binary_ASCII_Palette< State >::dead_glyph = "."

The documentation for this struct was generated from the following file: