Merge pull request #18 from aduros/affine-patch

Take shortcuts in translate() and scale().
This commit is contained in:
Michael Bayne
2012-12-10 15:36:31 -08:00
2 changed files with 16 additions and 4 deletions
@@ -191,7 +191,11 @@ public class AffineTransform extends AbstractTransform
@Override // from Transform
public Transform scale (double scaleX, double scaleY) {
return Transforms.multiply(this, scaleX, 0, 0, scaleY, 0, 0, this);
m00 *= scaleX;
m01 *= scaleX;
m10 *= scaleY;
m11 *= scaleY;
return this;
}
@Override // from Transform
@@ -212,7 +216,9 @@ public class AffineTransform extends AbstractTransform
@Override // from Transform
public Transform translate (double tx, double ty) {
return Transforms.multiply(this, 1, 0, 0, 1, tx, ty, this);
this.tx += m00*tx + m10*ty;
this.ty += m11*ty + m01*tx;
return this;
}
@Override // from Transform
@@ -191,7 +191,11 @@ public class AffineTransform extends AbstractTransform
@Override // from Transform
public Transform scale (float scaleX, float scaleY) {
return Transforms.multiply(this, scaleX, 0, 0, scaleY, 0, 0, this);
m00 *= scaleX;
m01 *= scaleX;
m10 *= scaleY;
m11 *= scaleY;
return this;
}
@Override // from Transform
@@ -212,7 +216,9 @@ public class AffineTransform extends AbstractTransform
@Override // from Transform
public Transform translate (float tx, float ty) {
return Transforms.multiply(this, 1, 0, 0, 1, tx, ty, this);
this.tx += m00*tx + m10*ty;
this.ty += m11*ty + m01*tx;
return this;
}
@Override // from Transform