Jameo Core Library
Loading...
Searching...
No Matches
Public Member Functions | Static Public Member Functions | Friends | List of all members
jm::Color Struct Reference

A class as a colour representation is so fundamental for us that it is used as a basic data type. The storage is as universal as possible. The special thing about this data type is that it stores the values "differently" depending on the mode. The data type is extremely space-saving. It only requires 6 bytes. More...

Public Member Functions

 Color ()
 Constructor.
 
 Color (const Color &other)
 Copy construktur.
 
 ~Color ()=default
 Destructor.
 
Coloroperator= (const Color &other)
 
const ColortoRgb ()
 Converts the colour to the RGB colour space.
 
void toCmyk ()
 Converts the colour to the CMYK colour space.
 
void toGreyScale ()
 Converts the colour to the greyscale colour space.
 
uint8 alpha () const
 Returns alpha component directly. 0 = transparent, 255 = opaque.
 
uint8 red () const
 Returns red component directly.
 
uint8 green () const
 Returns green component directly.
 
uint8 blue () const
 Returns blue component directly.
 
uint8 grey () const
 Returns grey component directly.
 
uint8 cyan () const
 Returns cyan component directly.
 
uint8 magenta () const
 Returns magenta component directly.
 
uint8 yellow () const
 Returns yellow component directly.
 
uint8 key () const
 Returns key (black) component directly.
 
ColorMode mode () const
 Returns the colour mode.
 
bool isWhite () const
 Is the colour white?
 
void hsvModel (float &hue, float &saturation, float &value) const
 Returns the HSV values of this colour. If the colour is not created in the RGB colour space, this method first temporarily converts the colour to the RFB colour space.
 
void setMode (ColorMode mode)
 Sets the colour space directly.
 
void setAlpha (uint8 alpha)
 Directly sets the transparency. 0 = transparent, 255 = opaque.
 
void setRed (uint8 red)
 Sets the red component directly.
 
void setGreen (uint8 green)
 Sets the green component directly.
 
void setBlue (uint8 blue)
 Sets the blue component directly.
 
void setGrey (uint8 grey)
 Sets the grey component directly.
 
void setCyan (uint8 cyan)
 Sets the cyan component directly.
 
void setMagenta (uint8 magenta)
 Sets the magenta component directly.
 
void setYellow (uint8 yellow)
 Sets the yellow component directly.
 
void setKey (uint8 key)
 Sets the key (black) component directly.
 

Static Public Member Functions

static Color fromGrey (uint8 grey, uint8 alpha=255)
 This method creates a colour in the colour space "greyscale". 0 means black, 255 means white.
 
static Color fromRgb (uint8 red, uint8 green, uint8 blue, uint8 alpha=255)
 This method creates a colour in the colour space "RGB". 0 means black/dark/no colour, 255 means white/light/full colour.
 
static Color fromCmyk (uint8 cyan, uint8 magenta, uint8 yellow, uint8 key, uint8 alpha=255)
 This method creates a colour in the colour space "CMYK". 0 means no colour (white on paper), 255 means full colour (dark on paper)
 
static Color FromHsv (float hue, float saturation, float value, float alpha=1.0)
 This method creates a colour in the colour space "RGB" using the HSV model. All specifications in the space from 0.0-1.0.
 

Friends

DllExport friend bool operator== (Color const &c1, Color const &c2)
 
DllExport friend bool operator!= (Color const &c1, Color const &c2)
 
DllExport friend Color operator- (Color const &c1, Color const &c2)
 
DllExport friend Color operator+ (Color const &c1, Color const &c2)
 
DllExport friend Color blend (Color background, Color foreground, uint8 alpha)
 
DllExport friend Color interpolate (Color colour1, Color colour2, float percent)
 

Detailed Description

A class as a colour representation is so fundamental for us that it is used as a basic data type. The storage is as universal as possible. The special thing about this data type is that it stores the values "differently" depending on the mode. The data type is extremely space-saving. It only requires 6 bytes.

Constructor & Destructor Documentation

◆ Color() [1/2]

jm::Color::Color ( )

Constructor.

◆ Color() [2/2]

jm::Color::Color ( const Color other)

Copy construktur.

Parameters
otherThe colour we became a copy of.

◆ ~Color()

jm::Color::~Color ( )
default

Destructor.

Member Function Documentation

◆ alpha()

uint8 jm::Color::alpha ( ) const

Returns alpha component directly. 0 = transparent, 255 = opaque.

Value is colour space independent.

◆ blue()

uint8 jm::Color::blue ( ) const

Returns blue component directly.

Note
Value only has a meaning in RGB mode

◆ cyan()

uint8 jm::Color::cyan ( ) const

Returns cyan component directly.

Note
Value only has meaning in CMYK mode

◆ fromCmyk()

static Color jm::Color::fromCmyk ( uint8  cyan,
uint8  magenta,
uint8  yellow,
uint8  key,
uint8  alpha = 255 
)
static

This method creates a colour in the colour space "CMYK". 0 means no colour (white on paper), 255 means full colour (dark on paper)

◆ fromGrey()

static Color jm::Color::fromGrey ( uint8  grey,
uint8  alpha = 255 
)
static

This method creates a colour in the colour space "greyscale". 0 means black, 255 means white.

◆ FromHsv()

static Color jm::Color::FromHsv ( float  hue,
float  saturation,
float  value,
float  alpha = 1.0 
)
static

