8bit dim support on 16bit color elements (#720)

This commit is contained in:
Michael Miller
2023-06-23 11:19:14 -07:00
committed by GitHub
parent 66a6ae41d4
commit 3c77a63b4b
2 changed files with 48 additions and 0 deletions

View File

@@ -193,6 +193,18 @@ struct Rgb48Color : RgbColorBase
// ------------------------------------------------------------------------
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
// 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;
// ------------------------------------------------------------------------
// 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
// NOTE: This is a simple linear change

View File

@@ -224,6 +224,18 @@ struct Rgbw64Color : RgbColorBase
// ------------------------------------------------------------------------
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
// 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;
// ------------------------------------------------------------------------
// 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
// NOTE: This is a simple linear change