spice::print namespace

Contents

This namespace exports utilities to print some of spice's types to the console. These are mainly meant for debugging purposes.

Functions

template<typename T_data = float, typename T_color = color<T_data>>
auto color_escape_string(std::string const& str, T_color const& foreground, T_color const& background) -> std::string
template<typename T>
void image(image<T> const& img, size_t stride = 1, std::ostream& stream = std::cout)
template<typename T = float>
void histogram(std::vector<std::vector<size_t>> const& histogram, size_t max_amplitude, std::vector<color<T>> const& colors, std::ostream& stream = std::cout)

Function documentation

template<typename T_data = float, typename T_color = color<T_data>>
std::string spice::print::color_escape_string(std::string const& str, T_color const& foreground, T_color const& background)

Parameters
str The string to surround with escape codes
foreground The text colour
background The background colour

Insert escape codes for terminals supporting 8 bpc colours into a string.

template<typename T>
void spice::print::image(image<T> const& img, size_t stride = 1, std::ostream& stream = std::cout)

Prints an image in pixel-art style to the stream.

Image

template<typename T = float>
void spice::print::histogram(std::vector<std::vector<size_t>> const& histogram, size_t max_amplitude, std::vector<color<T>> const& colors, std::ostream& stream = std::cout)

Parameters
histogram The data to print
max_amplitude The length of the longest bar in single spaces
colors The colour to print each channel in. Note that the colours should be represented as RGB, superfluous colours will be ignored and missing colours will be represented as grey.
stream The stream to insert the histogram into

Prints a histogram to the provided stream.