Author: stippi Date: 2010-04-21 18:46:32 +0200 (Wed, 21 Apr 2010) New Revision: 36401 Changeset: http://dev.haiku-os.org/changeset/36401/haiku Modified: haiku/trunk/headers/os/interface/AffineTransform.h haiku/trunk/src/kits/interface/AffineTransform.cpp Log: * 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. Modified: haiku/trunk/headers/os/interface/AffineTransform.h =================================================================== --- haiku/trunk/headers/os/interface/AffineTransform.h 2010-04-21 16:36:54 UTC (rev 36400) +++ haiku/trunk/headers/os/interface/AffineTransform.h 2010-04-21 16:46:32 UTC (rev 36401) @@ -81,6 +81,8 @@ 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 @@ 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 @@ 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 @@ 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 @@ }; +extern const BAffineTransform B_AFFINE_IDENTITY_TRANSFORM; + + // #pragma mark - inline methods Modified: haiku/trunk/src/kits/interface/AffineTransform.cpp =================================================================== --- haiku/trunk/src/kits/interface/AffineTransform.cpp 2010-04-21 16:36:54 UTC (rev 36400) +++ haiku/trunk/src/kits/interface/AffineTransform.cpp 2010-04-21 16:46:32 UTC (rev 36401) @@ -26,6 +26,9 @@ #include <TypeConstants.h> +const BAffineTransform B_AFFINE_IDENTITY_TRANSFORM; + + BAffineTransform::BAffineTransform() : sx(1.0), @@ -373,6 +376,36 @@ } +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 -