now working for art of presence

This commit is contained in:
Peter Cottle 2012-08-13 12:54:02 -07:00
parent a817cec5f5
commit c4cc6cd57e
3 changed files with 37 additions and 4 deletions

View file

@ -60,7 +60,7 @@ function Color(color_string)
},
{
re: /^rgba\((\d{1,3}),\s*(\d{1,3}),\s*(\d{1,3}),\s*([0-9.]+)\)*$/,
example: ['rgba(123, 234, 45, 0.2)', 'rgb(255,234,245,1)'],
example: ['rgba(123, 234, 45, 0.2)', 'rgba(255,234,245,1)'],
process: function (bits){
return [
parseInt(bits[1]),
@ -69,7 +69,21 @@ function Color(color_string)
parseFloat(bits[4])
];
}
},
{
re: /^rgba\((\d{1,3})%,\s*(\d{1,3})%,\s*(\d{1,3})%,\s*([0-9.]+)\)*$/,
example: ['rgba(100%, 97%, 45%, 0.2)', 'rgba(1%,4%,245%,1)'],
process: function (bits){
var parseRound = function(bit) {
return Math.round((parseInt(bit) / 100) * 256);
};
return [
parseRound(bits[1]),
parseRound(bits[2]),
parseRound(bits[3]),
parseFloat(bits[4])
];
}
}
];
@ -104,7 +118,7 @@ function Color(color_string)
return 'rgb(' + this.r + ', ' + this.g + ', ' + this.b + ')';
}
this.toRGBA = function() {
return 'rgb(' + this.r + ', ' + this.g + ', ' + this.b + ', ' + this.a;
return 'rgba(' + this.r + ', ' + this.g + ', ' + this.b + ', ' + this.a + ')';
}
this.toHex = function () {