diff options
author | Saivan <savian@me.com> | 2018-04-18 20:55:06 +1000 |
---|---|---|
committer | Saivan <savian@me.com> | 2018-04-18 20:55:06 +1000 |
commit | 7a4979d0cfd4c4dbe91b53b69c62aa28c295af5c (patch) | |
tree | 55c8efb1dd5954544dc14702424388f26f31e1e1 /src/transform.js | |
parent | c37d94a4dccd3c0d2ce8db99bd80b6e514f5c7de (diff) | |
download | svg.js-7a4979d0cfd4c4dbe91b53b69c62aa28c295af5c.tar.gz svg.js-7a4979d0cfd4c4dbe91b53b69c62aa28c295af5c.zip |
Initial planning for the Timeline Module
This commit just includes a few plans and a massive derrangement
of the fx module before it is to be refactored into the Timeline
module. The basic methods are included, but everything is broken
Diffstat (limited to 'src/transform.js')
-rw-r--r-- | src/transform.js | 167 |
1 files changed, 6 insertions, 161 deletions
diff --git a/src/transform.js b/src/transform.js index b173cb2..ecb5fc4 100644 --- a/src/transform.js +++ b/src/transform.js @@ -50,7 +50,8 @@ SVG.extend(SVG.Element, { SVG.extend(SVG.Element, { // Add transformations - transform: function (o, cyOrRel) { + transform: function (o, relative) { + // Get the bounding box of the element with no transformations applied var bbox = this.bbox() @@ -59,20 +60,6 @@ SVG.extend(SVG.Element, { var decomposed = new SVG.Matrix(this).decompose() return decomposed[o] || decomposed - // Let the user pass in a matrix as well - } else if (o.a != null) { - // Construct a matrix from the first parameter - var matrix = new SVG.Matrix(o) - - // If we have a relative matrix, we just apply the old matrix - if (cyOrRel != null) { - var oldMatrix = new SVG.Matrix(this) - matrix = matrix.multiply(oldMatrix) - } - - // Apply the matrix directly - return this.attr('transform', matrix) - // Allow the user to define the origin with a string } else if (typeof o.origin === 'string' || (o.origin == null && o.ox == null && o.oy == null) @@ -99,13 +86,14 @@ SVG.extend(SVG.Element, { } // The user can pass a boolean, an SVG.Element or an SVG.Matrix or nothing - var result = new SVG.Matrix(cyOrRel === true ? this : cyOrRel).transform(o) + var cleanRelative = relative === true ? this : (relative || false) + var result = new SVG.Matrix(cleanRelative).transform(o) return this.attr('transform', result) } }) -SVG.extend(SVG.FX, { - transform: function (o, relative) { +SVG.extend(SVG.Timeline, { + transform: function (o, relative, affine) { // // get target in case of the fx module, otherwise reference this // var target = this.target() @@ -232,146 +220,3 @@ SVG.extend(SVG.FX, { // return this._callStart() } }) - -// TODO: DESTROY -// ======= -// -// -// SVG.Transformation = SVG.invent({ -// -// create: function(source, inversed){ -// -// if(arguments.length > 1 && typeof inversed != 'boolean'){ -// return this.constructor.call(this, [].slice.call(arguments)) -// } -// -// if(Array.isArray(source)){ -// for(var i = 0, len = this.arguments.length; i < len; ++i){ -// this[this.arguments[i]] = source[i] -// } -// } else if(typeof source == 'object'){ -// for(var i = 0, len = this.arguments.length; i < len; ++i){ -// this[this.arguments[i]] = source[this.arguments[i]] -// } -// } -// -// this.inversed = false -// -// if(inversed === true){ -// this.inversed = true -// } -// -// } -// -// , extend: { -// -// arguments: [] -// , method: '' -// -// , at: function(pos){ -// -// var params = [] -// -// for(var i = 0, len = this.arguments.length; i < len; ++i){ -// params.push(this[this.arguments[i]]) -// } -// -// var m = this._undo || new SVG.Matrix() -// -// m = new SVG.Matrix().morph(SVG.Matrix.prototype[this.method].apply(m, params)).at(pos) -// -// return this.inversed ? m.inverse() : m -// -// } -// -// , undo: function(o){ -// for(var i = 0, len = this.arguments.length; i < len; ++i){ -// o[this.arguments[i]] = typeof this[this.arguments[i]] == 'undefined' ? 0 : o[this.arguments[i]] -// } -// -// // The method SVG.Matrix.extract which was used before calling this -// // method to obtain a value for the parameter o doesn't return a cx and -// // a cy so we use the ones that were provided to this object at its creation -// o.cx = this.cx -// o.cy = this.cy -// -// this._undo = new SVG[capitalize(this.method)](o, true).at(1) -// -// return this -// } -// -// } -// -// }) -// -// SVG.Translate = SVG.invent({ -// -// parent: SVG.Matrix -// , inherit: SVG.Transformation -// -// , create: function(source, inversed){ -// this.constructor.apply(this, [].slice.call(arguments)) -// } -// -// , extend: { -// arguments: ['transformedX', 'transformedY'] -// , method: 'translate' -// } -// -// }) -// -// SVG.Rotate = SVG.invent({ -// -// parent: SVG.Matrix -// , inherit: SVG.Transformation -// -// , create: function(source, inversed){ -// this.constructor.apply(this, [].slice.call(arguments)) -// } -// -// , extend: { -// arguments: ['rotation', 'cx', 'cy'] -// , method: 'rotate' -// , at: function(pos){ -// var m = new SVG.Matrix().rotate(new SVG.Number().morph(this.rotation - (this._undo ? this._undo.rotation : 0)).at(pos), this.cx, this.cy) -// return this.inversed ? m.inverse() : m -// } -// , undo: function(o){ -// this._undo = o -// return this -// } -// } -// -// }) -// -// SVG.Scale = SVG.invent({ -// -// parent: SVG.Matrix -// , inherit: SVG.Transformation -// -// , create: function(source, inversed){ -// this.constructor.apply(this, [].slice.call(arguments)) -// } -// -// , extend: { -// arguments: ['scaleX', 'scaleY', 'cx', 'cy'] -// , method: 'scale' -// } -// -// }) -// -// SVG.Skew = SVG.invent({ -// -// parent: SVG.Matrix -// , inherit: SVG.Transformation -// -// , create: function(source, inversed){ -// this.constructor.apply(this, [].slice.call(arguments)) -// } -// -// , extend: { -// arguments: ['skewX', 'skewY', 'cx', 'cy'] -// , method: 'skew' -// } -// -// }) |