diff --git a/modules/juce_graphics/geometry/juce_AffineTransform.cpp b/modules/juce_graphics/geometry/juce_AffineTransform.cpp index 3d9369291c..7f1b9aaed1 100644 --- a/modules/juce_graphics/geometry/juce_AffineTransform.cpp +++ b/modules/juce_graphics/geometry/juce_AffineTransform.cpp @@ -152,6 +152,12 @@ AffineTransform AffineTransform::scaled (const float factorX, const float factor factorY * mat10, factorY * mat11, factorY * mat12); } +AffineTransform AffineTransform::scaled (const float factor) const noexcept +{ + return AffineTransform (factor * mat00, factor * mat01, factor * mat02, + factor * mat10, factor * mat11, factor * mat12); +} + AffineTransform AffineTransform::scale (const float factorX, const float factorY) noexcept { return AffineTransform (factorX, 0, 0, 0, factorY, 0); diff --git a/modules/juce_graphics/geometry/juce_AffineTransform.h b/modules/juce_graphics/geometry/juce_AffineTransform.h index 400e7613f8..70937aeb81 100644 --- a/modules/juce_graphics/geometry/juce_AffineTransform.h +++ b/modules/juce_graphics/geometry/juce_AffineTransform.h @@ -165,6 +165,11 @@ public: AffineTransform scaled (float factorX, float factorY) const noexcept; + /** Returns a transform which is the same as this one followed by a re-scaling. + The scaling is centred around the origin (0, 0). + */ + AffineTransform scaled (float factor) const noexcept; + /** Returns a transform which is the same as this one followed by a re-scaling. The scaling is centred around the origin provided. */ diff --git a/modules/juce_graphics/geometry/juce_Rectangle.h b/modules/juce_graphics/geometry/juce_Rectangle.h index c7332939a6..2ebaf4979b 100644 --- a/modules/juce_graphics/geometry/juce_Rectangle.h +++ b/modules/juce_graphics/geometry/juce_Rectangle.h @@ -304,9 +304,10 @@ public: template Rectangle operator*= (FloatType scaleFactor) noexcept { - pos *= scaleFactor; - w = (ValueType) (w * scaleFactor); - h = (ValueType) (h * scaleFactor); + Rectangle (pos.x * scaleFactor, + pos.y * scaleFactor, + w * scaleFactor, + h * scaleFactor).copyWithRounding (*this); return *this; }