forked from paulirish/css3please
-
Notifications
You must be signed in to change notification settings - Fork 0
/
tests.html
306 lines (270 loc) · 14.3 KB
/
tests.html
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
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
<!DOCTYPE HTML>
<html>
<head>
<meta charset="UTF-8" />
<title>Cross-Browser CSS3 Rule Generator</title>
<script src="test_math.js"></script>
<script type="text/javascript">
/* ---- cssMath Firebug tests ---- */
console.log(
'--------------------------------------------------------------------------------\n' +
'General Tests' +
'\n--------------------------------------------------------------------------------'
);
console.log(
'Testing round: function (n, l = 10)', '\n',
'Number rounded by Length', '\n',
'cssMath.round(3.1417534)', 'returns: ', cssMath.round(3.1417534), '\n',
'cssMath.round(3.1417534, 2)', 'returns: ', cssMath.round(3.1417534, 2), '\n'
);
console.log(
'--------------------------------------------------------------------------------\n' +
'Rotation Tests' +
'\n--------------------------------------------------------------------------------'
);
console.log(
'Testing xy2rs: function (x, y)', '\n',
'X and Y coordinates to rotation and strength', '\n',
'cssMath.xy2rs(4, 4)', 'returns: ', cssMath.xy2rs(4, 4), '\n',
'cssMath.xy2rs(10, 15)', 'returns: ', cssMath.xy2rs(10, 15), '\n'
);
console.log(
'Testing rs2xy: function (r, s)', '\n',
'Rotation and Strength to x and y coordinates', '\n',
'cssMath.rs2xy(135, 5.657)', 'returns: ', cssMath.rs2xy(135, 5.657), '\n',
'cssMath.rs2xy(146.31, 18.028)', 'returns: ', cssMath.rs2xy(146.31, 18.028), '\n'
);
console.log(
'Testing r2d: function (r)', '\n',
'Rotation to degree', '\n',
'cssMath.r2d(3)', 'returns: ', cssMath.r2d(3), '\n',
'cssMath.r2d(3.5)', 'returns: ', cssMath.r2d(3.5), '\n'
);
console.log(
'Testing d2r: function (d)', '\n',
'Degree to rotation', '\n',
'cssMath.d2r(270)', 'returns: ', cssMath.d2r(270), '\n',
'cssMath.d2r(315)', 'returns: ', cssMath.d2r(315), '\n'
);
console.log(
'--------------------------------------------------------------------------------\n' +
'Color Tests' +
'\n--------------------------------------------------------------------------------'
);
console.log(
'Testing lh2sh: function (lh)', '\n',
'Long Hexadecimals compressed to short hexadecimals', '\n',
'cssMath.lh2sh(\'FF33FF\')', 'returns: ', cssMath.lh2sh('FF33FF'), '\n',
'cssMath.lh2sh(\'#FF33FF\')', 'returns: ', cssMath.lh2sh('#FF33FF'), '\n',
'cssMath.lh2sh(\'#F3F\')', 'returns: ', cssMath.lh2sh('#F3F'), '\n',
'cssMath.lh2sh(\'#FF33FE\')', 'returns: ', cssMath.lh2sh('#FF33FE'), '\n'
);
console.log(
'Testing sh2lh: function (sh)', '\n',
'Short Hexadecimals expanded to long hexadecimals', '\n',
'cssMath.sh2lh(\'F3F\')', 'returns: ', cssMath.sh2lh('F3F'), '\n',
'cssMath.lh2sh(\'#F3F\')', 'returns: ', cssMath.sh2lh('#F3F'), '\n',
'cssMath.lh2sh(\'#FF33FF\')', 'returns: ', cssMath.sh2lh('#FF33FF'), '\n'
);
console.log(
'Testing c2h: function (c)', '\n',
'Channel to hexadecimal', '\n',
'cssMath.c2h(255)', 'returns: ', cssMath.c2h(255), '\n',
'cssMath.c2h(0)', 'returns: ', cssMath.c2h(0), '\n'
);
console.log(
'Testing h2c: function (c)', '\n',
'Hexadecimal to channel', '\n',
'cssMath.h2c(\'FF\')', 'returns: ', cssMath.h2c('FF'), '\n',
'cssMath.h2c(\'00\')', 'returns: ', cssMath.h2c('00'), '\n'
);
console.log(
'Testing c2a: function (c)', '\n',
'Channels to array', '\n',
'cssMath.c2a(\'255, 0, 255\')', 'returns: ', cssMath.c2a('255, 0, 255'), '\n',
'cssMath.c2a(\'255,0,255\')', 'returns: ', cssMath.c2a('255,0,255'), '\n',
'cssMath.c2a(\'(255,0,255)\')', 'returns: ', cssMath.c2a('(255,0,255)'), '\n',
'cssMath.c2a(\'rgb(255,0,255)\')', 'returns: ', cssMath.c2a('rgb(255,0,255)'), '\n',
'cssMath.c2a(\'rgb ( 255 , 0 , 255 )\')', 'returns: ', cssMath.c2a('rgb ( 255 , 0 , 255 )'), '\n'
);
console.log(
'Testing h2a: function (c)', '\n',
'Hexadecimals to array', '\n',
'cssMath.h2a(\'FF00FF\')', 'returns: ', cssMath.h2a('FF00FF'), '\n',
'cssMath.h2a(\'#FF00FF\')', 'returns: ', cssMath.h2a('#FF00FF'), '\n',
'cssMath.h2a(\'#F0F\')', 'returns: ', cssMath.h2a('#F0F'), '\n',
'cssMath.h2a(\'F0F\')', 'returns: ', cssMath.h2a('F0F'), '\n'
);
console.log(
'Testing c2h2: function (c)', '\n',
'Channels to hexadecimals', '\n',
'cssMath.c2h2(\'255, 0, 255\')', 'returns: ', cssMath.c2h2('255, 0, 255'), '\n',
'cssMath.c2h2(\'255,0,255\')', 'returns: ', cssMath.c2h2('255,0,255'), '\n',
'cssMath.c2h2(\'(255,0,255)\')', 'returns: ', cssMath.c2h2('(255,0,255)'), '\n',
'cssMath.c2h2(\'rgb(255,0,255)\')', 'returns: ', cssMath.c2h2('rgb(255,0,255)'), '\n',
'cssMath.c2h2(\'rgb ( 255 , 0 , 255 )\')', 'returns: ', cssMath.c2h2('rgb ( 255 , 0 , 255 )'), '\n'
);
console.log(
'Testing h2c2: function (h)', '\n',
'Hexadecimals to channels', '\n',
'cssMath.h2c2(\'FF00FF\')', 'returns: ', cssMath.h2c2('FF00FF'), '\n',
'cssMath.h2c2(\'#FF00FF\')', 'returns: ', cssMath.h2c2('#FF00FF'), '\n',
'cssMath.h2c2(\'#F0F\')', 'returns: ', cssMath.h2c2('#F0F'), '\n',
'cssMath.h2c2(\'F0F\')', 'returns: ', cssMath.h2c2('F0F'), '\n'
);
console.log(
'Testing cf: function (c)', '\n',
'Channels proper formatting', '\n',
'cssMath.cf(\'255, 0, 255\')', 'returns: ', cssMath.cf('255, 0, 255'), '\n',
'cssMath.cf(\'255,0,255\')', 'returns: ', cssMath.cf('255,0,255'), '\n',
'cssMath.cf(\'(255,0,255)\')', 'returns: ', cssMath.cf('(255,0,255)'), '\n',
'cssMath.cf(\'rgb(255,0,255)\')', 'returns: ', cssMath.cf('rgb(255,0,255)'), '\n',
'cssMath.cf(\'rgb ( 255 , 0 , 255 )\')', 'returns: ', cssMath.cf('rgb ( 255 , 0 , 255 )'), '\n',
'cssMath.cf(\'255, 0, 255, 204\')', 'returns: ', cssMath.cf('255, 0, 255, 204'), '\n',
'cssMath.cf(\'255,0,255,204\')', 'returns: ', cssMath.cf('255,0,255,204'), '\n',
'cssMath.cf(\'(255,0,255,204)\')', 'returns: ', cssMath.cf('(255,0,255,204)'), '\n',
'cssMath.cf(\'rgb(255,0,255,204)\')', 'returns: ', cssMath.cf('rgb(255,0,255,204)'), '\n',
'cssMath.cf(\'rgb ( 255 , 0 , 255 , 204)\')', 'returns: ', cssMath.cf('rgb ( 255 , 0 , 255 , 204)'), '\n'
);
console.log(
'Testing hf: function (h)', '\n',
'Hexadecimals proper formatting', '\n',
'cssMath.hf(\'FF00FF\')', 'returns: ', cssMath.hf('FF00FF'), '\n',
'cssMath.hf(\'#FF00FF\')', 'returns: ', cssMath.hf('#FF00FF'), '\n',
'cssMath.hf(\'#F0F\')', 'returns: ', cssMath.hf('#F0F'), '\n',
'cssMath.hf(\'F0F\')', 'returns: ', cssMath.hf('F0F'), '\n',
'cssMath.hf(\'CCFF00FF\')', 'returns: ', cssMath.hf('CCFF00FF'), '\n',
'cssMath.hf(\'CF0F\')', 'returns: ', cssMath.hf('CF0F'), '\n'
);
console.log(
'Testing cm: function (c, m)', '\n',
'Channel Move', '\n',
'cssMath.cm(254, 1)', 'returns: ', cssMath.cm(254, 1), '\n',
'cssMath.cm(253, 2)', 'returns: ', cssMath.cm(253, 2), '\n',
'cssMath.cm(255, -51)', 'returns: ', cssMath.cm(255, -51), '\n'
);
console.log(
'Testing hm: function (h, m)', '\n',
'Hexadecimal Move', '\n',
'cssMath.hm(\'FE\', 1)', 'returns: ', cssMath.hm('FE', 1), '\n',
'cssMath.hm(\'FD\', 2)', 'returns: ', cssMath.hm('FD', 2), '\n',
'cssMath.hm(\'FF\', -51)', 'returns: ', cssMath.hm('FF', -51), '\n'
);
console.log(
'Testing cm2: function (c, m)', '\n',
'Channels Move', '\n',
'cssMath.cm2(\'254, 254, 254\', 1)', 'returns: ', cssMath.cm2('254, 254, 254', 1), '\n',
'cssMath.cm2(\'253, 253, 253\', 2)', 'returns: ', cssMath.cm2('253, 253, 253', 2), '\n',
'cssMath.cm2(\'255, 255, 255\', -51)', 'returns: ', cssMath.cm2('255, 255, 255', -51), '\n'
);
console.log(
'Testing hm2: function (h, m)', '\n',
'Hexadecimals Move', '\n',
'cssMath.hm2(\'FEFEFE\', 1)', 'returns: ', cssMath.hm2('FEFEFE', 1), '\n',
'cssMath.hm2(\'FDFDFD\', 2)', 'returns: ', cssMath.hm2('FDFDFD', 2), '\n',
'cssMath.hm2(\'FFFFFF\', -51)', 'returns: ', cssMath.hm2('FFFFFF', -51), '\n'
);
console.log(
'--------------------------------------------------------------------------------\n' +
'String Tests' +
'\n--------------------------------------------------------------------------------'
);
console.log(
'Testing s2sh: function (s)', '\n',
'String to short hexadecimal', '\n',
'cssMath.s2sh(\'255, 238, 255\')', 'returns: ', cssMath.s2sh('255, 238, 255'), '\n',
'cssMath.s2sh(\'rgb(255, 238, 255)\')', 'returns: ', cssMath.s2sh('rgb(255, 238, 255)'), '\n',
'cssMath.s2sh(\'rgba(255, 238, 255, 255)\')', 'returns: ', cssMath.s2sh('rgba(255, 238, 255, 255)'), '\n',
'cssMath.s2sh(\'rgb(255, 238, 255, 255)\')', 'returns: ', cssMath.s2sh('rgb(255, 238, 255, 255)'), '\n',
'cssMath.s2sh(\'rgba(255, 238, 255)\')', 'returns: ', cssMath.s2sh('rgba(255, 238, 255)'), '\n',
'cssMath.s2sh(\'F3F\')', 'returns: ', cssMath.s2sh('F3F'), '\n',
'cssMath.s2sh(\'FF33FF\')', 'returns: ', cssMath.s2sh('FF33FF'), '\n',
'cssMath.s2sh(\'FF3F\')', 'returns: ', cssMath.s2sh('FF3F'), '\n',
'cssMath.s2sh(\'FFFF33FF\')', 'returns: ', cssMath.s2sh('FFFF33FF'), '\n',
'cssMath.s2sh(\'#F3F\')', 'returns: ', cssMath.s2sh('#F3F'), '\n',
'cssMath.s2sh(\'#FF33FF\')', 'returns: ', cssMath.s2sh('#FF33FF'), '\n',
'cssMath.s2sh(\'#FF3F\')', 'returns: ', cssMath.s2sh('#FF3F'), '\n',
'cssMath.s2sh(\'#FFFF33FF\')', 'returns: ', cssMath.s2sh('#FFFF33FF'), '\n'
);
console.log(
'Testing s2lh: function (s)', '\n',
'String to long hexadecimal', '\n',
'cssMath.s2lh(\'255, 238, 255\')', 'returns: ', cssMath.s2lh('255, 238, 255'), '\n',
'cssMath.s2lh(\'rgb(255, 238, 255)\')', 'returns: ', cssMath.s2lh('rgb(255, 238, 255)'), '\n',
'cssMath.s2lh(\'rgba(255, 238, 255, 255)\')', 'returns: ', cssMath.s2lh('rgba(255, 238, 255, 255)'), '\n',
'cssMath.s2lh(\'rgb(255, 238, 255, 255)\')', 'returns: ', cssMath.s2lh('rgb(255, 238, 255, 255)'), '\n',
'cssMath.s2lh(\'rgba(255, 238, 255)\')', 'returns: ', cssMath.s2lh('rgba(255, 238, 255)'), '\n',
'cssMath.s2lh(\'F3F\')', 'returns: ', cssMath.s2lh('F3F'), '\n',
'cssMath.s2lh(\'FF33FF\')', 'returns: ', cssMath.s2lh('FF33FF'), '\n',
'cssMath.s2lh(\'FF3F\')', 'returns: ', cssMath.s2lh('FF3F'), '\n',
'cssMath.s2lh(\'FFFF33FF\')', 'returns: ', cssMath.s2lh('FFFF33FF'), '\n',
'cssMath.s2lh(\'#F3F\')', 'returns: ', cssMath.s2lh('#F3F'), '\n',
'cssMath.s2lh(\'#FF33FF\')', 'returns: ', cssMath.s2lh('#FF33FF'), '\n',
'cssMath.s2lh(\'#FF3F\')', 'returns: ', cssMath.s2lh('#FF3F'), '\n',
'cssMath.s2lh(\'#FFFF33FF\')', 'returns: ', cssMath.s2lh('#FFFF33FF'), '\n'
);
console.log(
'Testing s2c: function (s)', '\n',
'String to channels', '\n',
'cssMath.s2c(\'255, 238, 255\')', 'returns: ', cssMath.s2c('255, 238, 255'), '\n',
'cssMath.s2c(\'rgb(255, 238, 255)\')', 'returns: ', cssMath.s2c('rgb(255, 238, 255)'), '\n',
'cssMath.s2c(\'rgba(255, 238, 255, 255)\')', 'returns: ', cssMath.s2c('rgba(255, 238, 255, 255)'), '\n',
'cssMath.s2c(\'rgb(255, 238, 255, 255)\')', 'returns: ', cssMath.s2c('rgb(255, 238, 255, 255)'), '\n',
'cssMath.s2c(\'rgba(255, 238, 255)\')', 'returns: ', cssMath.s2c('rgba(255, 238, 255)'), '\n',
'cssMath.s2c(\'F3F\')', 'returns: ', cssMath.s2c('F3F'), '\n',
'cssMath.s2c(\'FF33FF\')', 'returns: ', cssMath.s2c('FF33FF'), '\n',
'cssMath.s2c(\'FF3F\')', 'returns: ', cssMath.s2c('FF3F'), '\n',
'cssMath.s2c(\'FFFF33FF\')', 'returns: ', cssMath.s2c('FFFF33FF'), '\n',
'cssMath.s2c(\'#F3F\')', 'returns: ', cssMath.s2c('#F3F'), '\n',
'cssMath.s2c(\'#FF33FF\')', 'returns: ', cssMath.s2c('#FF33FF'), '\n',
'cssMath.s2c(\'#FF3F\')', 'returns: ', cssMath.s2c('#FF3F'), '\n',
'cssMath.s2c(\'#FFFF33FF\')', 'returns: ', cssMath.s2c('#FFFF33FF'), '\n'
);
console.log(
'Testing s2x: function (s, m)', '\n',
'String of channels, hexadecimals, or units to string and moved', '\n',
'cssMath.s2x(\'255, 238, 255\', 17)', 'returns: ', cssMath.s2x('255, 238, 255', 17), '\n',
'cssMath.s2x(\'rgb(255, 238, 255)\', 17)', 'returns: ', cssMath.s2x('rgb(255, 238, 255)', 17), '\n',
'cssMath.s2x(\'rgba(255, 238, 255, 255)\', 17)', 'returns: ', cssMath.s2x('rgba(255, 238, 255, 255)', 17), '\n',
'cssMath.s2x(\'rgb(255, 238, 255, 255)\', 17)', 'returns: ', cssMath.s2x('rgb(255, 238, 255, 255)', 17), '\n',
'cssMath.s2x(\'rgba(255, 238, 255)\', 17)', 'returns: ', cssMath.s2x('rgba(255, 238, 255)', 17), '\n',
'cssMath.s2x(\'FEF\', 17)', 'returns: ', cssMath.s2x('FEF', 17), '\n',
'cssMath.s2x(\'FFEEFF\', 17)', 'returns: ', cssMath.s2x('FFEEFF', 17), '\n',
'cssMath.s2x(\'FFEF\', 17)', 'returns: ', cssMath.s2x('FFEF', 17), '\n',
'cssMath.s2x(\'FFFFEEFF\', 17)', 'returns: ', cssMath.s2x('FFFFEEFF', 17), '\n',
'cssMath.s2x(\'#FEF\', 17)', 'returns: ', cssMath.s2x('#FEF', 17), '\n',
'cssMath.s2x(\'#FFEEFF\', 17)', 'returns: ', cssMath.s2x('#FFEEFF', 17), '\n',
'cssMath.s2x(\'#FFEF\', 17)', 'returns: ', cssMath.s2x('#FFEF', 17), '\n',
'cssMath.s2x(\'#FFFFEEFF\', 17)', 'returns: ', cssMath.s2x('#FFFFEEFF', 17), '\n',
'cssMath.s2x(\'1px\', 9)', 'returns: ', cssMath.s2x('1px', 9), '\n',
'cssMath.s2x(\'1em\', 9)', 'returns: ', cssMath.s2x('1em', 9), '\n',
'cssMath.s2x(\'1%\', 9)', 'returns: ', cssMath.s2x('1%', 9), '\n',
'cssMath.s2x(\'1px 1px 11px 1px\', 9)', 'returns: ', cssMath.s2x('1px 1px 11px 1px', 9), '\n',
'cssMath.s2x(\'5px 0 10px 15px\', 5)', 'returns: ', cssMath.s2x('5px 0 10px 15px', 5), '\n'
);
console.log(
'Testing s2sx: function (s, m)', '\n',
'String of channels, hexadecimals, or units to short string and moved', '\n',
'cssMath.s2sx(\'255, 238, 255\', 17)', 'returns: ', cssMath.s2sx('255, 238, 255', 17), '\n',
'cssMath.s2sx(\'rgb(255, 238, 255)\', 17)', 'returns: ', cssMath.s2sx('rgb(255, 238, 255)', 17), '\n',
'cssMath.s2sx(\'rgba(255, 238, 255, 255)\', 17)', 'returns: ', cssMath.s2sx('rgba(255, 238, 255, 255)', 17), '\n',
'cssMath.s2sx(\'rgb(255, 238, 255, 255)\', 17)', 'returns: ', cssMath.s2sx('rgb(255, 238, 255, 255)', 17), '\n',
'cssMath.s2sx(\'rgba(255, 238, 255)\', 17)', 'returns: ', cssMath.s2sx('rgba(255, 238, 255)', 17), '\n',
'cssMath.s2sx(\'FEF\', 17)', 'returns: ', cssMath.s2sx('FEF', 17), '\n',
'cssMath.s2sx(\'FFEEFF\', 17)', 'returns: ', cssMath.s2sx('FFEEFF', 17), '\n',
'cssMath.s2sx(\'FFEF\', 17)', 'returns: ', cssMath.s2sx('FFEF', 17), '\n',
'cssMath.s2sx(\'FFFFEEFF\', 17)', 'returns: ', cssMath.s2sx('FFFFEEFF', 17), '\n',
'cssMath.s2sx(\'#FEF\', 17)', 'returns: ', cssMath.s2sx('#FEF', 17), '\n',
'cssMath.s2sx(\'#FFEEFF\', 17)', 'returns: ', cssMath.s2sx('#FFEEFF', 17), '\n',
'cssMath.s2sx(\'#FFEF\', 17)', 'returns: ', cssMath.s2sx('#FFEF', 17), '\n',
'cssMath.s2sx(\'#FFFFEEFF\', 17)', 'returns: ', cssMath.s2sx('#FFFFEEFF', 17), '\n',
'cssMath.s2sx(\'1px\', 9)', 'returns: ', cssMath.s2sx('1px', 9), '\n',
'cssMath.s2sx(\'1em\', 9)', 'returns: ', cssMath.s2sx('1em', 9), '\n',
'cssMath.s2sx(\'1%\', 9)', 'returns: ', cssMath.s2sx('1%', 9), '\n',
'cssMath.s2sx(\'1px 1px 11px 1px\', 9)', 'returns: ', cssMath.s2sx('1px 1px 11px 1px', 9), '\n',
'cssMath.s2sx(\'5px 0 10px 15px\', 5)', 'returns: ', cssMath.s2sx('5px 0 10px 15px', 5), '\n'
);
</script>
</head>
<body></body>
</html>