lighter/darker added
This commit is contained in:
parent
5b6f070d7d
commit
3519e92e91
@ -153,3 +153,22 @@ QRgb QskRgbValue::rgb( Qt::GlobalColor color )
|
|||||||
|
|
||||||
return rgbValues[ 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();
|
||||||
|
}
|
||||||
|
|
||||||
|
@ -437,7 +437,7 @@
|
|||||||
|
|
||||||
namespace QskRgbValue
|
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
|
QSK_RGB_VALUES
|
||||||
#undef RGB
|
#undef RGB
|
||||||
|
|
||||||
@ -460,6 +460,9 @@ namespace QskRgbValue
|
|||||||
{
|
{
|
||||||
return ( rgb & ColorMask ) | ( ( static_cast< uint >( alpha ) & 0xffu ) << 24 );
|
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
|
#endif
|
||||||
|
Loading…
x
Reference in New Issue
Block a user