80template <
typename State>
117template <
typename State>
132 std::ostringstream
out;
133 out <<
"\033[48;2;" <<
static_cast<unsigned>(c.
r) <<
';' <<
static_cast<unsigned>(c.
g) <<
';'
134 <<
static_cast<unsigned>(c.
b) <<
'm' <<
glyph <<
"\033[0m";
167template <
typename Lattice,
typename Palette>
173 { p(v) } -> std::convertible_to<std::string>;
177 static_assert(
Lattice::rank == 2,
"render_ascii requires a rank-2 frame");
185 if constexpr (
requires {
palette.glyph_width(); })
192 out <<
opts.line_prefix <<
'+';
201 if (
opts.include_border)
207 if (
opts.include_border)
211 if (
opts.include_border)
217 if (
r + 1 < frame.
size(0)
or opts.include_border
or opts.include_trailing_newline)
221 if (
opts.include_border)
236template <
typename Lattice,
typename Palette>
241 { p(v) } -> std::convertible_to<std::string>;
244 std::ostringstream
out;
256template <
typename Lattice>
269template <
typename Lattice>
273 std::ostringstream
out;
285template <
typename Palette>
313 template <
typename Lattice>
317 *
out_ <<
"# step " << step <<
'\n';
329template <
typename Palette>
Exception handling system with formatted messages for Aleph-w.
#define ah_runtime_error_if(C)
Throws std::runtime_error if condition holds.
size_t size_t int32_t value
size_t size_t int32_t * out
File-format readers and writers for cellular-automata frames.
Stream sink that writes textual frames to an output stream.
Ascii_Frame_Sink(std::ostream &out, Palette palette, Ascii_Render_Options opts={}, const bool include_step_header=true)
Build a stream-backed ASCII sink.
Ascii_Render_Options opts_
void accept(const std::size_t step, const Lattice &frame)
Write one textual frame.
void flush()
Flush the wrapped stream.
bool include_step_header_
Lattice that adds boundary-aware access on top of a storage.
typename Storage::state_type state_type
typename Storage::coord_type coord_type
static constexpr std::size_t rank
ca_size_t size() const noexcept
state_type at(const coord_type &c) const
Strict access: throws if c is out of range.
size_t blossom_maximum_cardinality_matching(const GT &g, DynDlist< typename GT::Arc * > &matching, SA sa=SA())
Alias of compute_maximum_cardinality_general_matching().
void render_ascii(std::ostream &out, const Lattice &frame, Palette &&palette, const Ascii_Render_Options &opts={})
Render a rank-2 frame as text.
std::string render_ascii_string(const Lattice &frame, Palette &&palette, const Ascii_Render_Options &opts={})
Return the text rendering of a rank-2 frame.
std::size_t ca_size_t
Unsigned size component used for extents and counts.
Main namespace for Aleph-w library functions.
Options for textual CA rendering.
bool include_border
draw a simple +---+ border
std::string line_prefix
text prepended to every row
bool include_trailing_newline
append newline after the last row
ANSI 24-bit colour palette for binary frames.
State dead
state considered dead
RGB8 alive_colour
background colour for live cells
std::string glyph
glyph painted with the background
std::string operator()(const State &value) const
Map a cell state to an ANSI-coloured glyph.
std::size_t glyph_width() const noexcept
Visible width of a single rendered cell, in columns.
RGB8 dead_colour
background colour for dead cells
Default binary text palette.
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.
std::string dead_glyph
glyph for dead cells
State dead
state considered dead
std::string alive_glyph
glyph for live cells
RGB byte triplet used by PPM exporters.
std::uint8_t g
green channel
std::uint8_t b
blue channel
std::uint8_t r
red channel
C++20 concepts for the Cellular Automata module.