Browse Source

Added Context2d#strokeStyle

v1.x
Tj Holowaychuk 15 years ago
parent
commit
c20cc1336c
  1. 41
      lib/canvas.js

41
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] + ')';
});
Loading…
Cancel
Save