6#include <Sawyer/CommandLine.h>
111 static Ptr instance() {
128 return std::max(T(0), std::min(c, T(1)));
142 RGB(): r_(1.0), g_(0.0), b_(0.0), a_(1.0) {}
188 HSV(): h_(0.0), s_(1.0), v_(0.5), a_(1.0) {}
257 colors_.
insert(0.0, color1);
258 colors_.
insert(1.0, color2);
345std::ostream& operator<<(std::ostream&,
const RGB&);
346std::ostream& operator<<(std::ostream&,
const HSV&);
347std::ostream& operator<<(std::ostream&,
const Gradient&);
352extern const HSV HSV_CLEAR;
virtual Sawyer::CommandLine::ParsedValues operator()(const Sawyer::CommandLine::ParsedValues &prev, const Sawyer::CommandLine::ParsedValues &cur)
Called when a switch's value is about to be stored into the ParserResult.
Parses an output color specification.
static Ptr instance()
Allocating constructor.
Sawyer::SharedPointer< ColorizationParser > Ptr
Shared ownership pointer to a ColorizationParser.
static Colorization parse(const char *input, const char **rest)
Parse a colorized output specification from a C string.
static Colorization parse(const std::string &input)
Parse a colorized output specification from a C++ string.
static Ptr instance(const Sawyer::CommandLine::ValueSaver::Ptr &valueSaver)
Allocating constructor.
static std::string docString()
Documentation for parser.
Mapping from floating point to color.
HSV operator()(double x) const
Return a color for the specified position.
Gradient(const HSV &color)
Construct a one-color gradient.
const ColorMap & colorMap() const
Reference to color map.
Gradient(const RGB &color)
Construct a one-color gradient.
void insert(double where, const HSV &color)
Insert a point into the gradient.
const HSV & nanColor() const
Color for NaN lookups.
ColorMap & colorMap()
Reference to color map.
void clear()
Remove all points from the gradient.
void nanColor(const HSV &c)
Color for NaN lookups.
Gradient(const HSV &color1, const HSV &color2)
Construct a mapping with two colors.
HSV interpolate(double) const
Return a color for the specified position.
Gradient()
Default constructor.
Component v() const
Component of color.
Component hue() const
Component of color.
HSV(Component h, Component s, Component v, Component a=1.0)
Construct a color from components.
Component value() const
Component of color.
HSV()
Default constructed color.
Component h() const
Component of color.
std::string toHtml() const
Convert to HTML string.
Component alpha() const
Component of color.
HSV(const RGB &)
Convert an RGB color to HSV space.
Component a() const
Component of color.
Component s() const
Component of color.
std::string toAnsi(Layer) const
Convert to ANSI color escape.
Component saturation() const
Component of color.
RGB(const HSV &)
Convert an HSV color to RGB space.
RGB(Component r, Component g, Component b, Component a=1.0)
Construct a color specified by components.
Component blue() const
Component of color.
Component red() const
Component of color.
std::string toHtml() const
Convert to HTML string.
Component r() const
Component of color.
Component a() const
Component of color.
Component g() const
Component of color.
Component b() const
Component of color.
RGB()
Default constructed color.
Component alpha() const
Component of color.
Component green() const
Component of color.
std::string toAnsi(Layer) const
Convert to ANSI color escape.
Information about a parsed switch value.
Base class for value agumentors.
Base class parsing a value from input.
const ValueSaver::Ptr valueSaver() const
Property: functor responsible for saving a parsed value in user storage.
Container associating values with keys.
Map & insert(const Key &key, const Value &value)
Insert or update a key/value pair.
Map & clear()
Remove all nodes.
Holds a value or nothing.
ROSE_UTIL_API HSV lighten(const HSV &, double amount)
Lighten a color.
const HSV HSV_MAGENTA
Magenta.
std::string colorName(AnsiColor)
Convert a color enum to a string.
const HSV HSV_WHITE
White.
const HSV HSV_GREEN
Green.
AnsiColor
ANSI color names for terminal output.
const HSV HSV_YELLOW
Yellow.
double Component
Type for color components.
Layer
Layer to which color applies.
@ BACKGROUND
Background colors.
@ FOREGROUND
Foreground colors.
const HSV HSV_BLACK
Black.
ROSE_UTIL_API HSV darken(const HSV &, double amount)
Darken a color.
Enabled
Whether colored output is enabled.
@ OFF
Disable colored output.
@ ON
Force colored output.
@ AUTO
Use colored output if standard output is a terminal.
@ DARK_ON_LIGHT
Dark text on light background.
@ LIGHT_ON_DARK
Light text on dark background.
ROSE_UTIL_API HSV fade(const HSV &, double amount)
Make a color less saturated.
ROSE_UTIL_API std::string toHtml(const RGB &)
Create an HTML color string.
HSV invertBrightness(const HSV &)
Invert the brightness.
ROSE_UTIL_API std::string toAnsi(const RGB &, Layer)
Create an ANSI color escape.
HSV terminal(const HSV &color, const Colorization &)
Adjust color for terminal.
T clip(T c)
Clip a floating point value between 0 and 1.
std::string ansiColorEscape(AnsiColor)
ANSI color escape for terminal output.
std::vector< ParsedValue > ParsedValues
A vector of parsed values.
Control colored command output.
Sawyer::Optional< Theme > theme
The color theme.
Sawyer::Optional< Enabled > enabled
Whether colored output is enabled.
bool isEnabled() const
True if color is enabled in this situation.
Colorization merge(const Colorization &) const
Merge this color and another to produce a result.
Position within a command-line.