From 8e219b468a4908d880541dc3eb1495edb5fc98ef Mon Sep 17 00:00:00 2001 From: Tj Holowaychuk Date: Thu, 30 Sep 2010 13:43:24 -0700 Subject: [PATCH] Prepping fillStyle for grads --- lib/canvas.js | 18 +++++++++++------- 1 file changed, 11 insertions(+), 7 deletions(-) diff --git a/lib/canvas.js b/lib/canvas.js index 26b3990..3502a64 100644 --- a/lib/canvas.js +++ b/lib/canvas.js @@ -145,13 +145,17 @@ Context2d.prototype.createRadialGradient = function(x0, y0, r0, x1, y1, r1){ */ Context2d.prototype.__defineSetter__('fillStyle', function(val){ - var rgba = exports.parseColor(val) || [0,0,0,1]; - this.lastFillStyle = rgba; - this.setFillRGBA( - rgba[0] - , rgba[1] - , rgba[2] - , rgba[3]); + if (val instanceof CanvasGradient) { + return this.setSource(val); + } else if ('string' == typeof val) { + var rgba = exports.parseColor(val) || [0,0,0,1]; + this.lastFillStyle = rgba; + this.setFillRGBA( + rgba[0] + , rgba[1] + , rgba[2] + , rgba[3]); + } }); /**