]> git.saurik.com Git - wxWidgets.git/commitdiff
Fix wxAffineMatrix2D::Translate() to multiply on the left.
authorVadim Zeitlin <vadim@wxwidgets.org>
Mon, 23 Jan 2012 11:28:16 +0000 (11:28 +0000)
committerVadim Zeitlin <vadim@wxwidgets.org>
Mon, 23 Jan 2012 11:28:16 +0000 (11:28 +0000)
The affine transform was previously multiplied by the translation matrix on
the right but this was incompatible with both the MSW version of the same
method and all the other methods of the generic version.

So multiply the transform by the translation on the left, as everywhere else.

Closes #13875.

git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@70444 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775

src/common/affinematrix2d.cpp
tests/graphics/affinematrix.cpp

index 5df1bac1e6a440004c72e9c5b31eef12f98e822e..0b1b9207dc90758d44f24dcf7b6d2745b9324869 100644 (file)
@@ -106,10 +106,13 @@ bool wxAffineMatrix2D::IsEqual(const wxAffineMatrix2DBase& t) const
 //
 
 // add the translation to this matrix
+// |  1   0   0 |   | m_11  m_12   0 |
+// |  0   1   0 | x | m_21  m_22   0 |
+// | dx  dy   1 |   | m_tx  m_ty   1 |
 void wxAffineMatrix2D::Translate(wxDouble dx, wxDouble dy)
 {
-    m_tx += dx;
-    m_ty += dy;
+    m_tx += m_11 * dx + m_21 * dy;
+    m_ty += m_12 * dx + m_22 * dy;
 }
 
 // add the scale to this matrix
index ee6c5470ddb1abee20c30f3a76621bd6b2f1b3ce..90f56cc1a9ce150fbf1d2ea5f30bdf81fdcdcf65 100644 (file)
@@ -112,7 +112,7 @@ void AffineTransformTestCase::VMirrorAndTranslate()
 
         wxAffineMatrix2D matrix;
         matrix.Mirror(wxVERTICAL);
-        matrix.Translate(0, m_bmpOrig.GetHeight() - 1);
+        matrix.Translate(0, -m_bmpOrig.GetHeight() + 1);
         dc.SetTransformMatrix(matrix);
         dc.DrawBitmap(m_bmpOrig, 0, 0);
     }
@@ -134,7 +134,7 @@ void AffineTransformTestCase::Rotate90Clockwise()
 
         wxAffineMatrix2D matrix;
         matrix.Rotate(-0.5 * M_PI);
-        matrix.Translate(m_bmpOrig.GetHeight(), 0);
+        matrix.Translate(0, -m_bmpOrig.GetHeight());
         dc.SetTransformMatrix(matrix);
         dc.DrawBitmap(m_bmpOrig, 0, 0);
     }