BRegion: add ScaleBy method.
* Is there a reason to not have it?
This commit is contained in:
@@ -59,6 +59,7 @@ public:
|
||||
|
||||
void OffsetBy(const BPoint& point);
|
||||
void OffsetBy(int32 x, int32 y);
|
||||
void ScaleBy(float x, float y);
|
||||
|
||||
void MakeEmpty();
|
||||
|
||||
|
||||
@@ -81,6 +81,16 @@ offset_rect(clipping_rect &rect, int32 x, int32 y)
|
||||
}
|
||||
|
||||
|
||||
static inline void
|
||||
scale_rect(clipping_rect& rect, float x, float y)
|
||||
{
|
||||
rect.left = (int)(rect.left * x);
|
||||
rect.top = (int)(rect.top * y);
|
||||
rect.right = (int)(rect.right * x);
|
||||
rect.bottom = (int)(rect.bottom * y);
|
||||
}
|
||||
|
||||
|
||||
// Converts the given clipping_rect to a BRect
|
||||
static inline BRect
|
||||
to_BRect(const clipping_rect &rect)
|
||||
|
||||
@@ -306,6 +306,23 @@ BRegion::OffsetBy(int32 x, int32 y)
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
BRegion::ScaleBy(float x, float y)
|
||||
{
|
||||
if (x == 1.0 && y == 1.0)
|
||||
return;
|
||||
|
||||
if (fCount > 0) {
|
||||
if (fData != &fBounds) {
|
||||
for (int32 i = 0; i < fCount; i++)
|
||||
scale_rect(fData[i], x, y);
|
||||
}
|
||||
|
||||
scale_rect(fBounds, x, y);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// Empties the region, so that it doesn't include any rect, and invalidates
|
||||
// its bounds.
|
||||
void
|
||||
|
||||
Reference in New Issue
Block a user