Avoid an extra division (and field update) in setScaleX/Y. Thanks Tim!
This commit is contained in:
@@ -122,18 +122,18 @@ public class AffineTransform extends AbstractTransform
|
|||||||
@Override // from Transform
|
@Override // from Transform
|
||||||
public Transform setScaleX (double scaleX) {
|
public Transform setScaleX (double scaleX) {
|
||||||
// normalize the scale to 1, then re-apply
|
// normalize the scale to 1, then re-apply
|
||||||
double osx = scaleX();
|
double mult = scaleX / scaleX();
|
||||||
m00 /= osx; m01 /= osx;
|
m00 *= mult;
|
||||||
m00 *= scaleX; m01 *= scaleX;
|
m01 *= mult;
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override // from Transform
|
@Override // from Transform
|
||||||
public Transform setScaleY (double scaleY) {
|
public Transform setScaleY (double scaleY) {
|
||||||
// normalize the scale to 1, then re-apply
|
// normalize the scale to 1, then re-apply
|
||||||
double osy = scaleY();
|
double mult = scaleY / scaleY();
|
||||||
m10 /= osy; m11 /= osy;
|
m10 *= mult;
|
||||||
m10 *= scaleY; m11 *= scaleY;
|
m11 *= mult;
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -122,18 +122,18 @@ public class AffineTransform extends AbstractTransform
|
|||||||
@Override // from Transform
|
@Override // from Transform
|
||||||
public Transform setScaleX (float scaleX) {
|
public Transform setScaleX (float scaleX) {
|
||||||
// normalize the scale to 1, then re-apply
|
// normalize the scale to 1, then re-apply
|
||||||
float osx = scaleX();
|
float mult = scaleX / scaleX();
|
||||||
m00 /= osx; m01 /= osx;
|
m00 *= mult;
|
||||||
m00 *= scaleX; m01 *= scaleX;
|
m01 *= mult;
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override // from Transform
|
@Override // from Transform
|
||||||
public Transform setScaleY (float scaleY) {
|
public Transform setScaleY (float scaleY) {
|
||||||
// normalize the scale to 1, then re-apply
|
// normalize the scale to 1, then re-apply
|
||||||
float osy = scaleY();
|
float mult = scaleY / scaleY();
|
||||||
m10 /= osy; m11 /= osy;
|
m10 *= mult;
|
||||||
m10 *= scaleY; m11 *= scaleY;
|
m11 *= mult;
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user