diff options
author | wout <wout@impinc.co.uk> | 2013-06-23 14:59:46 +0100 |
---|---|---|
committer | wout <wout@impinc.co.uk> | 2013-06-23 14:59:46 +0100 |
commit | a72b8a7afb609b9a76c494d9123d78e5c40962bf (patch) | |
tree | fdaacf9d56a3cc9e935ab1a5dcb4ad0458f929e4 /src/fx.js | |
parent | 5e52bd4f9f309b20bc848d5d45e5e620b17c1ad7 (diff) | |
download | svg.js-a72b8a7afb609b9a76c494d9123d78e5c40962bf.tar.gz svg.js-a72b8a7afb609b9a76c494d9123d78e5c40962bf.zip |
Added SVG.Number, reworked gradient system
Diffstat (limited to 'src/fx.js')
-rw-r--r-- | src/fx.js | 28 |
1 files changed, 14 insertions, 14 deletions
@@ -250,6 +250,16 @@ SVG.extend(SVG.FX, { return this } + // Add animateable gradient update +, update: function(o) { + if (this.target instanceof SVG.Stop) { + if (o.opacity != null) this.attr('stop-opacity', o.opacity) + if (o.color != null) this.attr('stop-color', o.color) + if (o.offset != null) this.attr('offset', new SVG.Number(o.offset)) + } + + return this + } // Add callback for each keyframe , during: function(during) { this._during = during @@ -291,7 +301,10 @@ SVG.extend(SVG.FX, { /* unit recalculation */ SVG.regex.unit.test(o.to) ? - this._unit(o, pos) : + new SVG.Number(o.to) + .minus(new SVG.Number(o.from)) + .times(pos) + .plus(new SVG.Number(o.from)) : /* color recalculation */ o.to && (o.to.r || SVG.Color.test(o.to)) ? @@ -300,19 +313,6 @@ SVG.extend(SVG.FX, { /* for all other values wait until pos has reached 1 to return the final value */ pos < 1 ? o.from : o.to } - // Private: tween unit -, _unit: function(o, pos) { - var match, from - - /* convert FROM unit */ - match = SVG.regex.unit.exec(o.from.toString()) - from = parseFloat(match ? match[1] : 0) - - /* convert TO unit */ - match = SVG.regex.unit.exec(o.to) - - return (from + (parseFloat(match[1]) - from) * pos) + match[2] - } // Private: tween color , _color: function(o, pos) { var from, to |