Namespaces | Classes | Typedefs | Enumerations | Functions | Variables
Rose::Color Namespace Reference




 Whether colored output is enabled.
 Layer to which color applies.
 Color theme.


struct  Colorization
 Control colored command output. More...
class  ColorizationMerge
class  ColorizationParser
 Parses an output color specification. More...
class  Gradient
 Mapping from floating point to color. More...
class  HSV
 Colors in HSV space. More...
class  RGB
 Colors in RGB space. More...


typedef double Component
 Type for color components. More...


enum  AnsiColor {
 ANSI color names for terminal output. More...


ColorizationParser::Ptr colorizationParser (Colorization &storage)
ColorizationParser::Ptr colorizationParser ()
template<typename T >
clip (T c)
 Clip a floating point value between 0 and 1. More...
HSV invertBrightness (const HSV &)
 Invert the brightness. More...
ROSE_UTIL_API HSV darken (const HSV &, double amount)
 Darken a color. More...
ROSE_UTIL_API HSV lighten (const HSV &, double amount)
 Lighten a color. More...
ROSE_UTIL_API HSV fade (const HSV &, double amount)
 Make a color less saturated. More...
HSV terminal (const HSV &color, const Colorization &)
 Adjust color for terminal. More...
ROSE_UTIL_API std::string toHtml (const RGB &)
 Create an HTML color string. More...
ROSE_UTIL_API std::string toAnsi (const RGB &, Layer::Flag layer)
 Create an ANSI color escape. More...
std::ostream & operator<< (std::ostream &, const RGB &)
std::ostream & operator<< (std::ostream &, const HSV &)
std::ostream & operator<< (std::ostream &, const Gradient &)
std::string colorName (AnsiColor)
 Convert a color enum to a string. More...
std::string ansiColorEscape (AnsiColor)
 ANSI color escape for terminal output. More...



Typedef Documentation

typedef double Rose::Color::Component

Type for color components.

FIXME[Robb P. Matzke 2014-12-19]: This should ideally be a template parameter so we can support 8-bit color, 16-bit color, floating point color using float or double, etc. At the moment, we'll use double since I don't expect that ROSE will be doing any heavy lifting of colors; i.e., no large image arrays, just color configuration kinds of things.

Definition at line 124 of file Color.h.

Enumeration Type Documentation

ANSI color names for terminal output.

Definition at line 359 of file Color.h.

Function Documentation

template<typename T >
T Rose::Color::clip ( c)

Clip a floating point value between 0 and 1.

Definition at line 128 of file Color.h.

HSV Rose::Color::invertBrightness ( const HSV )

Invert the brightness.

Light colors will become dark, dark colors will become light. The hue, saturation and alpha are not affected.

ROSE_UTIL_API HSV Rose::Color::darken ( const HSV ,
double  amount 

Darken a color.

Makes a color darker according to amount, which should be in the range [0..1]. If amount is zero then the value is not changed, if amount is one then the color becomes black, others are interpolated linearly. This method does not affect the hue, saturation, or alpha.

ROSE_UTIL_API HSV Rose::Color::lighten ( const HSV ,
double  amount 

Lighten a color.

Makes a color lighter by adjusting its value upward by the specified ratio. A value of zero does not affect the lightness while a value of one will make it white. Other values are linearly interpolated between those two points.

ROSE_UTIL_API HSV Rose::Color::fade ( const HSV ,
double  amount 

Make a color less saturated.

Makes a color less saturated according to amount. An amount of zero does not change the saturation, one removes all saturation, and other values are linearly interpolated between those two extremes.

HSV Rose::Color::terminal ( const HSV color,
const Colorization  

Adjust color for terminal.

Given a color suitable for a dark foreground on a light background (typical tty or printed output), convert the color as specified by the global color output command-line options.

ROSE_UTIL_API std::string Rose::Color::toHtml ( const RGB )

Create an HTML color string.

HTML color strings are of the form "#RRGGBB".

ROSE_UTIL_API std::string Rose::Color::toAnsi ( const RGB ,
Layer::Flag  layer 

Create an ANSI color escape.

These characters can be emitted to an ANSI terminal after the appropriate escape sequence in order to change the foreground or background color. The escape sequence is usually "\033[38;2;" for the foreground and "\033[48;2;" for the background. The foreground and background colors can be canceled by emitting "\033[0m". If a layer is specified, then the escape sequence is part of the return value. ANSI doesn't support alphas, so if the alpha is less than 0.5 the return value is an empty string.

std::string Rose::Color::colorName ( AnsiColor  )

Convert a color enum to a string.

std::string Rose::Color::ansiColorEscape ( AnsiColor  )

ANSI color escape for terminal output.

Indexed by ColorName.