aboutsummaryrefslogtreecommitdiff
path: root/includes/js/dojox/color/tests/Generator.js
blob: 6232cc7b8c2c9dbec3b1a1cee61c1a3bb2684339 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
if(!dojo._hasResource["dojox.color.tests.Generator"]){ //_hasResource checks added by build. Do not use _hasResource directly in your code.
dojo._hasResource["dojox.color.tests.Generator"] = true;
dojo.provide("dojox.color.tests.Generator");
dojo.require("dojox.color.Generator");

tests.register("dojox.color.tests.Generator", [
	function testAnalogous(t){
		//	test the defaults
		var args={ base: new dojox.color.Color({ r:128, g:0, b:0 }) };
		var a=dojox.color.Generator.analogous(args);
		var s='<h3>dojox.color.Generator.analogous</h3><table cellpadding="0" cellspacing="1" border="0"><tr>';
		var cols=5, c=0;
		dojo.forEach(a, function(item){
			if(c++%cols==0){ s+="</tr><tr>"; }
			s+='<td width="32" bgcolor="'+item.toHex()+'">&nbsp;</td>';
		});
		if(c<cols){
			for(; c<cols; c++){
				s+='<td width="32">&nbsp;</td>';
			}
		}
		t.debug(s+'</tr></table>');
	},

	function testMonochromatic(t){
		//	test the defaults
		var a=dojox.color.Generator.monochromatic({ base:new dojox.color.Color({r:128, g:0, b:0}) });
		var s='<h3>dojox.color.Generator.monochromatic</h3><table cellpadding="0" cellspacing="1" border="0"><tr>';
		var cols=8, c=0;
		dojo.forEach(a, function(item){
			if(c++%cols==0){ s+="</tr><tr>"; }
			s+='<td width="32" bgcolor="'+item.toHex()+'">&nbsp;</td>';
		});
		if(c<cols){
			for(; c<cols; c++){
				s+='<td width="32">&nbsp;</td>';
			}
		}
		t.debug(s+'</tr></table>');
	},

	function testTriadic(t){
		//	test the defaults
		var a=dojox.color.Generator.triadic({ base:new dojox.color.Color({r:128, g:0, b:0}) });
		var s='<h3>dojox.color.Generator.triadic</h3><table cellpadding="0" cellspacing="1" border="0"><tr>';
		var cols=3, c=0;
		dojo.forEach(a, function(item){
			if(c++%cols==0){ s+="</tr><tr>"; }
			s+='<td width="32" bgcolor="'+item.toHex()+'">&nbsp;</td>';
		});
		if(c<cols){
			for(; c<cols; c++){
				s+='<td width="32">&nbsp;</td>';
			}
		}
		t.debug(s+'</tr></table>');
	},

	function testComplementary(t){
		//	test the defaults
		var a=dojox.color.Generator.complementary({ base:new dojox.color.Color({r:128, g:0, b:0}) });
		var s='<h3>dojox.color.Generator.complementary</h3><table cellpadding="0" cellspacing="1" border="0"><tr>';
		var cols=2, c=0;
		dojo.forEach(a, function(item){
			if(c++%cols==0){ s+="</tr><tr>"; }
			s+='<td width="32" bgcolor="'+item.toHex()+'">&nbsp;</td>';
		});
		if(c<cols){
			for(; c<cols; c++){
				s+='<td width="32">&nbsp;</td>';
			}
		}
		t.debug(s+'</tr></table>');
	},

	function testSplitComplementary(t){
		//	test the defaults
		var a=dojox.color.Generator.splitComplementary({ base:new dojox.color.Color({r:128, g:0, b:0}) });
		var s='<h3>dojox.color.Generator.splitComplementary</h3><table cellpadding="0" cellspacing="1" border="0"><tr>';
		var cols=3, c=0;
		dojo.forEach(a, function(item){
			if(c++%cols==0){ s+="</tr><tr>"; }
			s+='<td width="32" bgcolor="'+item.toHex()+'">&nbsp;</td>';
		});
		if(c<cols){
			for(; c<cols; c++){
				s+='<td width="32">&nbsp;</td>';
			}
		}
		t.debug(s+'</tr></table>');
	},

	function testCompound(t){
		//	test the defaults
		var a=dojox.color.Generator.compound({ base:new dojox.color.Color({r:128, g:0, b:0}) });
		var s='<h3>dojox.color.Generator.compound</h3><table cellpadding="0" cellspacing="1" border="0"><tr>';
		var cols=4, c=0;
		dojo.forEach(a, function(item){
			if(c++%cols==0){ s+="</tr><tr>"; }
			s+='<td width="32" bgcolor="'+item.toHex()+'">&nbsp;</td>';
		});
		if(c<cols){
			for(; c<cols; c++){
				s+='<td width="32">&nbsp;</td>';
			}
		}
		t.debug(s+'</tr></table>');
	},

	function testShades(t){
		//	test the defaults
		var a=dojox.color.Generator.shades({ base:new dojox.color.Color({r:128, g:0, b:0}) });
		var s='<table cellpadding="0" cellspacing="1" border="0"><tr>';
		var cols=8, c=0;
		dojo.forEach(a, function(item){
			if(c++%cols==0){ s+="</tr><tr>"; }
			s+='<td width="32" bgcolor="'+item.toHex()+'">&nbsp;</td>';
		});
		if(c<cols){
			for(; c<cols; c++){
				s+='<td width="32">&nbsp;</td>';
			}
		}
		t.debug(s+'</tr></table>');
	}
]);

}