|
|
@ -67,7 +67,7 @@ var cache = {}; |
|
|
|
* @api public |
|
|
|
*/ |
|
|
|
|
|
|
|
exports.parseColor = function(str){ |
|
|
|
var parseColor = exports.parseColor = function(str){ |
|
|
|
if (cache[str]) return cache[str]; |
|
|
|
str = colors[str] || String(str); |
|
|
|
if (0 == str.indexOf('rgba')) { |
|
|
@ -127,13 +127,15 @@ Canvas.prototype.getContext = function(contextId){ |
|
|
|
}; |
|
|
|
|
|
|
|
CanvasGradient.prototype.addColorStop = function(offset, color){ |
|
|
|
var rgba = exports.parseColor(color) || [0,0,0,1]; |
|
|
|
this.addColorStopRGBA( |
|
|
|
offset |
|
|
|
, rgba[0] |
|
|
|
, rgba[1] |
|
|
|
, rgba[2] |
|
|
|
, rgba[3]); |
|
|
|
var rgba; |
|
|
|
if (rgba = parseColor(color)) { |
|
|
|
this.addColorStopRGBA( |
|
|
|
offset |
|
|
|
, rgba[0] |
|
|
|
, rgba[1] |
|
|
|
, rgba[2] |
|
|
|
, rgba[3]); |
|
|
|
} |
|
|
|
}; |
|
|
|
|
|
|
|
Context2d.prototype.createLinearGradient = function(x0, y0, x1, y1){ |
|
|
@ -155,13 +157,15 @@ Context2d.prototype.__defineSetter__('fillStyle', function(val){ |
|
|
|
if (val instanceof CanvasGradient) { |
|
|
|
this.setFillPattern(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]); |
|
|
|
var rgba; |
|
|
|
if (rgba = parseColor(val)) { |
|
|
|
this.lastFillStyle = rgba; |
|
|
|
this.setFillRGBA( |
|
|
|
rgba[0] |
|
|
|
, rgba[1] |
|
|
|
, rgba[2] |
|
|
|
, rgba[3]); |
|
|
|
} |
|
|
|
} |
|
|
|
}); |
|
|
|
|
|
|
@ -187,13 +191,15 @@ Context2d.prototype.__defineSetter__('strokeStyle', function(val){ |
|
|
|
if (val instanceof CanvasGradient) { |
|
|
|
this.setStrokePattern(val); |
|
|
|
} else if ('string' == typeof val) { |
|
|
|
var rgba = exports.parseColor(val) || [0,0,0,1]; |
|
|
|
this.lastStrokeStyle = rgba; |
|
|
|
this.setStrokeRGBA( |
|
|
|
rgba[0] |
|
|
|
, rgba[1] |
|
|
|
, rgba[2] |
|
|
|
, rgba[3]); |
|
|
|
var rgba; |
|
|
|
if (rgba = parseColor(val)) { |
|
|
|
this.lastStrokeStyle = rgba; |
|
|
|
this.setStrokeRGBA( |
|
|
|
rgba[0] |
|
|
|
, rgba[1] |
|
|
|
, rgba[2] |
|
|
|
, rgba[3]); |
|
|
|
} |
|
|
|
} |
|
|
|
}); |
|
|
|
|
|
|
|