Dusk Audio Framework
Loading...
Searching...
No Matches
Color Struct Reference

#include <Color.hpp>

Classes

union  [union].__unnamed0__

Public Member Functions

 Color () noexcept
 Color (int red, int green, int blue, float alpha=1.0f) noexcept
 Color (float red, float green, float blue, float alpha=1.0f) noexcept
 Color (const Color &color) noexcept
Color & operator= (const Color &color) noexcept
 Color (const Color &color1, const Color &color2, float u) noexcept
Color withAlpha (float alpha) const noexcept
Color minus (int value) const noexcept
Color minus (float value) const noexcept
Color plus (int value) const noexcept
Color plus (float value) const noexcept
Color invert () const noexcept
Color asGrayscale () const noexcept
void interpolate (const Color &other, float u) noexcept
bool isEqual (const Color &color, bool withAlpha=true) noexcept
bool isNotEqual (const Color &color, bool withAlpha=true) noexcept
bool operator== (const Color &color) noexcept
bool operator!= (const Color &color) noexcept
void fixBounds () noexcept
void setFor (const GraphicsContext &context, bool includeAlpha=false)
 Color (const NVGcolor &) noexcept
 operator NVGcolor () const noexcept

Static Public Member Functions

static Color fromHSL (float hue, float saturation, float lightness, float alpha=1.0f)
static Color fromHTML (const char *rgb, float alpha=1.0f) noexcept
static Color fromRGB (uint color, float alpha=1.0f) noexcept

Public Attributes

union  

Detailed Description

A color made from red, green, blue and alpha floating-point values in [0..1] range.

Constructor & Destructor Documentation

◆ Color() [1/5]

Color::Color ( )
noexcept

Create solid black color.

◆ Color() [2/5]

Color::Color ( int red,
int green,
int blue,
float alpha = 1.0f )
noexcept

Create a color from red, green, blue and alpha numeric values. All values except alpha must be in [0..255] range, with alpha in [0..1] range.

◆ Color() [3/5]

Color::Color ( float red,
float green,
float blue,
float alpha = 1.0f )
noexcept

Create a color from red, green, blue and alpha floating-point values. All values must in [0..1] range.

◆ Color() [4/5]

Color::Color ( const Color & color)
noexcept

Create a color by copying another color.

◆ Color() [5/5]

Color::Color ( const Color & color1,
const Color & color2,
float u )
noexcept

Create a color by linearly interpolating two other colors.

Member Function Documentation

◆ withAlpha()

Color Color::withAlpha ( float alpha) const
noexcept

Create a new color based on this one but with a different alpha value.

◆ minus() [1/2]

Color Color::minus ( int value) const
noexcept

Create a new color based on this one but with subtracted numeric value on all elements. Value must be in [0..255] range.

◆ minus() [2/2]

Color Color::minus ( float value) const
noexcept

Create a new color based on this one but with subtracted floating-point value on all elements. Value must be in [0..1] range.

◆ plus() [1/2]

Color Color::plus ( int value) const
noexcept

Create a new color based on this one but with added numeric value on all elements. Value must be in [0..255] range.

◆ plus() [2/2]

Color Color::plus ( float value) const
noexcept

Create a new color based on this one but with added floating-point value on all elements. Value must be in [0..1] range.

◆ invert()

Color Color::invert ( ) const
noexcept

Create a new color based on this one but colors inverted.

◆ asGrayscale()

Color Color::asGrayscale ( ) const
noexcept

Create a new color based on this one but in grayscale (using weighted average).

◆ fromHSL()

Color Color::fromHSL ( float hue,
float saturation,
float lightness,
float alpha = 1.0f )
static

Create a color specified by hue, saturation and lightness. Values must in [0..1] range.

◆ fromHTML()

Color Color::fromHTML ( const char * rgb,
float alpha = 1.0f )
staticnoexcept

Create a color from a HTML string like "#333" or "#112233".

◆ fromRGB()

Color Color::fromRGB ( uint color,
float alpha = 1.0f )
staticnoexcept

Create a color from a RGB unsigned integer. Basically doing:

uint8_t red = (color >> 24) & 0xff;
uint8_t green = (color >> 16) & 0xff;
uint8_t blue = (color >> 8) & 0xff;

◆ interpolate()

void Color::interpolate ( const Color & other,
float u )
noexcept

Linearly interpolate this color against another.

◆ isEqual()

bool Color::isEqual ( const Color & color,
bool withAlpha = true )
noexcept

Check if this color matches another.

Note
Comparison is done within 8-bit color space.

◆ fixBounds()

void Color::fixBounds ( )
noexcept

Fix color bounds if needed.

◆ setFor()

void Color::setFor ( const GraphicsContext & context,
bool includeAlpha = false )

Set this color for use in the next drawing operation for the provided context.


The documentation for this struct was generated from the following file: