diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/fx.js | 9 |
1 files changed, 8 insertions, 1 deletions
@@ -177,6 +177,7 @@ SVG.extend(SVG.FX, { o.from = this._h2r(o.from || '#000'); // convert hex to rgb and store it for further reference + if (typeof o.to !== 'object') o.to = this._h2r(o.to); @@ -203,7 +204,13 @@ SVG.extend(SVG.FX, { // private: convert rgb object to hex string _r2h: function(r) { - return '#' + (r.r + 256 * r.g + 65536 * r.b).toString(16); + return '#' + this._c2h(r.r) + this._c2h(r.g) + this._c2h(r.b); + }, + + // private: convert component to hex + _c2h: function(c) { + var h = c.toString(16); + return h.length == 1 ? '0' + h : h; }, // private: force potential 3-based hex to 6-based |