5 #include <Sawyer/CommandLine.h>
6 #include <Sawyer/Map.h>
111 static Ptr instance() {
129 return std::max(T(0), std::min(c, T(1)));
143 RGB(): r_(1.0), g_(0.0), b_(0.0), a_(1.0) {}
167 std::string
toHtml()
const;
185 HSV(): h_(0.0), s_(1.0), v_(0.5), a_(1.0) {}
209 std::string
toHtml()
const;
250 colors_.
insert(0.0, color1);
251 colors_.
insert(1.0, color2);
276 HSV interpolate(
double)
const;
303 ROSE_UTIL_API HSV
darken(
const HSV&,
double amount);
309 ROSE_UTIL_API HSV
lighten(
const HSV&,
double amount);
315 ROSE_UTIL_API HSV
fade(
const HSV&,
double amount);
321 HSV
terminal(
const HSV &color,
const Colorization&);
326 ROSE_UTIL_API std::string
toHtml(
const RGB&);
338 std::ostream& operator<<(std::ostream&,
const RGB&);
339 std::ostream& operator<<(std::ostream&,
const HSV&);
340 std::ostream& operator<<(std::ostream&,
const Gradient&);
345 extern const HSV HSV_CLEAR;
346 extern const HSV HSV_BLACK;
347 extern const HSV HSV_WHITE;
348 extern const HSV HSV_RED;
349 extern const HSV HSV_GREEN;
350 extern const HSV HSV_BLUE;
351 extern const HSV HSV_CYAN;
352 extern const HSV HSV_MAGENTA;
353 extern const HSV HSV_YELLOW;
354 extern const HSV HSV_GRAY;
359 enum AnsiColor { ANSI_CLEAR, ANSI_RED, ANSI_GREEN, ANSI_YELLOW, ANSI_BLUE, ANSI_MAGENTA, ANSI_CYAN, ANSI_GRAY };
ColorMap & colorMap()
Reference to color map.
Information about a parsed switch value.
@ BACKGROUND
Background colors.
Sawyer::Optional< Enabled::Flag > enabled
Whether colored output is enabled.
HSV operator()(double x) const
Return a color for the specified position.
HSV terminal(const HSV &color, const Colorization &)
Adjust color for terminal.
void clear()
Remove all points from the gradient.
HSV()
Default constructed color.
Component blue() const
Component of color.
Component green() const
Component of color.
Component value() const
Component of color.
void nanColor(const HSV &c)
Color for NaN lookups.
ROSE_UTIL_API std::string toHtml(const RGB &)
Create an HTML color string.
Colorization merge(const Colorization &) const
Merge this color and another to produce a result.
Component saturation() const
Component of color.
static Colorization parse(const char *input, const char **rest)
Parse a colorized output specification from a C string.
Component alpha() const
Component of color.
Component hue() const
Component of color.
ROSE_UTIL_API HSV darken(const HSV &, double amount)
Darken a color.
HSV invertBrightness(const HSV &)
Invert the brightness.
@ ON
Force colored output.
Mapping from floating point to color.
Component v() const
Component of color.
static Ptr instance(const Sawyer::CommandLine::ValueSaver::Ptr &valueSaver)
Allocating constructor.
@ LIGHT_ON_DARK
Light text on dark background.
Component r() const
Component of color.
std::vector< ParsedValue > ParsedValues
A vector of parsed values.
RGB()
Default constructed color.
bool isEnabled() const
True if color is enabled in this situation.
RGB(Component r, Component g, Component b, Component a=1.0)
Construct a color specified by components.
const ColorMap & colorMap() const
Reference to color map.
Component b() const
Component of color.
Map & insert(const Key &key, const Value &value)
Insert or update a key/value pair.
Component g() const
Component of color.
Base class parsing a value from input.
std::string colorName(AnsiColor)
Convert a color enum to a string.
Gradient(const HSV &color)
Construct a one-color gradient.
void insert(double where, const HSV &color)
Insert a point into the gradient.
Control colored command output.
std::string ansiColorEscape(AnsiColor)
ANSI color escape for terminal output.
@ OFF
Disable colored output.
Gradient(const RGB &color)
Construct a one-color gradient.
Base class for value agumentors.
ROSE_UTIL_API std::string toAnsi(const RGB &, Layer::Flag layer)
Create an ANSI color escape.
Gradient()
Default constructor.
Gradient(const HSV &color1, const HSV &color2)
Construct a mapping with two colors.
Component a() const
Component of color.
static Ptr instance()
Allocating constructor.
@ DARK_ON_LIGHT
Dark text on light background.
Component red() const
Component of color.
HSV(Component h, Component s, Component v, Component a=1.0)
Construct a color from components.
@ AUTO
Use colored output if standard output is a terminal.
Parses an output color specification.
static std::string docString()
Documentation for parser.
Main namespace for the ROSE library.
@ FOREGROUND
Foreground colors.
double Component
Type for color components.
const ValueSaver::Ptr valueSaver() const
Property: functor responsible for saving a parsed value in user storage.
ROSE_UTIL_API HSV fade(const HSV &, double amount)
Make a color less saturated.
Component a() const
Component of color.
Component alpha() const
Component of color.
Position within a command-line.
AnsiColor
ANSI color names for terminal output.
Component s() const
Component of color.
Sawyer::Optional< Theme::Flag > theme
The color theme.
Sawyer::SharedPointer< ColorizationParser > Ptr
Shared ownership pointer to a ColorizationParser.
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.
Map & clear()
Remove all nodes.
const HSV & nanColor() const
Color for NaN lookups.
ROSE_UTIL_API HSV lighten(const HSV &, double amount)
Lighten a color.
T clip(T c)
Clip a floating point value between 0 and 1.
Component h() const
Component of color.