lighter/darker added

This commit is contained in:
Uwe Rathmann 2020-08-15 13:05:25 +02:00
parent 5b6f070d7d
commit 3519e92e91
2 changed files with 23 additions and 1 deletions

View File

@ -153,3 +153,22 @@ QRgb QskRgbValue::rgb( Qt::GlobalColor color )
return rgbValues[ color ];
}
QRgb QskRgbValue::lighter( QRgb rgb, int factor ) noexcept
{
if ( factor <= 0 )
return rgb;
// guess we can find a faster implementation without using QColor TODO ...
return QColor::fromRgba( rgb ).lighter( factor ).rgba();
}
QRgb QskRgbValue::darker( QRgb rgb, int factor ) noexcept
{
if ( factor <= 0 )
return rgb;
// guess we can find a faster implementation without using QColor TODO ...
return QColor::fromRgba( rgb ).darker( factor ).rgba();
}

View File

@ -437,7 +437,7 @@
namespace QskRgbValue
{
#define RGB( name, value ) static constexpr const unsigned int name = value;
#define RGB( name, value ) static constexpr const QRgb name = value;
QSK_RGB_VALUES
#undef RGB
@ -460,6 +460,9 @@ namespace QskRgbValue
{
return ( rgb & ColorMask ) | ( ( static_cast< uint >( alpha ) & 0xffu ) << 24 );
}
QSK_EXPORT QRgb lighter( QRgb, int factor = 150 ) noexcept;
QSK_EXPORT QRgb darker( QRgb, int factor = 200 ) noexcept;
}
#endif