This method creates a colour in the colour space "RGB" using the HSV model. All specifications in the space from 0.0-1.0.

◆ fromRgb()

static Color jm::Color::fromRgb ( uint8  red,
uint8  green,
uint8  blue,
uint8  alpha = 255 
)
static

This method creates a colour in the colour space "RGB". 0 means black/dark/no colour, 255 means white/light/full colour.

◆ green()

uint8 jm::Color::green ( ) const

Returns green component directly.

Note
Value only has a meaning in RGB mode

◆ grey()

uint8 jm::Color::grey ( ) const

Returns grey component directly.

Note
Value only has meaning in greyscale mode.

◆ hsvModel()

void jm::Color::hsvModel ( float &  hue,
float &  saturation,
float &  value 
) const

Returns the HSV values of this colour. If the colour is not created in the RGB colour space, this method first temporarily converts the colour to the RFB colour space.

Parameters
hueOutput filled in with the hue value.
saturationOutput filled in with the saturation value.
valueOutput filled in with the brightness value.

◆ isWhite()

bool jm::Color::isWhite ( ) const

Is the colour white?

◆ key()

uint8 jm::Color::key ( ) const

Returns key (black) component directly.

Note
Value only has meaning in CMYK mode

◆ magenta()

uint8 jm::Color::magenta ( ) const

Returns magenta component directly.

Note
Value only has meaning in CMYK mode

◆ mode()

ColorMode jm::Color::mode ( ) const

Returns the colour mode.

◆ operator=()

Color & jm::Color::operator= ( const Color other)

◆ red()

uint8 jm::Color::red ( ) const

Returns red component directly.

Note
Value only has a meaning in RGB mode

◆ setAlpha()

void jm::Color::setAlpha ( uint8  alpha)

Directly sets the transparency. 0 = transparent, 255 = opaque.

◆ setBlue()

void jm::Color::setBlue ( uint8  blue)

Sets the blue component directly.

Note
Value only has a meaning in RGB mode. In other colour spaces, the colour is changed incorrectly.

◆ setCyan()

void jm::Color::setCyan ( uint8  cyan)

Sets the cyan component directly.

Note
Value only has a meaning in CMYK mode. In other colour spaces, the colour is changed incorrectly.

◆ setGreen()

void jm::Color::setGreen ( uint8  green)

Sets the green component directly.

Note
Value only has a meaning in RGB mode. In other colour spaces, the colour is changed incorrectly.

◆ setGrey()

void jm::Color::setGrey ( uint8  grey)

Sets the grey component directly.

Note
Value only has a meaning in grey scale mode. In other colour spaces, the colour is changed incorrectly.

◆ setKey()

void jm::Color::setKey ( uint8  key)

Sets the key (black) component directly.

Note
Value only has a meaning in CMYK mode. In other colour spaces, the colour is changed incorrectly.

◆ setMagenta()

void jm::Color::setMagenta ( uint8  magenta)

Sets the magenta component directly.

Note
Value only has a meaning in CMYK mode. In other colour spaces, the colour is changed incorrectly.

◆ setMode()

void jm::Color::setMode ( ColorMode  mode)

Sets the colour space directly.

Note
There is no conversion of values.

◆ setRed()

void jm::Color::setRed ( uint8  red)

Sets the red component directly.

Note
Value only has a meaning in RGB mode. In other colour spaces, the colour is changed incorrectly.

◆ setYellow()

void jm::Color::setYellow ( uint8  yellow)

Sets the yellow component directly.

Note
Value only has a meaning in CMYK mode. In other colour spaces, the colour is changed incorrectly.

◆ toCmyk()

void jm::Color::toCmyk ( )

Converts the colour to the CMYK colour space.

◆ toGreyScale()

void jm::Color::toGreyScale ( )

Converts the colour to the greyscale colour space.

The following algorithm is used: G = 0.2126 R + 0.7152 G + 0.0722 B.

◆ toRgb()

const Color & jm::Color::toRgb ( )

Converts the colour to the RGB colour space.

◆ yellow()

uint8 jm::Color::yellow ( ) const

Returns yellow component directly.

Note
Value only has meaning in CMYK mode

Friends And Related Symbol Documentation

◆ blend

DllExport friend Color blend ( Color  background,
Color  foreground,
uint8  alpha 
)
friend

◆ interpolate

DllExport friend Color interpolate ( Color  colour1,
Color  colour2,
float  percent 
)
friend

◆ operator!=

DllExport friend bool operator!= ( Color const &  c1,
Color const &  c2 
)
friend

◆ operator+

DllExport friend Color operator+ ( Color const &  c1,
Color const &  c2 
)
friend

◆ operator-

DllExport friend Color operator- ( Color const &  c1,
Color const &  c2 
)
friend

◆ operator==

DllExport friend bool operator== ( Color const &  c1,
Color const &  c2 
)
friend

Member Data Documentation

◆ blue

uint8 jm::Color::blue

◆ [struct]

struct { ... } jm::Color::cmyk

◆ cyan

uint8 jm::Color::cyan

◆ [struct]

struct { ... } jm::Color::g

◆ green

uint8 jm::Color::green

◆ grey

uint8 jm::Color::grey

◆ key

uint8 jm::Color::key

◆ magenta

uint8 jm::Color::magenta

◆ red

uint8 jm::Color::red

◆ [struct]

struct { ... } jm::Color::rgb

◆ yellow

uint8 jm::Color::yellow