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

Description

Colors.

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.
 

Enumerations

enum class  Enabled {
  OFF ,
  ON ,
  AUTO
}
 Whether colored output is enabled. More...
 
enum class  Theme {
  DARK_ON_LIGHT ,
  LIGHT_ON_DARK
}
 Color theme. More...
 
enum class  Layer {
  NONE ,
  FOREGROUND ,
  BACKGROUND
}
 Layer to which color applies. More...
 
enum class  AnsiColor {
  CLEAR ,
  RED ,
  GREEN ,
  YELLOW ,
  BLUE ,
  MAGENTA ,
  CYAN ,
  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.
 
HSV invertBrightness (const HSV &)
 Invert the brightness.
 
ROSE_UTIL_API HSV darken (const HSV &, double amount)
 Darken a color.
 
ROSE_UTIL_API HSV lighten (const HSV &, double amount)
 Lighten a color.
 
ROSE_UTIL_API HSV fade (const HSV &, double amount)
 Make a color less saturated.
 
HSV terminal (const HSV &color, const Colorization &)
 Adjust color for terminal.
 
ROSE_UTIL_API std::string toHtml (const RGB &)
 Create an HTML color string.
 
ROSE_UTIL_API std::string toAnsi (const RGB &, Layer)
 Create an ANSI color escape.
 
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.
 
std::string ansiColorEscape (AnsiColor)
 ANSI color escape for terminal output.
 

Variables

const HSV HSV_CLEAR
 
const HSV HSV_BLACK
 Black.
 
const HSV HSV_WHITE
 White.
 
const HSV HSV_RED
 Red.
 
const HSV HSV_GREEN
 Green.
 
const HSV HSV_BLUE
 Blue.
 
const HSV HSV_CYAN
 Cyan.
 
const HSV HSV_MAGENTA
 Magenta.
 
const HSV HSV_YELLOW
 Yellow.
 
const HSV HSV_GRAY
 Gray.
 

Typedef Documentation

◆ Component

typedef double Rose::Color::Component

Type for color components.

ROSE doesn't do any heavy lifting of colors, so there's no need to distinguish between 8-bit colors, 16-bit colors, etc. Therefore we just use floating point for everything.

Definition at line 123 of file Color.h.

Enumeration Type Documentation

◆ Enabled

enum class Rose::Color::Enabled
strong

Whether colored output is enabled.

Enumerator
OFF 

Disable colored output.

ON 

Force colored output.

AUTO 

Use colored output if standard output is a terminal.

Definition at line 22 of file Color.h.

◆ Theme

enum class Rose::Color::Theme
strong

Color theme.

Controls whether to use dark text on a light background, or light text on a dark background.

Enumerator
DARK_ON_LIGHT 

Dark text on light background.

LIGHT_ON_DARK 

Light text on dark background.

Definition at line 31 of file Color.h.

◆ Layer

enum class Rose::Color::Layer
strong

Layer to which color applies.

Enumerator
NONE 

No specific layer.

FOREGROUND 

Foreground colors.

BACKGROUND 

Background colors.

Definition at line 49 of file Color.h.

◆ AnsiColor

enum class Rose::Color::AnsiColor
strong

ANSI color names for terminal output.

Enumerator
CLEAR 

Clear.

RED 

Red.

GREEN 

Green.

YELLOW 

Yellow.

BLUE 

Blue.

MAGENTA 

Magenta.

CYAN 

Cyan.

GRAY 

Gray.

Definition at line 366 of file Color.h.

Function Documentation

◆ clip()

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

Clip a floating point value between 0 and 1.

Definition at line 127 of file Color.h.

Referenced by Rose::Color::HSV::HSV(), and Rose::Color::RGB::RGB().

◆ invertBrightness()

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.

◆ darken()

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.

◆ lighten()

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.

◆ fade()

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.

◆ terminal()

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.

◆ toHtml()

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

Create an HTML color string.

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

◆ toAnsi()

ROSE_UTIL_API std::string Rose::Color::toAnsi ( const RGB ,
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.

◆ ansiColorEscape()

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

ANSI color escape for terminal output.

Indexed by ColorName.