diff options
author | wout <wout@impinc.co.uk> | 2013-01-03 21:37:24 +0100 |
---|---|---|
committer | wout <wout@impinc.co.uk> | 2013-01-03 21:37:24 +0100 |
commit | 99c2d41a80658ff0c0d381ba215ff826b5d99a55 (patch) | |
tree | 2ccca39073dcab2e76958832cd5c41c1524bf590 /src/fx.js | |
parent | 6f49a9d4c5ada0b7335c08fbcef623cf32898938 (diff) | |
download | svg.js-99c2d41a80658ff0c0d381ba215ff826b5d99a55.tar.gz svg.js-99c2d41a80658ff0c0d381ba215ff826b5d99a55.zip |
Fix in color parser
Diffstat (limited to 'src/fx.js')
-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 |