Browse Source

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

tags/2021-05-28
jules 12 years ago
parent
commit
7d167aef87
3 changed files with 15 additions and 3 deletions
  1. +6
    -0
      modules/juce_graphics/geometry/juce_AffineTransform.cpp
  2. +5
    -0
      modules/juce_graphics/geometry/juce_AffineTransform.h
  3. +4
    -3
      modules/juce_graphics/geometry/juce_Rectangle.h

+ 6
- 0
modules/juce_graphics/geometry/juce_AffineTransform.cpp 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);


+ 5
- 0
modules/juce_graphics/geometry/juce_AffineTransform.h 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.
*/


+ 4
- 3
modules/juce_graphics/geometry/juce_Rectangle.h 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;
}


Loading…
Cancel
Save