]>
git.wh0rd.org - tt-rss.git/blob - lib/dojo/_base/Color.js
2 Copyright (c) 2004-2010, The Dojo Foundation All Rights Reserved.
3 Available via Academic Free License >= 2.1 OR the modified BSD license.
4 see: http://dojotoolkit.org/license for details
8 if(!dojo
._hasResource
["dojo._base.Color"]){
9 dojo
._hasResource
["dojo._base.Color"]=true;
10 dojo
.provide("dojo._base.Color");
11 dojo
.require("dojo._base.array");
12 dojo
.require("dojo._base.lang");
15 dojo
.Color=function(_1
){
20 dojo
.Color
.named
={black
:[0,0,0],silver
:[192,192,192],gray
:[128,128,128],white
:[255,255,255],maroon
:[128,0,0],red
:[255,0,0],purple
:[128,0,128],fuchsia
:[255,0,255],green
:[0,128,0],lime
:[0,255,0],olive
:[128,128,0],yellow
:[255,255,0],navy
:[0,0,128],blue
:[0,0,255],teal
:[0,128,128],aqua
:[0,255,255],transparent
:d
.config
.transparentColor
||[255,255,255]};
21 dojo
.extend(dojo
.Color
,{r
:255,g
:255,b
:255,a
:1,_set:function(r
,g
,b
,a
){
27 },setColor:function(_2
){
29 d
.colorFromString(_2
,this);
32 d
.colorFromArray(_2
,this);
34 this._set(_2
.r
,_2
.g
,_2
.b
,_2
.a
);
35 if(!(_2
instanceof d
.Color
)){
41 },sanitize:function(){
48 return [t
.r
,t
.g
,t
.b
,t
.a
];
50 var _3
=d
.map(["r","g","b"],function(x
){
51 var s
=this[x
].toString(16);
52 return s
.length
<2?"0"+s
:s
;
54 return "#"+_3
.join("");
56 var t
=this,_5
=t
.r
+", "+t
.g
+", "+t
.b
;
57 return (_4
?"rgba("+_5
+", "+t
.a
:"rgb("+_5
)+")";
58 },toString:function(){
59 return this.toCss(true);
61 dojo
.blendColors=function(_6
,_7
,_8
,_9
){
62 var t
=_9
||new d
.Color();
63 d
.forEach(["r","g","b","a"],function(x
){
64 t
[x
]=_6
[x
]+(_7
[x
]-_6
[x
])*_8
;
66 t
[x
]=Math
.round(t
[x
]);
71 dojo
.colorFromRgb=function(_a
,_b
){
72 var m
=_a
.toLowerCase().match(/^rgba?\(([\s\.,0-9]+)\)/);
73 return m
&&dojo
.colorFromArray(m
[1].split(/\s*,\s*/),_b
);
75 dojo
.colorFromHex=function(_c
,_d
){
76 var t
=_d
||new d
.Color(),_e
=(_c
.length
==4)?4:8,_f
=(1<<_e
)-1;
77 _c
=Number("0x"+_c
.substr(1));
81 d
.forEach(["b","g","r"],function(x
){
89 dojo
.colorFromArray=function(a
,obj
){
90 var t
=obj
||new d
.Color();
91 t
._set(Number(a
[0]),Number(a
[1]),Number(a
[2]),Number(a
[3]));
97 dojo
.colorFromString=function(str
,obj
){
98 var a
=d
.Color
.named
[str
];
99 return a
&&d
.colorFromArray(a
,obj
)||d
.colorFromRgb(str
,obj
)||d
.colorFromHex(str
,obj
);