mirror of
https://github.com/juce-framework/JUCE.git
synced 2026-01-10 23:44:24 +00:00
Added some more translation methods to AffineTransform, and a couple of methods to Rectangle and RectangleList
This commit is contained in:
parent
53ae95b730
commit
bd3a75e726
3 changed files with 32 additions and 7 deletions
|
|
@ -127,10 +127,24 @@ public:
|
|||
AffineTransform translated (float deltaX,
|
||||
float deltaY) const noexcept;
|
||||
|
||||
/** Returns a new transform which is the same as this one followed by a translation. */
|
||||
template <typename PointType>
|
||||
AffineTransform translated (PointType delta) const noexcept
|
||||
{
|
||||
return translated ((float) delta.x, (float) delta.y);
|
||||
}
|
||||
|
||||
/** Returns a new transform which is a translation. */
|
||||
static AffineTransform translation (float deltaX,
|
||||
float deltaY) noexcept;
|
||||
|
||||
/** Returns a new transform which is a translation. */
|
||||
template <typename PointType>
|
||||
static AffineTransform translation (PointType delta) noexcept
|
||||
{
|
||||
return translation ((float) delta.x, (float) delta.y);
|
||||
}
|
||||
|
||||
/** Returns a copy of this transform with the specified translation matrix values. */
|
||||
AffineTransform withAbsoluteTranslation (float translationX,
|
||||
float translationY) const noexcept;
|
||||
|
|
|
|||
|
|
@ -711,7 +711,6 @@ public:
|
|||
}
|
||||
|
||||
/** Casts this rectangle to a Rectangle<float>.
|
||||
Obviously this is mainly useful for rectangles that use integer types.
|
||||
@see getSmallestIntegerContainer
|
||||
*/
|
||||
Rectangle<float> toFloat() const noexcept
|
||||
|
|
@ -721,7 +720,6 @@ public:
|
|||
}
|
||||
|
||||
/** Casts this rectangle to a Rectangle<double>.
|
||||
Obviously this is mainly useful for rectangles that use integer types.
|
||||
@see getSmallestIntegerContainer
|
||||
*/
|
||||
Rectangle<double> toDouble() const noexcept
|
||||
|
|
@ -730,6 +728,18 @@ public:
|
|||
static_cast<double> (w), static_cast<double> (h));
|
||||
}
|
||||
|
||||
/** Casts this rectangle to a Rectangle with the given type.
|
||||
If the target type is a conversion from float to int, then the conversion
|
||||
will be done using getSmallestIntegerContainer().
|
||||
*/
|
||||
template <typename TargetType>
|
||||
Rectangle<TargetType> toType() const noexcept
|
||||
{
|
||||
Rectangle<TargetType> r;
|
||||
copyWithRounding (r);
|
||||
return r;
|
||||
}
|
||||
|
||||
/** Returns the smallest Rectangle that can contain a set of points. */
|
||||
static Rectangle findAreaContainingPoints (const Point<ValueType>* const points, const int numPoints) noexcept
|
||||
{
|
||||
|
|
|
|||
|
|
@ -343,7 +343,8 @@ public:
|
|||
|
||||
@see getIntersectionWith
|
||||
*/
|
||||
bool clipTo (const RectangleList& other)
|
||||
template <typename OtherValueType>
|
||||
bool clipTo (const RectangleList<OtherValueType>& other)
|
||||
{
|
||||
if (rects.size() == 0)
|
||||
return false;
|
||||
|
|
@ -354,12 +355,12 @@ public:
|
|||
{
|
||||
const RectangleType& rect = rects.getReference (j);
|
||||
|
||||
for (int i = other.rects.size(); --i >= 0;)
|
||||
for (const Rectangle<OtherValueType>* r = other.begin(), * const e = other.end(); r != e; ++r)
|
||||
{
|
||||
RectangleType r (other.rects.getReference (i));
|
||||
RectangleType clipped (r->template toType<ValueType>());
|
||||
|
||||
if (rect.intersectRectangle (r))
|
||||
result.rects.add (r);
|
||||
if (rect.intersectRectangle (clipped))
|
||||
result.rects.add (clipped);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue