Lamp-Da 0.1
A compact lantern project
Loading...
Searching...
No Matches
Classes | Typedefs | Enumerations | Functions | Variables
lampda::modes::colors Namespace Reference

Tools to manipulate colors and their representation. More...

Classes

struct  ToRGB
 Exposes (r, g, b) as uint8_t in struct from a single uint32_t color. More...
 

Typedefs

using PaletteTy = std::array< uint32_t, 16 >
 Palette types.
 

Enumerations

enum  ColorTemperature {
  Candle = 0xFF9329 , Tungsten40W = 0xFFC58F , Tungsten100W = 0xFFD6AA , Halogen = 0xFFF1E0 ,
  CarbonArc = 0xFFFAF4 , HighNoonSun = 0xFFFFFB , DirectSunlight = 0xFFFFFF , OvercastSky = 0xC9E2FF ,
  ClearBlueSky = 0x409CFF , WarmFluorescent = 0xFFF4E5 , StandardFluorescent = 0xF4FFFA , CoolWhiteFluorescent = 0xD4EBFF ,
  FullSpectrumFluorescent = 0xFFF4F2 , GrowLightFluorescent = 0xFFEFF7 , BlackLightFluorescent = 0xA700FF , MercuryVapor = 0xD8F7FF ,
  SodiumVapor = 0xFFD1B2 , MetalHalide = 0xF2FCFF , HighPressureSodium = 0xFFB74C , UncorrectedTemperature = 0xFFFFFF
}
 Color temperature values. More...
 
