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

Description

Colors.

Namespaces

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

Classes

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...
 

Typedefs

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

Enumerations

enum  AnsiColor {
  ANSI_CLEAR,
  ANSI_RED,
  ANSI_GREEN,
  ANSI_YELLOW,
  ANSI_BLUE,
  ANSI_MAGENTA,
  ANSI_CYAN,
  ANSI_GRAY
}
 ANSI color names for terminal output. More...
 

Functions

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...
 

Variables

const HSV HSV_CLEAR
 
const HSV HSV_BLACK
 
const HSV HSV_WHITE
 
const HSV HSV_RED
 
const HSV HSV_GREEN
 
const HSV HSV_BLUE
 
const HSV HSV_CYAN
 
const HSV HSV_MAGENTA
 
const HSV HSV_YELLOW
 
const HSV HSV_GRAY
 

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 Rose/Color.h.

Enumeration Type Documentation

ANSI color names for terminal output.

Definition at line 359 of file Rose/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 Rose/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.