Skip to content

Commit

Permalink
- added named colors support to Color. - renamed the internal proper…
Browse files Browse the repository at this point in the history
…ty $typeOf to $family.
  • Loading branch information
kamicane committed Apr 7, 2010
1 parent 25b06ef commit f08bab0
Showing 1 changed file with 13 additions and 0 deletions.
13 changes: 13 additions & 0 deletions Color.js
Expand Up @@ -9,6 +9,13 @@ provides: Color

(function(){

var colors = {
maroon: '#800000', red: '#ff0000', orange: '#ffA500', yellow: '#ffff00', olive: '#808000',
purple: '#800080', fuchsia: "#ff00ff", white: '#ffffff', lime: '#00ff00', green: '#008000',
navy: '#000080', blue: '#0000ff', aqua: '#00ffff', teal: '#008080',
black: '#000000', silver: '#c0c0c0', gray: '#808080'
};

var Color = this.Color = function(color, type){

if (color.isColor){
Expand All @@ -19,6 +26,12 @@ var Color = this.Color = function(color, type){
this.alpha = color.alpha;

} else {

var namedColor = colors[color];
if (namedColor){
color = namedColor;
type = 'hex';
}

switch (typeof color){
case 'string': if (!type) type = (type = color.match(/^rgb|^hsb/)) ? type[0] : 'hex'; break;
Expand Down

0 comments on commit f08bab0

Please sign in to comment.