heightForWidth/widthForHeight added

This commit is contained in:
Uwe Rathmann 2018-10-18 15:41:33 +02:00
parent 2cd9c79fa7
commit 2b84276019
2 changed files with 21 additions and 0 deletions

View File

@ -578,6 +578,24 @@ QSizeF QskGraphic::defaultSize() const
return boundingRect().size();
}
qreal QskGraphic::heightForWidth( qreal width ) const
{
const auto sz = defaultSize();
if ( sz.isEmpty() )
return 0;
return sz.height() * width / sz.width();
}
qreal QskGraphic::widthForHeight( qreal height ) const
{
const auto sz = defaultSize();
if ( sz.isEmpty() )
return 0;
return sz.width() * height / sz.height();
}
void QskGraphic::render( QPainter* painter ) const
{
render( painter, QskColorFilter() );

View File

@ -88,6 +88,9 @@ class QSK_EXPORT QskGraphic : public QPaintDevice
void setDefaultSize( const QSizeF& );
QSizeF defaultSize() const;
qreal heightForWidth( qreal width ) const;
qreal widthForHeight( qreal height ) const;
void setRenderHint( RenderHint, bool on = true );
bool testRenderHint( RenderHint ) const;