enum  HTMLColorCode {
  AliceBlue = 0xF0F8FF , Amethyst = 0x9966CC , AntiqueWhite = 0xFAEBD7 , Aqua = 0x00FFFF ,
  Aquamarine = 0x7FFFD4 , Azure = 0xF0FFFF , Beige = 0xF5F5DC , Bisque = 0xFFE4C4 ,
  Black = 0x000000 , BlanchedAlmond = 0xFFEBCD , Blue = 0x0000FF , BlueViolet = 0x8A2BE2 ,
  Brown = 0xA52A2A , BurlyWood = 0xDEB887 , CadetBlue = 0x5F9EA0 , Chartreuse = 0x7FFF00 ,
  Chocolate = 0xD2691E , Coral = 0xFF7F50 , CornflowerBlue = 0x6495ED , Cornsilk = 0xFFF8DC ,
  Crimson = 0xDC143C , Cyan = 0x00FFFF , DarkBlue = 0x00008B , DarkCyan = 0x008B8B ,
  DarkGoldenrod = 0xB8860B , DarkGray = 0xA9A9A9 , DarkGrey = 0xA9A9A9 , DarkGreen = 0x006400 ,
  DarkKhaki = 0xBDB76B , DarkMagenta = 0x8B008B , DarkOliveGreen = 0x556B2F , DarkOrange = 0xFF8C00 ,
  DarkOrchid = 0x9932CC , DarkRed = 0x8B0000 , DarkSalmon = 0xE9967A , DarkSeaGreen = 0x8FBC8F ,
  DarkSlateBlue = 0x483D8B , DarkSlateGray = 0x2F4F4F , DarkSlateGrey = 0x2F4F4F , DarkTurquoise = 0x00CED1 ,
  DarkViolet = 0x9400D3 , DeepPink = 0xFF1493 , DeepSkyBlue = 0x00BFFF , DimGray = 0x696969 ,
  DimGrey = 0x696969 , DodgerBlue = 0x1E90FF , FireBrick = 0xB22222 , FloralWhite = 0xFFFAF0 ,
  ForestGreen = 0x228B22 , Gainsboro = 0xDCDCDC , GhostWhite = 0xF8F8FF , Gold = 0xFFD700 ,
  Goldenrod = 0xDAA520 , Gray = 0x808080 , Grey = 0x808080 , Green = 0x008000 ,
  GreenYellow = 0xADFF2F , Honeydew = 0xF0FFF0 , HotPink = 0xFF69B4 , IndianRed = 0xCD5C5C ,
  Indigo = 0x4B0082 , Ivory = 0xFFFFF0 , Khaki = 0xF0E68C , Lavender = 0xE6E6FA ,
  LavenderBlush = 0xFFF0F5 , LawnGreen = 0x7CFC00 , LemonChiffon = 0xFFFACD , LightBlue = 0xADD8E6 ,
  LightCoral = 0xF08080 , LightCyan = 0xE0FFFF , LightGoldenrodYellow = 0xFAFAD2 , LightGreen = 0x90EE90 ,
  LightGrey = 0xD3D3D3 , LightPink = 0xFFB6C1 , LightSalmon = 0xFFA07A , LightSeaGreen = 0x20B2AA ,
  LightSkyBlue = 0x87CEFA , LightSlateGray = 0x778899 , LightSlateGrey = 0x778899 , LightSteelBlue = 0xB0C4DE ,
  LightYellow = 0xFFFFE0 , Lime = 0x00FF00 , LimeGreen = 0x32CD32 , Linen = 0xFAF0E6 ,
  Magenta = 0xFF00FF , Maroon = 0x800000 , MediumAquamarine = 0x66CDAA , MediumBlue = 0x0000CD ,
  MediumOrchid = 0xBA55D3 , MediumPurple = 0x9370DB , MediumSeaGreen = 0x3CB371 , MediumSlateBlue = 0x7B68EE ,
  MediumSpringGreen = 0x00FA9A , MediumTurquoise = 0x48D1CC , MediumVioletRed = 0xC71585 , MidnightBlue = 0x191970 ,
  MintCream = 0xF5FFFA , MistyRose = 0xFFE4E1 , Moccasin = 0xFFE4B5 , NavajoWhite = 0xFFDEAD ,
  Navy = 0x000080 , OldLace = 0xFDF5E6 , Olive = 0x808000 , OliveDrab = 0x6B8E23 ,
  Orange = 0xFFA500 , OrangeRed = 0xFF4500 , Orchid = 0xDA70D6 , PaleGoldenrod = 0xEEE8AA ,
  PaleGreen = 0x98FB98 , PaleTurquoise = 0xAFEEEE , PaleVioletRed = 0xDB7093 , PapayaWhip = 0xFFEFD5 ,
  PeachPuff = 0xFFDAB9 , Peru = 0xCD853F , Pink = 0xFFC0CB , Plaid = 0xCC5533 ,
  Plum = 0xDDA0DD , PowderBlue = 0xB0E0E6 , Purple = 0x800080 , Red = 0xFF0000 ,
  RosyBrown = 0xBC8F8F , RoyalBlue = 0x4169E1 , SaddleBrown = 0x8B4513 , Salmon = 0xFA8072 ,
  SandyBrown = 0xF4A460 , SeaGreen = 0x2E8B57 , Seashell = 0xFFF5EE , Sienna = 0xA0522D ,
  Silver = 0xC0C0C0 , SkyBlue = 0x87CEEB , SlateBlue = 0x6A5ACD , SlateGray = 0x708090 ,
  SlateGrey = 0x708090 , Snow = 0xFFFAFA , SpringGreen = 0x00FF7F , SteelBlue = 0x4682B4 ,
  Tan = 0xD2B48C , Teal = 0x008080 , Thistle = 0xD8BFD8 , Tomato = 0xFF6347 ,
  Turquoise = 0x40E0D0 , Violet = 0xEE82EE , Wheat = 0xF5DEB3 , White = 0xFFFFFF ,
  WhiteSmoke = 0xF5F5F5 , Yellow = 0xFFFF00 , YellowGreen = 0x9ACD32 , FairyLight = 0xFFE42D ,
  FairyLightNCC = 0xFF9D2A
}
 Define common HTML colors. More...
 

Functions

static constexpr uint8_t gamma8 (uint8_t value)
 used for color gamma correction
 
template<bool PaletteLoops = true, typename UIntTy = uint8_t>
static constexpr uint32_t from_palette (UIntTy index, const PaletteTy &palette, uint8_t brightness=255)
 Return a color from a palette.
 
