* Allow to set the scale (versus multiplication with a scale).
* Added commented versions for translation, rotation and shear, which would work similar. * Added B_AFFINE_IDENTITY_TRANSFORM constant similar to B_ORIGIN. git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@36401 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
parent
b19e758b80
commit
d7fcb36f2b
@ -81,6 +81,8 @@ public:
|
||||
BAffineTransform TranslateByCopy(double x, double y) const;
|
||||
BAffineTransform TranslateByCopy(const BPoint& delta) const;
|
||||
|
||||
// const BAffineTransform& SetTranslation(double x, double y);
|
||||
|
||||
// Rotation
|
||||
inline const BAffineTransform& RotateBy(double angle);
|
||||
const BAffineTransform& RotateBy(const BPoint& center,
|
||||
@ -90,6 +92,8 @@ public:
|
||||
BAffineTransform RotateByCopy(const BPoint& center,
|
||||
double angle) const;
|
||||
|
||||
// const BAffineTransform& SetRotation(double angle);
|
||||
|
||||
// Scaling
|
||||
inline const BAffineTransform& ScaleBy(double scale);
|
||||
const BAffineTransform& ScaleBy(const BPoint& center,
|
||||
@ -111,6 +115,9 @@ public:
|
||||
BAffineTransform ScaleByCopy(const BPoint& center,
|
||||
const BPoint& scale) const;
|
||||
|
||||
const BAffineTransform& SetScale(double scale);
|
||||
const BAffineTransform& SetScale(double x, double y);
|
||||
|
||||
// Shearing
|
||||
inline const BAffineTransform& ShearBy(double x, double y);
|
||||
const BAffineTransform& ShearBy(const BPoint& center, double x,
|
||||
@ -126,6 +133,8 @@ public:
|
||||
BAffineTransform ShearByCopy(const BPoint& center,
|
||||
const BPoint& shear) const;
|
||||
|
||||
// const BAffineTransform& SetShear(double x, double y);
|
||||
|
||||
// Multiplication
|
||||
inline const BAffineTransform& Multiply(const BAffineTransform& other);
|
||||
const BAffineTransform& PreMultiply(const BAffineTransform& other);
|
||||
@ -191,6 +200,9 @@ public:
|
||||
};
|
||||
|
||||
|
||||
extern const BAffineTransform B_AFFINE_IDENTITY_TRANSFORM;
|
||||
|
||||
|
||||
// #pragma mark - inline methods
|
||||
|
||||
|
||||
|
@ -26,6 +26,9 @@
|
||||
#include <TypeConstants.h>
|
||||
|
||||
|
||||
const BAffineTransform B_AFFINE_IDENTITY_TRANSFORM;
|
||||
|
||||
|
||||
BAffineTransform::BAffineTransform()
|
||||
:
|
||||
sx(1.0),
|
||||
@ -373,6 +376,36 @@ BAffineTransform::ScaleByCopy(const BPoint& center, const BPoint& scale) const
|
||||
}
|
||||
|
||||
|
||||
const BAffineTransform&
|
||||
BAffineTransform::SetScale(double scale)
|
||||
{
|
||||
return SetScale(scale, scale);
|
||||
}
|
||||
|
||||
|
||||
const BAffineTransform&
|
||||
BAffineTransform::SetScale(double x, double y)
|
||||
{
|
||||
double tx;
|
||||
double ty;
|
||||
double rotation;
|
||||
double shearX;
|
||||
double shearY;
|
||||
if (!GetAffineParameters(&tx, &ty, &rotation, NULL, NULL,
|
||||
&shearX, &shearY)) {
|
||||
return *this;
|
||||
}
|
||||
|
||||
BAffineTransform result;
|
||||
result.ShearBy(shearX, shearY);
|
||||
result.ScaleBy(x, y);
|
||||
result.RotateBy(rotation);
|
||||
result.TranslateBy(tx, ty);
|
||||
|
||||
return *this = result;
|
||||
}
|
||||
|
||||
|
||||
// #pragma mark -
|
||||
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user