1 if(!dojo._hasResource["dojox.charting._color"]){ //_hasResource checks added by build. Do not use _hasResource directly in your code.
2 dojo._hasResource["dojox.charting._color"] = true;
3 dojo.provide("dojox.charting._color");
5 dojox.charting._color={};
6 dojox.charting._color.fromHsb=function(/* int */hue, /* int */saturation, /* int */brightness){
8 // Creates an instance of dojo.Color based on HSB input (360, %, %)
10 saturation=Math.round((saturation/100)*255);
11 brightness=Math.round((brightness/100)*255);
18 tint2=(255-saturation)*brightness/255,
19 tint3=(tint1-tint2)*(hue%60)/60;
20 if(hue<60){ r=tint1, g=tint2+tint3, b=tint2; }
21 else if(hue<120){ r=tint1-tint3, g=tint1, b=tint2; }
22 else if(hue<180){ r=tint2, g=tint1, b=tint2+tint3; }
23 else if(hue<240){ r=tint2, g=tint1-tint3, b=tint1; }
24 else if(hue<300){ r=tint2+tint3, g=tint2, b=tint1; }
25 else if(hue<360){ r=tint1, g=tint2, b=tint1-tint3; }
28 r=Math.round(r); g=Math.round(g); b=Math.round(b);
29 return new dojo.Color({ r:r, g:g, b:b });
32 dojox.charting._color.toHsb=function(/* int|Object|dojo.Color */ red, /* int? */ green, /* int? */blue){
34 // Returns the color in HSB representation (360, %, %)
35 var r=red,g=green,b=blue;
36 if(dojo.isObject(red)){
37 r=red.r,g=red.g,b=red.b;
39 var min=Math.min(r,g,b);
40 var max=Math.max(r,g,b);
43 var hue=0, saturation=(max!=0?delta/max:0), brightness=max/255;
44 if(saturation==0){ hue=0; }
46 if(r==max){ hue=((max-b)/delta)-((max-g)/delta); }
47 else if(g==max){ hue=2+(((max-r)/delta)-((max-b)/delta)); }
48 else { hue=4+(((max-g)/delta)-((max-r)/delta)); }
53 hue=Math.round(hue*360);
54 saturation=Math.round(saturation*100);
55 brightness=Math.round(brightness*100);
57 h:hue, s:saturation, b:brightness,
58 hue:hue, saturation:saturation, brightness:brightness