diff options
-rw-r--r-- | dirty.html | 4 | ||||
-rw-r--r-- | src/matrix.js | 1 | ||||
-rw-r--r-- | src/runner.js | 7 |
3 files changed, 10 insertions, 2 deletions
@@ -218,11 +218,11 @@ a.timeline().source(() => { }) -let obj = { rotate: 90, shear:2, origin: [600, 600], translate: [100, 100] } +let obj = { rotate: 100, shear:2, origin: [600, 600], translate: [100, 100] } a.clone() // startPosition a.clone().transform(obj) // endPosition -a.animate(new SVG.PID(0.1, 0.1)).transform(obj) // animation +a.animate(new SVG.Spring(50, 30)).transform(obj) // animation // Put an ellipse where we expect the object to be diff --git a/src/matrix.js b/src/matrix.js index 05e9c7d..4396816 100644 --- a/src/matrix.js +++ b/src/matrix.js @@ -129,6 +129,7 @@ SVG.Matrix = SVG.invent({ var lam = (a * c + b * d) / determinant var sy = ((c * sx) / (lam * a - b)) || ((d * sx) / (lam * b + a)) + // Use the translations let tx = e - cx + cx * ct * sx + cy * (lam * ct * sx - st * sy) let ty = f - cy + cx * st * sx + cy * (lam * st * sx + ct * sy) diff --git a/src/runner.js b/src/runner.js index 963f31b..4c9dda2 100644 --- a/src/runner.js +++ b/src/runner.js @@ -700,6 +700,13 @@ SVG.extend(SVG.Runner, { } // FIXME: correct the rotation so that it takes the shortest path + // GIVE ME (rCurrent) (rTarget) - to store the current/target angle + const possibilities = [rTarget - 360, rTarget, rTarget + 360] + const distances = possibilities.map( a => Math.abs(a - rCurrent) ) + const shortest = Math.min(...distances) + const index = distances.indexOf(shortest) + const target = possibilities[index] + morpher.from(startMatrix) }, function (pos) { |