static constexpr LMBD_INLINE uint32_t fromRGB (uint8_t r, uint8_t g, uint8_t b)
 Return color (r, g, b) as a single uint32_t integer.
 
static constexpr LMBD_INLINE uint32_t fromGrey (uint32_t w)
 Return color (w, w, w) as a single uint32_t integer.
 
static constexpr LMBD_INLINE uint32_t fromAngleHue (uint16_t angleDegrees)
 Given a 360 degrees angle, return a corresponding color as an integer.
 
static uint32_t blend (uint32_t leftColor, uint32_t rightColor, uint16_t blend, bool b16=false)
 blend to two colors
 
template<bool isVideoMode = false>
static uint32_t fade (uint32_t inputColor, uint8_t fadeAmount)
 fade the color toward black
 
template<bool isFast = false>
uint32_t add (uint32_t c1, uint32_t c2)
 Add two colors together.
 

Variables

static constexpr PaletteTy PaletteCloudColors
 Cloudy color palette/ blue to blue-white.
 
static constexpr PaletteTy PaletteLavaColors
 Lava color palette.
 
static constexpr PaletteTy PaletteFlameColors
 Fire color palette.
 
static constexpr PaletteTy PaletteOceanColors
 Ocean colors, blues and whites.
 
static constexpr PaletteTy PaletteWaterColors
 Water colors, blues.
 
static constexpr PaletteTy PaletteForestColors
 Forest colors, greens.
 
static constexpr PaletteTy PaletteRainbowColors
 HSV Rainbow.
 
static constexpr PaletteTy PalettePartyColors
 basically, HSV with no green. looks better when lighing people
 
static constexpr PaletteTy PaletteBlackBodyColors
 Black body radiation, with the high end changed to be nicer.
 
static constexpr PaletteTy PaletteHeatColors
 Heat black body.
 
static constexpr PaletteTy PaletteAuroraColors
 Palette of green yellow colors.
 
static constexpr PaletteTy PalettePapiColors
 Palette of nice handpicked colors.
 
template<uint32_t startColor, uint32_t endColor>
static constexpr PaletteTy PaletteGradient
 Return a palette gradient from startColor to endColor.
 
static constexpr uint8_t colorRotation [360]
 precompiled table for Hue
 

Detailed Description

Tools to manipulate colors and their representation.

Enumeration Type Documentation

◆ ColorTemperature

Color temperature values.

These color values are separated into two groups: black body radiators and gaseous light sources.

Black body radiators emit a (relatively) continuous spectrum, and can be described as having a Kelvin 'temperature'. This includes things like candles, tungsten lightbulbs, and sunlight.

Gaseous light sources emit discrete spectral bands, and while we can approximate their aggregate hue with RGB values, they don't actually have a proper Kelvin temperature.

See also
https://en.wikipedia.org/wiki/Color_temperature
Enumerator
Candle 

1900 Kelvin

2600 Kelvin

Tungsten40W 

2850 Kelvin

Tungsten100W 

3200 Kelvin

Halogen 

5200 Kelvin

CarbonArc 

5400 Kelvin

HighNoonSun 

6000 Kelvin

DirectSunlight 

7000 Kelvin

OvercastSky 

20000 Kelvin

ClearBlueSky 
WarmFluorescent 

Warm (yellower) flourescent light bulbs.

Standard flourescent light bulbs

StandardFluorescent 

Cool white (bluer) flourescent light bulbs

CoolWhiteFluorescent 

Full spectrum flourescent light bulbs

FullSpectrumFluorescent 

Grow light flourescent light bulbs

GrowLightFluorescent 

Black light flourescent light bulbs

BlackLightFluorescent 

Mercury vapor light bulbs

MercuryVapor 

Sodium vapor light bulbs

SodiumVapor 

Metal-halide light bulbs

MetalHalide 

High-pressure sodium light bulbs

HighPressureSodium 
UncorrectedTemperature 

Uncorrected temperature (0xFFFFFF)

◆ HTMLColorCode

Define common HTML colors.

