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]); + } }); /**