add QgsRectangle::scaled which returns the scaled rectangle

facilitates one-lines
This commit is contained in:
Denis Rouzaud 2018-10-25 13:36:46 -04:00
parent edc03030ef
commit 80d0c33f5b
3 changed files with 20 additions and 0 deletions

View File

@ -183,6 +183,13 @@ Scale the rectangle around its center point.
void scale( double scaleFactor, double centerX, double centerY );
%Docstring
Scale the rectangle around its center point.
%End
QgsRectangle scaled( double scaleFactor, const QgsPointXY *center = 0 );
%Docstring
Scale the rectangle around its ``center`` point.
.. versionadded:: 3.4
%End
void grow( double delta );

View File

@ -58,6 +58,13 @@ QgsRectangle QgsRectangle::fromCenterAndSize( QgsPointXY center, double width, d
return QgsRectangle( xMin, yMin, xMax, yMax );
}
QgsRectangle QgsRectangle::scaled( double scaleFactor, const QgsPointXY *center )
{
QgsRectangle scaledRect = QgsRectangle( *this );
scaledRect.scale( scaleFactor, center );
return scaledRect;
}
QgsRectangle QgsRectangle::operator-( const QgsVector v ) const
{
double xmin = mXmin - v.x();

View File

@ -261,6 +261,12 @@ class CORE_EXPORT QgsRectangle
mYmax = centerY + newHeight / 2.0;
}
/**
* Scale the rectangle around its \a center point.
* \since QGIS 3.4
*/
QgsRectangle scaled( double scaleFactor, const QgsPointXY *center = nullptr );
/**
* Grows the rectangle in place by the specified amount.
* \see buffered()