From b85982e025ee1d45a7a9873f5809ed45f3412201 Mon Sep 17 00:00:00 2001 From: kitfox Date: Sat, 29 Sep 2012 06:49:32 +0000 Subject: AnimateTransform can now handle short parameter lists. git-svn-id: https://svn.java.net/svn/svgsalamander~svn/trunk/svg-core@127 7dc7fa77-23fb-e6ad-8e2e-c86bd48ed22b --- .../com/kitfox/svg/animation/AnimateTransform.java | 29 +++++++++++++++------- 1 file changed, 20 insertions(+), 9 deletions(-) (limited to 'src/main/java/com/kitfox/svg/animation/AnimateTransform.java') diff --git a/src/main/java/com/kitfox/svg/animation/AnimateTransform.java b/src/main/java/com/kitfox/svg/animation/AnimateTransform.java index 61d73b2..14e39c2 100644 --- a/src/main/java/com/kitfox/svg/animation/AnimateTransform.java +++ b/src/main/java/com/kitfox/svg/animation/AnimateTransform.java @@ -182,8 +182,14 @@ public class AnimateTransform extends AnimateXform { case TR_TRANSLATE: { - double x = (1.0 - interp) * fromValue[0] + interp * toValue[0]; - double y = (1.0 - interp) * fromValue[1] + interp * toValue[1]; + double x0 = fromValue.length > 1 ? fromValue[0] : 0; + double x1 = toValue.length > 1 ? toValue[0] : 0; + double y0 = fromValue.length > 2 ? fromValue[1] : 0; + double y1 = toValue.length > 2 ? toValue[1] : 0; + + double x = lerp(x0, x1, interp); + double y = lerp(y0, y1, interp); + xform.setToTranslation(x, y); break; } @@ -194,28 +200,33 @@ public class AnimateTransform extends AnimateXform double x2 = toValue.length == 3 ? toValue[1] : 0; double y2 = toValue.length == 3 ? toValue[2] : 0; - double theta = (1.0 - interp) * fromValue[0] + interp * toValue[0]; - double x = (1.0 - interp) * x1 + interp * x2; - double y = (1.0 - interp) * y1 + interp * y2; + double theta = lerp(fromValue[0], toValue[0], interp); + double x = lerp(x1, x2, interp); + double y = lerp(y1, y2, interp); xform.setToRotation(Math.toRadians(theta), x, y); break; } case TR_SCALE: { - double x = (1.0 - interp) * fromValue[0] + interp * toValue[0]; - double y = (1.0 - interp) * fromValue[1] + interp * toValue[1]; + double x0 = fromValue.length > 1 ? fromValue[0] : 1; + double x1 = toValue.length > 1 ? toValue[0] : 1; + double y0 = fromValue.length > 2 ? fromValue[1] : 1; + double y1 = toValue.length > 2 ? toValue[1] : 1; + + double x = lerp(x0, x1, interp); + double y = lerp(y0, y1, interp); xform.setToScale(x, y); break; } case TR_SKEWX: { - double x = (1.0 - interp) * fromValue[0] + interp * toValue[0]; + double x = lerp(fromValue[0], toValue[0], interp); xform.setToShear(Math.toRadians(x), 0.0); break; } case TR_SKEWY: { - double y = (1.0 - interp) * fromValue[0] + interp * toValue[0]; + double y = lerp(fromValue[0], toValue[0], interp); xform.setToShear(0.0, Math.toRadians(y)); break; } -- cgit v1.2.3-55-g7522