1
0
Fork 0
mirror of https://github.com/juce-framework/JUCE.git synced 2026-01-18 00:54:19 +00:00

Added a new AffineTransform::scaled method and improved Rectangle::operator*=

This commit is contained in:
jules 2013-07-26 17:19:07 +01:00
parent 7590e3f1fe
commit 7d167aef87
3 changed files with 15 additions and 3 deletions

View file

@ -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);

View file

@ -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.
*/

View file

@ -304,9 +304,10 @@ public:
template <typename FloatType>
Rectangle operator*= (FloatType scaleFactor) noexcept
{
pos *= scaleFactor;
w = (ValueType) (w * scaleFactor);
h = (ValueType) (h * scaleFactor);
Rectangle<FloatType> (pos.x * scaleFactor,
pos.y * scaleFactor,
w * scaleFactor,
h * scaleFactor).copyWithRounding (*this);
return *this;
}