forked from Makuna/NeoPixelBus
8bit dim support on 16bit color elements (#720)
This commit is contained in:
@@ -193,6 +193,18 @@ struct Rgb48Color : RgbColorBase
|
|||||||
// ------------------------------------------------------------------------
|
// ------------------------------------------------------------------------
|
||||||
Rgb48Color Dim(uint16_t ratio) const;
|
Rgb48Color Dim(uint16_t ratio) const;
|
||||||
|
|
||||||
|
// ------------------------------------------------------------------------
|
||||||
|
// Dim will return a new color that is blended to black with the given ratio
|
||||||
|
// ratio - (0-255) where 255 will return the original color and 0 will return black
|
||||||
|
//
|
||||||
|
// NOTE: This is a simple linear blend
|
||||||
|
// ------------------------------------------------------------------------
|
||||||
|
Rgb48Color Dim(uint8_t ratio) const
|
||||||
|
{
|
||||||
|
uint16_t expanded = ratio << 8;
|
||||||
|
return Dim(expanded);
|
||||||
|
}
|
||||||
|
|
||||||
// ------------------------------------------------------------------------
|
// ------------------------------------------------------------------------
|
||||||
// Brighten will return a new color that is blended to white with the given ratio
|
// Brighten will return a new color that is blended to white with the given ratio
|
||||||
// ratio - (0-65535) where 65535 will return the original color and 0 will return white
|
// ratio - (0-65535) where 65535 will return the original color and 0 will return white
|
||||||
@@ -201,6 +213,18 @@ struct Rgb48Color : RgbColorBase
|
|||||||
// ------------------------------------------------------------------------
|
// ------------------------------------------------------------------------
|
||||||
Rgb48Color Brighten(uint16_t ratio) const;
|
Rgb48Color Brighten(uint16_t ratio) const;
|
||||||
|
|
||||||
|
// ------------------------------------------------------------------------
|
||||||
|
// Brighten will return a new color that is blended to white with the given ratio
|
||||||
|
// ratio - (0-255) where 255 will return the original color and 0 will return white
|
||||||
|
//
|
||||||
|
// NOTE: This is a simple linear blend
|
||||||
|
// ------------------------------------------------------------------------
|
||||||
|
Rgb48Color Brighten(uint8_t ratio) const
|
||||||
|
{
|
||||||
|
uint16_t expanded = ratio << 8;
|
||||||
|
return Brighten(expanded);
|
||||||
|
}
|
||||||
|
|
||||||
// ------------------------------------------------------------------------
|
// ------------------------------------------------------------------------
|
||||||
// Darken will adjust the color by the given delta toward black
|
// Darken will adjust the color by the given delta toward black
|
||||||
// NOTE: This is a simple linear change
|
// NOTE: This is a simple linear change
|
||||||
|
@@ -224,6 +224,18 @@ struct Rgbw64Color : RgbColorBase
|
|||||||
// ------------------------------------------------------------------------
|
// ------------------------------------------------------------------------
|
||||||
Rgbw64Color Dim(uint16_t ratio) const;
|
Rgbw64Color Dim(uint16_t ratio) const;
|
||||||
|
|
||||||
|
// ------------------------------------------------------------------------
|
||||||
|
// Dim will return a new color that is blended to black with the given ratio
|
||||||
|
// ratio - (0-255) where 255 will return the original color and 0 will return black
|
||||||
|
//
|
||||||
|
// NOTE: This is a simple linear blend
|
||||||
|
// ------------------------------------------------------------------------
|
||||||
|
Rgbw64Color Dim(uint8_t ratio) const
|
||||||
|
{
|
||||||
|
uint16_t expanded = ratio << 8;
|
||||||
|
return Dim(expanded);
|
||||||
|
}
|
||||||
|
|
||||||
// ------------------------------------------------------------------------
|
// ------------------------------------------------------------------------
|
||||||
// Brighten will return a new color that is blended to white with the given ratio
|
// Brighten will return a new color that is blended to white with the given ratio
|
||||||
// ratio - (0-65535) where 65535 will return the original color and 0 will return white
|
// ratio - (0-65535) where 65535 will return the original color and 0 will return white
|
||||||
@@ -232,6 +244,18 @@ struct Rgbw64Color : RgbColorBase
|
|||||||
// ------------------------------------------------------------------------
|
// ------------------------------------------------------------------------
|
||||||
Rgbw64Color Brighten(uint16_t ratio) const;
|
Rgbw64Color Brighten(uint16_t ratio) const;
|
||||||
|
|
||||||
|
// ------------------------------------------------------------------------
|
||||||
|
// Brighten will return a new color that is blended to white with the given ratio
|
||||||
|
// ratio - (0-255) where 255 will return the original color and 0 will return white
|
||||||
|
//
|
||||||
|
// NOTE: This is a simple linear blend
|
||||||
|
// ------------------------------------------------------------------------
|
||||||
|
Rgbw64Color Brighten(uint8_t ratio) const
|
||||||
|
{
|
||||||
|
uint16_t expanded = ratio << 8;
|
||||||
|
return Brighten(expanded);
|
||||||
|
}
|
||||||
|
|
||||||
// ------------------------------------------------------------------------
|
// ------------------------------------------------------------------------
|
||||||
// Darken will adjust the color by the given delta toward black
|
// Darken will adjust the color by the given delta toward black
|
||||||
// NOTE: This is a simple linear change
|
// NOTE: This is a simple linear change
|
||||||
|
Reference in New Issue
Block a user