Skip to content

Commit

Permalink
add QgsRectangle::scaled which returns the scaled rectangle
Browse files Browse the repository at this point in the history
facilitates one-lines
  • Loading branch information
3nids committed Oct 25, 2018
1 parent edc0303 commit 80d0c33
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 0 deletions.
7 changes: 7 additions & 0 deletions python/core/auto_generated/geometry/qgsrectangle.sip.in
Expand Up @@ -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 );
Expand Down
7 changes: 7 additions & 0 deletions src/core/geometry/qgsrectangle.cpp
Expand Up @@ -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();
Expand Down
6 changes: 6 additions & 0 deletions src/core/geometry/qgsrectangle.h
Expand Up @@ -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()
Expand Down

0 comments on commit 80d0c33

Please sign in to comment.