QRectF interpolator added

This commit is contained in:
Uwe Rathmann 2021-12-29 15:30:44 +01:00
parent e5f15d34e4
commit a3e1065096
2 changed files with 19 additions and 0 deletions

View File

@ -122,6 +122,22 @@ QRectF qskValidOrEmptyInnerRect( const QRectF& rect, const QMarginsF& margins )
return QRectF( x, y, w, h );
}
QRectF qskInterpolatedRect( const QRectF &from, const QRectF &to, qreal progress )
{
if ( progress <= 0.0 )
return from;
if ( progress >= 1.0 )
return to;
const auto x = from.x() + progress * ( to.x() - from.x() );
const auto y = from.y() + progress * ( to.y() - from.y() );
const auto w = from.width() + progress * ( to.width() - from.width() );
const auto h = from.height() + progress * ( to.height() - from.height() );
return QRectF( x, y, w, h );
}
qreal qskHorizontalAdvance( const QFont& font, const QString& text )
{
return qskHorizontalAdvance( QFontMetricsF( font ), text );

View File

@ -30,6 +30,9 @@ QSK_EXPORT QRectF qskValidOrEmptyInnerRect(
QSK_EXPORT qreal qskHorizontalAdvance( const QFont&, const QString& );
QSK_EXPORT qreal qskHorizontalAdvance( const QFontMetricsF&, const QString& );
QSK_EXPORT QRectF qskInterpolatedRect(
const QRectF& from, const QRectF& to, qreal progress );
inline QMarginsF qskMargins( const QRectF& rect, const QRectF& innerRect )
{
return QMarginsF(