Enumerator
AliceBlue 
Amethyst 
AntiqueWhite 
Aqua 
Aquamarine 
Azure 
Beige 
Bisque 
Black 
BlanchedAlmond 
Blue 
BlueViolet 
Brown 
BurlyWood 
CadetBlue 
Chartreuse 
Chocolate 
Coral 
CornflowerBlue 
Cornsilk 
Crimson 
Cyan 
DarkBlue 
DarkCyan 
DarkGoldenrod 
DarkGray 
DarkGrey 
DarkGreen 
DarkKhaki 
DarkMagenta 
DarkOliveGreen 
DarkOrange 
DarkOrchid 
DarkRed 
DarkSalmon 
DarkSeaGreen 
DarkSlateBlue 
DarkSlateGray 
DarkSlateGrey 
DarkTurquoise 
DarkViolet 
DeepPink 
DeepSkyBlue 
DimGray 
DimGrey 
DodgerBlue 
FireBrick 
FloralWhite 
ForestGreen 
Gainsboro 
GhostWhite 
Gold 
Goldenrod 
Gray 
Grey 
Green 
GreenYellow 
Honeydew 
HotPink 
IndianRed 
Indigo 
Ivory 
Khaki 
Lavender 
LavenderBlush 
LawnGreen 
LemonChiffon 
LightBlue 
LightCoral 
LightCyan 
LightGoldenrodYellow 
LightGreen 
LightGrey 
LightPink 
LightSalmon 
LightSeaGreen 
LightSkyBlue 
LightSlateGray 
LightSlateGrey 
LightSteelBlue 
LightYellow 
Lime 
LimeGreen 
Linen 
Magenta 
Maroon 
MediumAquamarine 
MediumBlue 
MediumOrchid 
MediumPurple 
MediumSeaGreen 
MediumSlateBlue 
MediumSpringGreen 
MediumTurquoise 
MediumVioletRed 
MidnightBlue 
MintCream 
MistyRose 
Moccasin 
NavajoWhite 
Navy 
OldLace 
Olive 
OliveDrab 
Orange 
OrangeRed 
Orchid 
PaleGoldenrod 
PaleGreen 
PaleTurquoise 
PaleVioletRed 
PapayaWhip 
PeachPuff 
Peru 
Pink 
Plaid 
Plum 
PowderBlue 
Purple 
Red 
RosyBrown 
RoyalBlue 
SaddleBrown 
Salmon 
SandyBrown 
SeaGreen 
Seashell 
Sienna 
Silver 
SkyBlue 
SlateBlue 
SlateGray 
SlateGrey 
Snow 
SpringGreen 
SteelBlue 
Tan 
Teal 
Thistle 
Tomato 
Turquoise 
Violet 
Wheat 
White 
WhiteSmoke 
Yellow 
YellowGreen 
FairyLight 
FairyLightNCC 

Function Documentation

◆ blend()

static uint32_t lampda::modes::colors::blend ( uint32_t  leftColor,
uint32_t  rightColor,
uint16_t  blend,
bool  b16 = false 
)
static

blend to two colors

Parameters
[in]leftColor: the first color to use
[in]rightColor: the second color to use
[in]blend: the amount of the first color use in the blend
[in]b16optional : use b16 for a more
Returns
the new color computed

◆ fade()

template<bool isVideoMode = false>
static uint32_t lampda::modes::colors::fade ( uint32_t  inputColor,
uint8_t  fadeAmount 
)
static

fade the color toward black

if using template "isVideoMode" method the resulting color will never become black unless it is already black

Parameters
[in]inputColor: the first color to use
[in]fadeAmount: the second color to use
Returns
the new color computed

◆ from_palette()

template<bool PaletteLoops = true, typename UIntTy = uint8_t>
static constexpr uint32_t lampda::modes::colors::from_palette ( UIntTy  index,
const PaletteTy palette,
uint8_t  brightness = 255 
)
staticconstexpr

Return a color from a palette.

Parameters
[in]indexfrom 0 to 255, the index of color we want from the palette
[in]paletteThe palette to sample from. Values are interpolated
[in]brightnessThe brighness of the color, default is max at 255
Returns
The desired color

