diff --git a/lib/canvas.js b/lib/canvas.js index d892b73..136484b 100644 --- a/lib/canvas.js +++ b/lib/canvas.js @@ -111,6 +111,13 @@ Canvas.prototype.getContext = function(contextId){ } }; +/** + * Set the fill style with the given css color string. + * + * @see exports.parseColor() + * @api public + */ + Context2d.prototype.__defineSetter__('fillStyle', function(val){ var rgba = exports.parseColor(val) || [0,0,0,1]; this.lastFillStyle = rgba; @@ -121,7 +128,41 @@ Context2d.prototype.__defineSetter__('fillStyle', function(val){ , rgba[3]); }); +/** + * Get the current fill style string. + * + * @api public + */ + Context2d.prototype.__defineGetter__('fillStyle', function(){ var rgba = this.lastFillStyle; return 'rgba(' + rgba[0] + ',' + rgba[1] + ',' + rgba[2] + ',' + rgba[3] + ')'; +}); + +/** + * Set the stroke style with the given css color string. + * + * @see exports.parseColor() + * @api public + */ + +Context2d.prototype.__defineSetter__('strokeStyle', function(val){ + var rgba = exports.parseColor(val) || [0,0,0,1]; + this.lastStrokeStyle = rgba; + this.setStrokeRGBA( + rgba[0] + , rgba[1] + , rgba[2] + , rgba[3]); +}); + +/** + * Get the current stroke style string. + * + * @api public + */ + +Context2d.prototype.__defineGetter__('strokeStyle', function(){ + var rgba = this.lastStrokeStyle; + return 'rgba(' + rgba[0] + ',' + rgba[1] + ',' + rgba[2] + ',' + rgba[3] + ')'; }); \ No newline at end of file