Merge remote-tracking branch 'origin/master'

Conflicts:
	src/color/Color.js
This commit is contained in:
Jürg Lehni 2011-03-09 13:34:13 +00:00
commit 41ce6279f1

View file

@ -64,8 +64,17 @@ var Color = this.Color = Base.extend(new function() {
gray: '808080', dimgray: '696969', black: '000000'
};
function hexToRGB(hex) {
hex = hex.match(/^#?(\w{1,2})(\w{1,2})(\w{1,2})$/);
function stringToRGB(string) {
// If the string isn't a hex code, it is a named color whose hex code
// needs to be looked up in the namedColor object:
if (!string.match(/^#[0-9a-f]{3,6}$/i)) {
string = namedColors[string];
if (!string)
throw new Error('The named color "' + string
+ '" does not exist.');
}
// Now convert the hex code to [r, g, b]:
var hex = string.match(/^#?(\w{1,2})(\w{1,2})(\w{1,2})$/);
if (hex.length >= 4) {
var rgb = new Array(3);
for (var i = 0; i < 3; i++) {
@ -75,18 +84,6 @@ var Color = this.Color = Base.extend(new function() {
}
return rgb;
}
}
function stringToRGB(string) {
if (string.match(/^#[0-9a-f]{3,6}$/i)) {
return hexToRGB(string);
} else {
var hex = namedColors[string];
if (!hex)
throw new Error('The named color "' + string
+ '" does not exist.');
return hexToRGB(hex);
}
};
return {
@ -168,7 +165,7 @@ var Color = this.Color = Base.extend(new function() {
},
setAlpha: function(alpha) {
this._alpha = Math.min(Math.max(alpha, 0), 1);
// this._alpha = Math.min(Math.max(alpha, 0), 1);
this._alpha = alpha < 0 ? 0 : alpha > 1 ? 1 : alpha;
this._cssString = null;
},