Variable Documentation

◆ colorRotation

constexpr uint8_t lampda::modes::colors::colorRotation[360]
staticconstexpr
Initial value:
= {
0, 0, 0, 0, 0, 1, 1, 2, 2, 3, 4, 5, 6, 7, 8, 9, 11, 12, 13, 15, 17, 18,
20, 22, 24, 26, 28, 30, 32, 35, 37, 39, 42, 44, 47, 49, 52, 55, 58, 60, 63, 66, 69, 72,
75, 78, 81, 85, 88, 91, 94, 97, 101, 104, 107, 111, 114, 117, 121, 124, 127, 131, 134, 137, 141, 144,
147, 150, 154, 157, 160, 163, 167, 170, 173, 176, 179, 182, 185, 188, 191, 194, 197, 200, 202, 205, 208, 210,
213, 215, 217, 220, 222, 224, 226, 229, 231, 232, 234, 236, 238, 239, 241, 242, 244, 245, 246, 248, 249, 250,
251, 251, 252, 253, 253, 254, 254, 255, 255, 255, 255, 255, 255, 255, 254, 254, 253, 253, 252, 251, 251, 250,
249, 248, 246, 245, 244, 242, 241, 239, 238, 236, 234, 232, 231, 229, 226, 224, 222, 220, 217, 215, 213, 210,
208, 205, 202, 200, 197, 194, 191, 188, 185, 182, 179, 176, 173, 170, 167, 163, 160, 157, 154, 150, 147, 144,
141, 137, 134, 131, 127, 124, 121, 117, 114, 111, 107, 104, 101, 97, 94, 91, 88, 85, 81, 78, 75, 72,
69, 66, 63, 60, 58, 55, 52, 49, 47, 44, 42, 39, 37, 35, 32, 30, 28, 26, 24, 22, 20, 18,
17, 15, 13, 12, 11, 9, 8, 7, 6, 5, 4, 3, 2, 2, 1, 1, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0}

precompiled table for Hue

◆ PaletteAuroraColors

constexpr PaletteTy lampda::modes::colors::PaletteAuroraColors
staticconstexpr
Initial value:
= {0x000000,
0x003300,
0x006600,
0x009900,
0x00cc00,
0x33ff00,
0x66ff00,
0x99ff00,
0xccff00,
0xffcc00,
0xff9900,
0xff6600,
0xff3300,
Red}
@ Red
Definition: palettes.hpp:207
@ Lime
Definition: palettes.hpp:169
@ Yellow
Definition: palettes.hpp:233

Palette of green yellow colors.

◆ PaletteBlackBodyColors

constexpr PaletteTy lampda::modes::colors::PaletteBlackBodyColors
staticconstexpr
Initial value:
= {0xE73E05,
0xff5300,
0xff6500,
0xff7300,
0xff7e00,
0xff8912,
0xff932c,
0xff9d3f,
0xffa54f,
0xffad5e,
0xffb46b,
0xffbb78,
0xffc184,
0xffc78f,
0xffcc99,
0xffd1a3}

Black body radiation, with the high end changed to be nicer.

◆ PaletteCloudColors

