From 99c2d41a80658ff0c0d381ba215ff826b5d99a55 Mon Sep 17 00:00:00 2001 From: wout Date: Thu, 3 Jan 2013 21:37:24 +0100 Subject: Fix in color parser --- src/fx.js | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) (limited to 'src') diff --git a/src/fx.js b/src/fx.js index c35478c..40baf87 100644 --- a/src/fx.js +++ b/src/fx.js @@ -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 -- cgit v1.2.3