* 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:
@@ -81,6 +81,8 @@ public:
|
|||||||
BAffineTransform TranslateByCopy(double x, double y) const;
|
BAffineTransform TranslateByCopy(double x, double y) const;
|
||||||
BAffineTransform TranslateByCopy(const BPoint& delta) const;
|
BAffineTransform TranslateByCopy(const BPoint& delta) const;
|
||||||
|
|
||||||
|
// const BAffineTransform& SetTranslation(double x, double y);
|
||||||
|
|
||||||
// Rotation
|
// Rotation
|
||||||
inline const BAffineTransform& RotateBy(double angle);
|
inline const BAffineTransform& RotateBy(double angle);
|
||||||
const BAffineTransform& RotateBy(const BPoint& center,
|
const BAffineTransform& RotateBy(const BPoint& center,
|
||||||
@@ -90,6 +92,8 @@ public:
|
|||||||
BAffineTransform RotateByCopy(const BPoint& center,
|
BAffineTransform RotateByCopy(const BPoint& center,
|
||||||
double angle) const;
|
double angle) const;
|
||||||
|
|
||||||
|
// const BAffineTransform& SetRotation(double angle);
|
||||||
|
|
||||||
// Scaling
|
// Scaling
|
||||||
inline const BAffineTransform& ScaleBy(double scale);
|
inline const BAffineTransform& ScaleBy(double scale);
|
||||||
const BAffineTransform& ScaleBy(const BPoint& center,
|
const BAffineTransform& ScaleBy(const BPoint& center,
|
||||||
@@ -111,6 +115,9 @@ public:
|
|||||||
BAffineTransform ScaleByCopy(const BPoint& center,
|
BAffineTransform ScaleByCopy(const BPoint& center,
|
||||||
const BPoint& scale) const;
|
const BPoint& scale) const;
|
||||||
|
|
||||||
|
const BAffineTransform& SetScale(double scale);
|
||||||
|
const BAffineTransform& SetScale(double x, double y);
|
||||||
|
|
||||||
// Shearing
|
// Shearing
|
||||||
inline const BAffineTransform& ShearBy(double x, double y);
|
inline const BAffineTransform& ShearBy(double x, double y);
|
||||||
const BAffineTransform& ShearBy(const BPoint& center, double x,
|
const BAffineTransform& ShearBy(const BPoint& center, double x,
|
||||||
@@ -126,6 +133,8 @@ public:
|
|||||||
BAffineTransform ShearByCopy(const BPoint& center,
|
BAffineTransform ShearByCopy(const BPoint& center,
|
||||||
const BPoint& shear) const;
|
const BPoint& shear) const;
|
||||||
|
|
||||||
|
// const BAffineTransform& SetShear(double x, double y);
|
||||||
|
|
||||||
// Multiplication
|
// Multiplication
|
||||||
inline const BAffineTransform& Multiply(const BAffineTransform& other);
|
inline const BAffineTransform& Multiply(const BAffineTransform& other);
|
||||||
const BAffineTransform& PreMultiply(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
|
// #pragma mark - inline methods
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -26,6 +26,9 @@
|
|||||||
#include <TypeConstants.h>
|
#include <TypeConstants.h>
|
||||||
|
|
||||||
|
|
||||||
|
const BAffineTransform B_AFFINE_IDENTITY_TRANSFORM;
|
||||||
|
|
||||||
|
|
||||||
BAffineTransform::BAffineTransform()
|
BAffineTransform::BAffineTransform()
|
||||||
:
|
:
|
||||||
sx(1.0),
|
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 -
|
// #pragma mark -
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user