constexpr PaletteTy lampda::modes::colors::PaletteCloudColors
staticconstexpr
Initial value:
= {Blue,
@ LightBlue
Definition: palettes.hpp:155
@ White
Definition: palettes.hpp:231
@ SkyBlue
Definition: palettes.hpp:217
@ DarkBlue
Definition: palettes.hpp:110
@ Blue
Definition: palettes.hpp:98

Cloudy color palette/ blue to blue-white.

◆ PaletteFlameColors

constexpr PaletteTy lampda::modes::colors::PaletteFlameColors
staticconstexpr
Initial value:
= {Orange,
@ Candle
1900 Kelvin
Definition: palettes.hpp:38
@ Orange
Definition: palettes.hpp:192
@ Gold
Definition: palettes.hpp:139

Fire color palette.

◆ PaletteForestColors

constexpr PaletteTy lampda::modes::colors::PaletteForestColors
staticconstexpr
Initial value:
@ MediumAquamarine
Definition: palettes.hpp:174
@ LightGreen
Definition: palettes.hpp:159
@ ForestGreen
Definition: palettes.hpp:136
@ DarkOliveGreen
Definition: palettes.hpp:118
@ LimeGreen
Definition: palettes.hpp:170
@ Green
Definition: palettes.hpp:143
@ SeaGreen
Definition: palettes.hpp:213
@ LawnGreen
Definition: palettes.hpp:153
@ DarkGreen
Definition: palettes.hpp:115
@ OliveDrab
Definition: palettes.hpp:191
@ YellowGreen
Definition: palettes.hpp:234

Forest colors, greens.

◆ PaletteGradient

template<uint32_t startColor, uint32_t endColor>
constexpr PaletteTy lampda::modes::colors::PaletteGradient
staticconstexpr
Initial value:
=
_gradient_palette_from_color<startColor, endColor>()

Return a palette gradient from startColor to endColor.

◆ PaletteHeatColors

constexpr PaletteTy lampda::modes::colors::PaletteHeatColors
staticconstexpr
Initial value:
= {Black,
0x330000,
0x660000,
0x990000,
0xCC0000,
Red,
0xFF3300,
0xFF6600,
0xFF9900,
0xFFCC00,
0xFFFF33,
0xFFFF66,
0xFFFF99,
0xFFFFCC}
@ Black
Definition: palettes.hpp:96

Heat black body.

◆ PaletteLavaColors

constexpr PaletteTy lampda::modes::colors::PaletteLavaColors
staticconstexpr
Initial value:
= {Black,
Red,
Red,
@ Maroon
Definition: palettes.hpp:173
@ DarkRed
Definition: palettes.hpp:121

Lava color palette.

◆ PaletteOceanColors

constexpr PaletteTy lampda::modes::colors::PaletteOceanColors
staticconstexpr
Initial value:
@ CadetBlue
Definition: palettes.hpp:102
@ MediumBlue
Definition: palettes.hpp:175
@ LightSkyBlue
Definition: palettes.hpp:164
@ Navy
Definition: palettes.hpp:188
@ Aquamarine
Definition: palettes.hpp:92
@ Teal
Definition: palettes.hpp:225
@ CornflowerBlue
Definition: palettes.hpp:106
@ DarkCyan
Definition: palettes.hpp:111
@ Aqua
Definition: palettes.hpp:91
@ MidnightBlue
Definition: palettes.hpp:183

Ocean colors, blues and whites.

◆ PalettePapiColors

constexpr PaletteTy lampda::modes::colors::PalettePapiColors
staticconstexpr
Initial value:
= {
Blue,
0x0F9DE8,
0x2BFAFA,
0x791CF8,
0x9683EC,
Red,
0xFF7F00,
0xE73E05,
Lime,
0x87E990,
0x058E8E,
0x660099,
0xFF007F,
}
@ Magenta
Definition: palettes.hpp:172

Palette of nice handpicked colors.

◆ PalettePartyColors

constexpr PaletteTy lampda::modes::colors::PalettePartyColors
staticconstexpr
Initial value:
= {0x5500AB,
0x84007C,
0xB5004B,
0xE5001B,
0xE81700,
0xB84700,
0xAB7700,
0xABAB00,
0xAB5500,
0xDD2200,
0xF2000E,
0xC2003E,
0x8F0071,
0x5F00A1,
0x2F00D0,
0x0007F9}

basically, HSV with no green. looks better when lighing people

◆ PaletteRainbowColors

constexpr PaletteTy lampda::modes::colors::PaletteRainbowColors
staticconstexpr
Initial value:
= {Red,
0xD52A00,
0xAB5500,
0xAB7F00,
0xABAB00,
0x56D500,
0x00D52A,
0x00AB55,
0x0056AA,
0x2A00D5,
0x5500AB,
0x7F0081,
0xAB0055,
0xD5002B}

HSV Rainbow.

◆ PaletteWaterColors

constexpr PaletteTy lampda::modes::colors::PaletteWaterColors
staticconstexpr