aboutsummaryrefslogtreecommitdiffstats
path: root/src/matrix.js
diff options
context:
space:
mode:
authorwout <wout@impinc.co.uk>2014-08-30 17:06:00 +0200
committerwout <wout@impinc.co.uk>2014-08-30 17:06:00 +0200
commitbde8508836f9cad16b462c811d124258ca35400d (patch)
treedf79d62041c7afa4a40517f27ddb2a6a45568e63 /src/matrix.js
parent6c1820b4c5790be1b0872a49a50d10d97a243292 (diff)
downloadsvg.js-bde8508836f9cad16b462c811d124258ca35400d.tar.gz
svg.js-bde8508836f9cad16b462c811d124258ca35400d.zip
Added animated parametric transformations
Diffstat (limited to 'src/matrix.js')
-rw-r--r--src/matrix.js36
1 files changed, 16 insertions, 20 deletions
diff --git a/src/matrix.js b/src/matrix.js
index 26b7613..4531457 100644
--- a/src/matrix.js
+++ b/src/matrix.js
@@ -17,10 +17,6 @@ SVG.Matrix = SVG.invent({
for (i = abcdef.length - 1; i >= 0; i--)
this[abcdef[i]] = typeof source[abcdef[i]] === 'number' ?
source[abcdef[i]] : base[abcdef[i]]
-
- // merge polymertic values
- if (source._r)
- this._r = source._r
}
// Add methods
@@ -55,10 +51,6 @@ SVG.Matrix = SVG.invent({
// store new destination
this.destination = new SVG.Matrix(matrix)
- // detect polymetric rotation
- if (this.destination._r)
- this._r = this.extract()
-
return this
}
// Get morphed matrix at a given position
@@ -76,13 +68,21 @@ SVG.Matrix = SVG.invent({
, f: this.f + (this.destination.f - this.f) * pos
})
- // add polymetric rotation if required
- if (this._r && this.destination._r)
- matrix = matrix.rotate(
- this._r.rotation + (this.destination._r.rotation - this._r.rotation) * pos
- , this.destination._r.cx
- , this.destination._r.cy
- )
+ // process parametric rotation if present
+ if (this.param && this.param.to) {
+ // calculate current parametric position
+ var param = {
+ rotation: this.param.from.rotation + (this.param.to.rotation - this.param.from.rotation) * pos
+ , cx: this.param.from.cx
+ , cy: this.param.from.cy
+ }
+
+ // rotate matrix
+ matrix = matrix.rotate(param.rotation - this.param.initial, param.cx, param.cy)
+
+ // store current parametric values
+ matrix.param = param
+ }
return matrix
}
@@ -158,11 +158,7 @@ SVG.Matrix = SVG.invent({
}
// Convert matrix to string
, toString: function() {
- return 'matrix(' + this.toArray().join() + ')'
- }
- // Convert matrix to array
- , toArray: function() {
- return [this.a, this.b, this.c, this.d, this.e, this.f]
+ return 'matrix(' + this.a + ',' + this.b + ',' + this.c + ',' + this.d + ',' + this.e + ',' + this.f + ')'
}
}