QskGraphic::aspectRatio added

This commit is contained in:
Uwe Rathmann 2021-12-22 15:07:03 +01:00
parent 0b5b622d1a
commit 3842ca36a3
2 changed files with 11 additions and 0 deletions

View File

@ -611,6 +611,15 @@ qreal QskGraphic::widthForHeight( qreal height ) const
return sz.width() * height / sz.height(); return sz.width() * height / sz.height();
} }
qreal QskGraphic::aspectRatio() const
{
const auto sz = defaultSize();
if ( sz.isEmpty() )
return 1.0;
return sz.width() / sz.height();
}
void QskGraphic::render( QPainter* painter ) const void QskGraphic::render( QPainter* painter ) const
{ {
render( painter, QskColorFilter() ); render( painter, QskColorFilter() );

View File

@ -101,6 +101,8 @@ class QSK_EXPORT QskGraphic : public QPaintDevice
void setDefaultSize( const QSizeF& ); void setDefaultSize( const QSizeF& );
QSizeF defaultSize() const; QSizeF defaultSize() const;
qreal aspectRatio() const;
qreal heightForWidth( qreal width ) const; qreal heightForWidth( qreal width ) const;
qreal widthForHeight( qreal height ) const; qreal widthForHeight( qreal height ) const;