Color

class

A RGB color representation, generic for display devices.

This class implements a 16-bit RGB 5-6-5 color model. It support methods for calculating color blendings and more.

The class definition also define a set of global constant predefined colors, like white, red, green, blue and black. Further, it includes a set of the FlatUI colors that Mono uses:

  • Clouds
  • WetAsphalt
  • Concrete
  • Silver
  • Asbestos
  • BelizeHole
  • MidnightBlue
  • Alizarin
  • Turquoise
  • Emerald

Public Functions

Color::Color()

Construct a black color.

Color::Color(const int col)

Construct a color from an existing 5-6-5 encoded value.

This constructor takes a an integer an casts it to a 5-6-5 RGB color, from from the integers LSB’s.

Parameters
  • col -

    The 5-6-5 RGB color value

Color::Color(uint8_t R, uint8_t G, uint8_t B)

Construct a color from individual RGB components.

You provide 8-bit RGB components to create the color.

Parameters
  • R -

    The red component, 0 to 255

  • G -

    The red component, 0 to 255

  • B -

    The red component, 0 to 255

uint8_t Color::Red()
const

Return 8-bit red color component

uint8_t Color::Green()
const

Return 8-bit green color component

uint8_t Color::Blue()
const

Return 8-bit blue color component

Color Color::scale(uint8_t factor)
const

Misc.

Multiply each RGB channel by a factor from 0-255

Return
the scaled color

Color Color::blendMultiply(Color other)
const

Return the product of two colors

Return
the multiply blended color

Color Color::blendAdditive(Color other)
const

Add this color with another

Color Color::invert()
const

Return the inverse

Color Color::alphaBlend(uint8_t intensity, Color const &other)
const

Blend this color with another using a provided intensity.

Alpha blending is done when you need to combine two colors, say you wish to realize a gradient. If you blend black and white the intensity will define all the grayscales in between.

Use this method to realize an alpha channel that controls how transparent a certain color is. The alpha channel controls the intensity, and you must provide the color that lies behind the alpha blended color.

Return
The new blended color
Parameters
  • intensity -

    The intensity of this color, 0 to 255.

  • other -

    The color to blend with

mono::String Color::toString()
const

Get a human readable string representatio of the color.

Returns a string of the form: (RR, GG, BB)

Return
a color string