|
|
@ -53,34 +53,6 @@ var fontre = new RegExp('^ *' |
|
|
|
+ '((?:' + string + ')( *, *(?:' + string + '))*)' |
|
|
|
); |
|
|
|
|
|
|
|
/** |
|
|
|
* Return a function used to normalize an RGBA color `prop` |
|
|
|
* or the pattern previously set. |
|
|
|
* |
|
|
|
* @param {String} prop |
|
|
|
* @return {Function} |
|
|
|
* @api private |
|
|
|
*/ |
|
|
|
|
|
|
|
function getter(prop) { |
|
|
|
return function(){ |
|
|
|
var val = this[prop]; |
|
|
|
if (val instanceof CanvasGradient) return val; |
|
|
|
if (1 == val[3]) { |
|
|
|
return '#' |
|
|
|
+ val[0].toString(16) |
|
|
|
+ val[1].toString(16) |
|
|
|
+ val[2].toString(16); |
|
|
|
} else { |
|
|
|
return 'rgba(' |
|
|
|
+ val[0] + ', ' |
|
|
|
+ val[1] + ', ' |
|
|
|
+ val[2] + ', ' |
|
|
|
+ val[3] + ')'; |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
/** |
|
|
|
* Parse font `str`. |
|
|
|
* |
|
|
@ -106,26 +78,6 @@ var parseFont = exports.parseFont = function(str){ |
|
|
|
return font; |
|
|
|
}; |
|
|
|
|
|
|
|
/** |
|
|
|
* Add `color` stop at the given `offset`. |
|
|
|
* |
|
|
|
* @param {Number} offset |
|
|
|
* @param {String} color |
|
|
|
* @api public |
|
|
|
*/ |
|
|
|
|
|
|
|
CanvasGradient.prototype.addColorStop = function(offset, color){ |
|
|
|
var rgba; |
|
|
|
if (rgba = parseColor(color)) { |
|
|
|
this.addColorStopRGBA( |
|
|
|
offset |
|
|
|
, rgba[0] |
|
|
|
, rgba[1] |
|
|
|
, rgba[2] |
|
|
|
, rgba[3]); |
|
|
|
} |
|
|
|
}; |
|
|
|
|
|
|
|
/** |
|
|
|
* Create a linear gradient at the given point `(x0, y0)` and `(x1, y1)`. |
|
|
|
* |
|
|
@ -174,7 +126,6 @@ Context2d.prototype.setTransform = function(){ |
|
|
|
/** |
|
|
|
* Set the fill style with the given css color string. |
|
|
|
* |
|
|
|
* @see exports.parseColor() |
|
|
|
* @api public |
|
|
|
*/ |
|
|
|
|
|
|
@ -183,30 +134,13 @@ Context2d.prototype.__defineSetter__('fillStyle', function(val){ |
|
|
|
this.lastFillStyle = val; |
|
|
|
this.setFillPattern(val); |
|
|
|
} else if ('string' == typeof val) { |
|
|
|
var rgba; |
|
|
|
if (rgba = parseColor(val)) { |
|
|
|
this.lastFillStyle = rgba; |
|
|
|
this.setFillRGBA( |
|
|
|
rgba[0] |
|
|
|
, rgba[1] |
|
|
|
, rgba[2] |
|
|
|
, rgba[3]); |
|
|
|
} |
|
|
|
this.setFillStyle(val); |
|
|
|
} |
|
|
|
}); |
|
|
|
|
|
|
|
/** |
|
|
|
* Get the current fill style string. |
|
|
|
* |
|
|
|
* @api public |
|
|
|
*/ |
|
|
|
|
|
|
|
Context2d.prototype.__defineGetter__('fillStyle', getter('lastFillStyle')); |
|
|
|
|
|
|
|
/** |
|
|
|
* Set the stroke style with the given css color string. |
|
|
|
* |
|
|
|
* @see exports.parseColor() |
|
|
|
* @api public |
|
|
|
*/ |
|
|
|
|
|
|
@ -215,55 +149,20 @@ Context2d.prototype.__defineSetter__('strokeStyle', function(val){ |
|
|
|
this.lastStrokeStyle = val; |
|
|
|
this.setStrokePattern(val); |
|
|
|
} else if ('string' == typeof val) { |
|
|
|
var rgba; |
|
|
|
if (rgba = parseColor(val)) { |
|
|
|
this.lastStrokeStyle = rgba; |
|
|
|
this.setStrokeRGBA( |
|
|
|
rgba[0] |
|
|
|
, rgba[1] |
|
|
|
, rgba[2] |
|
|
|
, rgba[3]); |
|
|
|
} |
|
|
|
this.setStrokeStyle(val); |
|
|
|
} |
|
|
|
}); |
|
|
|
|
|
|
|
/** |
|
|
|
* Get the current stroke style string. |
|
|
|
* |
|
|
|
* @api public |
|
|
|
*/ |
|
|
|
|
|
|
|
Context2d.prototype.__defineGetter__('strokeStyle', getter('lastStrokeStyle')); |
|
|
|
|
|
|
|
/** |
|
|
|
* Set the shadow color with the given css color string. |
|
|
|
* |
|
|
|
* @see exports.parseColor() |
|
|
|
* @api public |
|
|
|
*/ |
|
|
|
|
|
|
|
Context2d.prototype.__defineSetter__('shadowColor', function(val){ |
|
|
|
if ('string' == typeof val) { |
|
|
|
var rgba; |
|
|
|
if (rgba = parseColor(val)) { |
|
|
|
this.lastShadowColor = rgba; |
|
|
|
this.setShadowRGBA( |
|
|
|
rgba[0] |
|
|
|
, rgba[1] |
|
|
|
, rgba[2] |
|
|
|
, rgba[3]); |
|
|
|
} |
|
|
|
} |
|
|
|
this.setShadowColor(val); |
|
|
|
}); |
|
|
|
|
|
|
|
/** |
|
|
|
* Get the current shadow color string. |
|
|
|
* |
|
|
|
* @api public |
|
|
|
*/ |
|
|
|
|
|
|
|
Context2d.prototype.__defineGetter__('shadowColor', getter('lastShadowColor')); |
|
|
|
|
|
|
|
/** |
|
|
|
* Set font. |
|
|
|
* |
|
|
|