blob: c4a465d019398cd1454a0ccef74978b9bca525f6 [file] [log] [blame]
caryclark@google.com752b60e2012-03-22 21:11:17 +00001<html>
2<head>
3<div style="height:0">
caryclark@google.comfa0588f2012-04-26 21:01:06 +00004
5<div id="testSimplifyQuadratic1">
6 SkPath path, out;
7 path.moveTo(0, 0);
8 path.quadTo(1, 0, 1, 1);
9 path.close();
10 path.moveTo(1, 0);
11 path.quadTo(0, 0, 0, 1);
12 path.close();
13 testSimplify(path, true, out, bitmap);
14}
caryclark@google.com752b60e2012-03-22 21:11:17 +000015</div>
caryclark@google.comfa0588f2012-04-26 21:01:06 +000016
17<div id="testSimplifyQuadratic2">
18 SkPath path, out;
19 path.moveTo(0, 0);
20 path.quadTo(20, 0, 20, 20);
21 path.close();
22 path.moveTo(20, 0);
23 path.quadTo(0, 0, 0, 20);
24 path.close();
25 testSimplify(path, true, out, bitmap);
26}
caryclark@google.comd88e0892012-03-27 13:23:51 +000027</div>
caryclark@google.comfa0588f2012-04-26 21:01:06 +000028
29<div id="testSimplifyQuadratic3">
30 SkPath path, out;
31 path.moveTo(0, 0);
32 path.quadTo(20, 0, 20, 20);
33 path.close();
34 path.moveTo(0, 20);
35 path.quadTo(0, 0, 20, 0);
36 path.close();
37 testSimplify(path, true, out, bitmap);
38}
caryclark@google.comd88e0892012-03-27 13:23:51 +000039</div>
caryclark@google.comfa0588f2012-04-26 21:01:06 +000040
41<div id="testSimplifyQuadratic4">
42 SkPath path, out;
43 path.moveTo(0, 20);
44 path.quadTo(20, 0, 40, 20);
45 path.close();
46 path.moveTo(40, 10);
47 path.quadTo(20, 30, 0, 10);
48 path.close();
49 testSimplify(path, true, out, bitmap);
50 drawAsciiPaths(path, out, true);
51}
caryclark@google.comd88e0892012-03-27 13:23:51 +000052</div>
caryclark@google.comfa0588f2012-04-26 21:01:06 +000053
54<div id="testSimplifyQuadratic5">
55 SkPath path, out;
56 path.moveTo(0, 0);
57 path.quadTo(0, 0, 0, 0);
58 path.lineTo(0, 0);
59 path.close();
60 path.moveTo(0, 0);
61 path.lineTo(0, 0);
62 path.quadTo(0, 0, 0, 1);
63 path.close();
64 testSimplify(path, true, out, bitmap);
65 drawAsciiPaths(path, out, true);
66}
caryclark@google.comfb173422012-04-10 18:28:55 +000067</div>
caryclark@google.comfa0588f2012-04-26 21:01:06 +000068
69<div id="testSimplifyQuadratic6">
70 SkPath path, out;
71 path.moveTo(0, 0);
72 path.quadTo(0, 0, 0, 0);
73 path.lineTo(1, 0);
74 path.close();
75 path.moveTo(0, 0);
76 path.lineTo(0, 0);
77 path.quadTo(1, 0, 0, 1);
78 path.close();
79 testSimplify(path, true, out, bitmap);
80 drawAsciiPaths(path, out, true);
81}
caryclark@google.comfb173422012-04-10 18:28:55 +000082</div>
caryclark@google.comfa0588f2012-04-26 21:01:06 +000083
84<div id="testSimplifyQuadratic7">
85 SkPath path, out;
86 path.moveTo(0, 0);
87 path.quadTo(0, 0, 0, 0);
88 path.lineTo(0, 1);
89 path.close();
90 path.moveTo(0, 0);
91 path.lineTo(0, 0);
92 path.quadTo(1, 0, 0, 2);
93 path.close();
94 testSimplify(path, true, out, bitmap);
95 drawAsciiPaths(path, out, true);
96}
97</div>
98
99<div id="testSimplifyQuadratic8">
100 SkPath path, out;
101 path.moveTo(0, 0);
102 path.quadTo(0, 0, 0, 0);
103 path.lineTo(0, 0);
104 path.close();
105 path.moveTo(0, 0);
106 path.lineTo(0, 0);
107 path.quadTo(1, 0, 0, 2);
108 path.close();
109 testSimplify(path, true, out, bitmap);
110 drawAsciiPaths(path, out, true);
111}
112</div>
113
114<div id="testSimplifyQuadratic9">
115 SkPath path, out;
116 path.moveTo(0, 0);
117 path.quadTo(0, 0, 0, 0);
118 path.lineTo(1, 1);
119 path.close();
120 path.moveTo(0, 0);
121 path.lineTo(0, 0);
122 path.quadTo(1, 0, 2, 2);
123 path.close();
124 testSimplify(path, true, out, bitmap);
125 drawAsciiPaths(path, out, true);
126}
127</div>
128
129<div id="testSimplifyQuadratic10">
130 SkPath path, out;
caryclark@google.com78e17132012-04-17 11:40:34 +0000131 path.moveTo(0, 0);
132 path.quadTo(0, 0, 0, 0);
133 path.lineTo(0, 0);
134 path.close();
135 path.moveTo(0, 0);
136 path.lineTo(0, 1);
137 path.quadTo(1, 1, 1, 2);
caryclark@google.com78e17132012-04-17 11:40:34 +0000138 path.close();
caryclark@google.comfa0588f2012-04-26 21:01:06 +0000139 testSimplify(path, true, out, bitmap);
140 drawAsciiPaths(path, out, true);
141}
caryclark@google.com78e17132012-04-17 11:40:34 +0000142</div>
143
caryclark@google.comfa0588f2012-04-26 21:01:06 +0000144<div id="testSimplifyQuadratic11">
145 SkPath path, out;
caryclark@google.com78e17132012-04-17 11:40:34 +0000146 path.moveTo(0, 0);
147 path.quadTo(0, 0, 0, 0);
148 path.lineTo(0, 2);
caryclark@google.com78e17132012-04-17 11:40:34 +0000149 path.close();
150 path.moveTo(0, 0);
151 path.lineTo(2, 1);
152 path.quadTo(2, 2, 3, 3);
caryclark@google.comfa0588f2012-04-26 21:01:06 +0000153 path.close();
154 testSimplify(path, true, out, bitmap);
155 drawAsciiPaths(path, out, true);
156}
157</div>
158
159<div id="testSimplifyQuadratic12">
160 SkPath path, out;
161 path.moveTo(0, 0);
162 path.lineTo(0, 2);
caryclark@google.com78e17132012-04-17 11:40:34 +0000163 path.lineTo(0, 0);
164 path.close();
caryclark@google.comfa0588f2012-04-26 21:01:06 +0000165 path.moveTo(3, 0);
166 path.quadTo(1, 1, 0, 2);
167 path.lineTo(3, 0);
168 path.close();
169 testSimplify(path, true, out, bitmap);
170 drawAsciiPaths(path, out, true);
171}
caryclark@google.com78e17132012-04-17 11:40:34 +0000172</div>
173
caryclark@google.comfa0588f2012-04-26 21:01:06 +0000174<div id="testSimplifyQuadratic13">
175 SkPath path, out;
caryclark@google.com78e17132012-04-17 11:40:34 +0000176path.moveTo(0, 0);
177path.quadTo(0, 0, 1, 0);
178path.lineTo(1, 1);
179path.lineTo(0, 0);
180path.close();
181path.moveTo(0, 0);
182path.quadTo(3, 0, 1, 1);
183path.lineTo(0, 0);
184path.close();
caryclark@google.comfa0588f2012-04-26 21:01:06 +0000185 testSimplify(path, true, out, bitmap);
186 drawAsciiPaths(path, out, true);
187}
caryclark@google.com78e17132012-04-17 11:40:34 +0000188</div>
189
caryclark@google.comfa0588f2012-04-26 21:01:06 +0000190<div id="testSimplifyQuadratic14">
191 SkPath path, out;
caryclark@google.com78e17132012-04-17 11:40:34 +0000192 path.moveTo(0, 0);
193 path.quadTo(0, 0, 0, 0);
194 path.lineTo(1, 1);
caryclark@google.com78e17132012-04-17 11:40:34 +0000195 path.close();
196 path.moveTo(0, 0);
197 path.lineTo(0, 0);
198 path.quadTo(0, 1, 2, 1);
caryclark@google.com78e17132012-04-17 11:40:34 +0000199 path.close();
caryclark@google.comfa0588f2012-04-26 21:01:06 +0000200 testSimplify(path, true, out, bitmap);
201 drawAsciiPaths(path, out, true);
202}
caryclark@google.com78e17132012-04-17 11:40:34 +0000203</div>
204
caryclark@google.comfa0588f2012-04-26 21:01:06 +0000205<div id="testSimplifyQuadratic15">
206 SkPath path, out;
207 path.moveTo(0, 0);
208 path.quadTo(0, 0, 1, 3);
209 path.lineTo(3, 3);
210 path.close();
211 path.moveTo(0, 1);
212 path.lineTo(1, 1);
213 path.quadTo(0, 3, 3, 3);
214 path.close();
215 testSimplify(path, true, out, bitmap);
216 drawAsciiPaths(path, out, true);
217}
218</div>
219
220<div id="testSimplifyQuadratic16">
221 SkPath path, out;
222 path.moveTo(0, 0);
223 path.quadTo(0, 0, 0, 0);
224 path.lineTo(0, 1);
225 path.close();
226 path.moveTo(0, 0);
227 path.lineTo(0, 0);
228 path.quadTo(1, 0, 0, 1);
229 path.close();
230 testSimplify(path, true, out, bitmap);
231 drawAsciiPaths(path, out, true);
232}
233</div>
234
235<div id="testSimplifyQuadratic17">
236 SkPath path, out;
caryclark@google.comb45a1b42012-05-18 20:50:33 +0000237 path.moveTo(8, 8);
238 path.quadTo(10, 10, 8, -10);
caryclark@google.comfa0588f2012-04-26 21:01:06 +0000239 path.close();
caryclark@google.comb45a1b42012-05-18 20:50:33 +0000240 path.moveTo(8, 8);
241 path.quadTo(12, 12, 14, 4);
242 path.close();
243 path.moveTo(8, 8);
244 path.quadTo(9, 9, 10, 8);
caryclark@google.comfa0588f2012-04-26 21:01:06 +0000245 path.close();
246 testSimplify(path, true, out, bitmap);
247 drawAsciiPaths(path, out, true);
248}
caryclark@google.com78e17132012-04-17 11:40:34 +0000249</div>
caryclark@google.comfb173422012-04-10 18:28:55 +0000250
caryclark@google.comb45a1b42012-05-18 20:50:33 +0000251<div id="testSimplifyQuadratic18">
252 SkPath path, out;
253 path.moveTo(8.0000000000000071, 8.0000000000000071);
254 path.quadTo(8.7289570079366854, 8.7289570079366889, 9.3914917259458743, 9.0593802763083691);
255 path.close();
256 path.moveTo(8.0000000000000142, 8.0000000000000142);
257 path.quadTo(8.1250000000000107, 8.1250000000000071, 8.2500000000000071, 8.2187500000000053);
258 path.close();
259 testSimplify(path, true, out, bitmap);
260 drawAsciiPaths(path, out, true);
261</div>
caryclark@google.com8dcf1142012-07-02 20:27:02 +0000262
263<div id="testSimplifyQuadratic19">
264 SkPath path, simple;
265 path.moveTo(0,4);
266 path.lineTo(6,4);
267 path.lineTo(3,1);
268 path.close();
269 path.moveTo(2,3);
270 path.lineTo(3,2);
271 path.lineTo(4,3);
272 path.close();
273 testSimplifyx(path);
274</div>
275
276<div id="testSimplifyQuadratic20">
277 SkPath path, simple;
278 path.moveTo(0,4);
279 path.lineTo(6,4);
280 path.lineTo(3,1);
281 path.close();
282 path.moveTo(2,3);
283 path.lineTo(4,3);
284 path.lineTo(3,2);
285 path.close();
286 testSimplifyx(path);
287</div>
288
289<div id="testSimplifyQuadratic21">
290 SkPath path, simple;
291 path.moveTo(0,4);
292 path.lineTo(8,4);
293 path.lineTo(4,0);
294 path.close();
295 path.moveTo(2,2);
296 path.lineTo(3,3);
297 path.lineTo(4,2);
298 path.close();
299 testSimplifyx(path);
300</div>
301
302<div id="testLine6">
303 SkPath path, simple;
304 path.moveTo(0,0);
305 path.lineTo(4,0);
306 path.lineTo(2,2);
307 path.close();
308 path.moveTo(2,0);
309 path.lineTo(6,0);
310 path.lineTo(4,2);
311 path.close();
312 testSimplifyx(path);
313</div>
314
caryclark@google.comfa4a6e92012-07-11 17:52:32 +0000315<div id="testLine7">
316 SkPath path, simple;
317 path.moveTo(0,0);
318 path.lineTo(4,0);
319 path.lineTo(2,2);
320 path.close();
321 path.moveTo(6,0);
322 path.lineTo(2,0);
323 path.lineTo(4,2);
324 path.close();
325 testSimplifyx(path);
326</div>
327
caryclark@google.comcc905052012-07-25 20:59:42 +0000328<div id="testLine7b">
329 path.moveTo(0,0);
330 path.lineTo(4,0);
331 path.close();
332 path.moveTo(6,0);
333 path.lineTo(2,0);
334 path.lineTo(4,2);
335 path.close();
336</div>
337
caryclark@google.comfa4a6e92012-07-11 17:52:32 +0000338<div id="testLine9">
339 SkPath path, simple;
340 path.moveTo(0,4);
341 path.lineTo(4,4);
342 path.lineTo(2,2);
343 path.close();
344 path.moveTo(6,4);
345 path.lineTo(2,4);
346 path.lineTo(4,2);
347 path.close();
348 testSimplifyx(path);
349</div>
350
caryclark@google.come21cb182012-07-23 21:26:31 +0000351<div id="testLine12">
352 path.moveTo(0,4);
353 path.lineTo(6,4);
354 path.lineTo(3,1);
355 path.close();
356 path.moveTo(2,3);
357 path.lineTo(3,2);
358 path.lineTo(4,3);
359 path.close();
360</div>
361
362<div id="testLine13">
363 path.moveTo(6,4);
364 path.lineTo(0,4);
365 path.lineTo(3,1);
366 path.close();
367 path.moveTo(3,2);
368 path.lineTo(2,3);
369 path.lineTo(4,3);
370 path.close();
371</div>
372
caryclark@google.com8dcf1142012-07-02 20:27:02 +0000373<div id="testLine17">
374 SkPath path, simple;
375 path.addRect(0, 0, 12, 12, (SkPath::Direction) 0);
376 path.addRect(4, 12, 13, 13, (SkPath::Direction) 0);
377 testSimplifyx(path);
378</div>
379
caryclark@google.com47580692012-07-23 12:14:49 +0000380<div id="testLine19">
381 SkPath path, simple;
382 path.addRect(0, 0, 12, 12, (SkPath::Direction) 0);
383 path.addRect(12, 16, 21, 21, (SkPath::Direction) 0);
384 testSimplifyx(path);
385</div>
386
caryclark@google.comcc905052012-07-25 20:59:42 +0000387<div id="testLine22">
388 path.addRect(0, 12, 12, 12, (SkPath::Direction) 0);
389 path.addRect(4, 12, 13, 13, (SkPath::Direction) 0);
390</div>
391
caryclark@google.com47580692012-07-23 12:14:49 +0000392<div id="testLine24">
393 path.addRect(0, 18, 12, 12, (SkPath::Direction) 0);
394 path.addRect(4, 12, 13, 13, (SkPath::Direction) 0);
395</div>
396
caryclark@google.comfa4a6e92012-07-11 17:52:32 +0000397<div id="testLine28">
398 SkPath path, simple;
399 path.addRect(0, 6, 12, 12, (SkPath::Direction) 0);
400 path.addRect(0, 0, 9, 9, (SkPath::Direction) 0);
401 testSimplifyx(path);
402</div>
403
404<div id="testLine29">
405 SkPath path, simple;
406 path.addRect(0, 18, 12, 12, (SkPath::Direction) 0);
407 path.addRect(12, 12, 21, 21, (SkPath::Direction) 0);
408 testSimplifyx(path);
409</div>
410
411<div id="testLine30">
412 path.addRect(0, 0, 20, 20, (SkPath::Direction) 0);
413 path.addRect(0, 0, 12, 12, (SkPath::Direction) 0);
414 path.addRect(4, 4, 13, 13, (SkPath::Direction) 0);
415</div>
416
417<div id="testLine31">
418 path.addRect(0, 0, 20, 20, (SkPath::Direction) 0);
419 path.addRect(0, 0, 12, 12, (SkPath::Direction) 0);
420 path.addRect(0, 4, 9, 9, (SkPath::Direction) 0);
421</div>
422
423<div id="testLine32">
424 path.addRect(0, 0, 20, 20, (SkPath::Direction) 0);
425 path.addRect(0, 0, 12, 12, (SkPath::Direction) 0);
426 path.addRect(4, 12, 13, 13, (SkPath::Direction) 0);
427</div>
428
caryclark@google.com9764cc62012-07-12 19:29:45 +0000429<div id="testLine33">
430 path.addRect(0, 0, 20, 20, (SkPath::Direction) 0);
431 path.addRect(0, 0, 12, 12, (SkPath::Direction) 0);
432 path.addRect(4, 16, 13, 13, (SkPath::Direction) 0);
433</div>
434
caryclark@google.com210acaf2012-07-12 21:05:13 +0000435<div id="testLine34">
436 path.addRect(0, 0, 20, 20, (SkPath::Direction) 0);
437 path.addRect(0, 6, 12, 12, (SkPath::Direction) 0);
438 path.addRect(4, 12, 13, 13, (SkPath::Direction) 0);
439</div>
440
441<div id="testLine35">
442 path.addRect(0, 0, 20, 20, (SkPath::Direction) 0);
443 path.addRect(6, 0, 18, 18, (SkPath::Direction) 0);
444 path.addRect(4, 16, 13, 13, (SkPath::Direction) 0);
445</div>
446
caryclark@google.com0e08a192012-07-13 21:07:52 +0000447<div id="testLine36">
448 path.addRect(0, 10, 20, 20, (SkPath::Direction) 0);
449 path.addRect(6, 12, 18, 18, (SkPath::Direction) 0);
450 path.addRect(4, 16, 13, 13, (SkPath::Direction) 0);
451</div>
452
caryclark@google.com47580692012-07-23 12:14:49 +0000453<div id="testLine37">
454 path.addRect(0, 20, 20, 20, (SkPath::Direction) 0);
455 path.addRect(18, 24, 30, 30, (SkPath::Direction) 0);
456 path.addRect(0, 0, 9, 9, (SkPath::Direction) 0);
457</div>
458
459<div id="testLine38">
460 path.addRect(10, 0, 30, 30, (SkPath::Direction) 0);
461 path.addRect(6, 12, 18, 18, (SkPath::Direction) 0);
462 path.addRect(12, 12, 21, 21, (SkPath::Direction) 0);
463</div>
464
465<div id="testLine39">
466 path.addRect(10, 0, 30, 30, (SkPath::Direction) 0);
467 path.addRect(12, 6, 24, 24, (SkPath::Direction) 0);
468 path.addRect(12, 4, 21, 21, (SkPath::Direction) 0);
469</div>
470
471<div id="testLine40">
472 path.addRect(10, 0, 30, 30, (SkPath::Direction) 0);
473 path.addRect(12, 18, 24, 24, (SkPath::Direction) 0);
474 path.addRect(4, 16, 13, 13, (SkPath::Direction) 0);
475</div>
476
477<div id="testLine41">
478 path.addRect(0, 0, 20, 20, (SkPath::Direction) 0);
479 path.addRect(18, 24, 30, 30, (SkPath::Direction) 0);
480 path.addRect(12, 0, 21, 21, (SkPath::Direction) 0);
481</div>
482
483<div id="testLine42">
484 path.addRect(0, 0, 20, 20, (SkPath::Direction) 0);
485 path.addRect(0, 0, 12, 12, (SkPath::Direction) 0);
486 path.addRect(8, 16, 17, 17, (SkPath::Direction) 0);
487</div>
488
489<div id="testLine43">
490 path.addRect(0, 0, 20, 20, (SkPath::Direction) 0);
491 path.addRect(6, 24, 18, 18, (SkPath::Direction) 0);
492 path.addRect(0, 32, 9, 36, (SkPath::Direction) 1);
493</div>
494
495<div id="testLine44">
496 path.addRect(10, 40, 30, 30, (SkPath::Direction) 0);
497 path.addRect(18, 0, 30, 30, (SkPath::Direction) 0);
498 path.addRect(18, 32, 27, 36, (SkPath::Direction) 1);
499</div>
500
501<div id="testLine45">
502 path.addRect(10, 0, 30, 30, (SkPath::Direction) 0);
503 path.addRect(18, 0, 30, 30, (SkPath::Direction) 0);
504 path.addRect(24, 32, 33, 36, (SkPath::Direction) 0);
505</div>
506
507<div id="testLine46">
508 path.addRect(10, 40, 30, 30, (SkPath::Direction) 0);
509 path.addRect(24, 0, 36, 36, (SkPath::Direction) 0);
510 path.addRect(24, 32, 33, 36, (SkPath::Direction) 0);
511</div>
512
513<div id="testLine47">
514 path.addRect(0, 0, 20, 20, (SkPath::Direction) 0);
515 path.addRect(0, 0, 12, 12, (SkPath::Direction) 0);
516 path.addRect(0, 0, 9, 9, (SkPath::Direction) 1);
517</div>
518
519<div id="testLine48">
520 path.addRect(0, 0, 20, 20, (SkPath::Direction) 0);
521 path.addRect(0, 6, 12, 12, (SkPath::Direction) 0);
522 path.addRect(0, 0, 9, 9, (SkPath::Direction) 1);
523</div>
524
525<div id="testLine49">
526 path.addRect(0, 0, 20, 20, (SkPath::Direction) 0);
527 path.addRect(0, 0, 12, 12, (SkPath::Direction) 0);
528 path.addRect(0, 0, 9, 9, (SkPath::Direction) 0);
529</div>
530
531<div id="testLine50">
532 path.addRect(10, 30, 30, 30, (SkPath::Direction) 0);
533 path.addRect(24, 20, 36, 30, (SkPath::Direction) 0);
534</div>
535
536<div id="testLine51">
537 path.addRect(0, 0, 20, 20, (SkPath::Direction) 0);
538 path.addRect(0, 12, 12, 12, (SkPath::Direction) 0);
539 path.addRect(4, 12, 13, 13, (SkPath::Direction) 1);
540</div>
541
caryclark@google.come21cb182012-07-23 21:26:31 +0000542<div id="testLine52">
543 path.addRect(0, 30, 20, 20, (SkPath::Direction) 0);
544 path.addRect(6, 20, 18, 30, (SkPath::Direction) 0);
545 path.addRect(32, 0, 36, 41, (SkPath::Direction) 0);
546</div>
547
548<div id="testLine53">
549 path.addRect(10, 30, 30, 30, (SkPath::Direction) 0);
550 path.addRect(12, 20, 24, 30, (SkPath::Direction) 0);
551 path.addRect(12, 32, 21, 36, (SkPath::Direction) 1);
552</div>
553
554<div id="testLine54">
555 path.addRect(0, 0, 20, 20, (SkPath::Direction) 0);
556 path.addRect(6, 0, 18, 18, (SkPath::Direction) 0);
557 path.addRect(8, 4, 17, 17, (SkPath::Direction) 1);
558</div>
559
560<div id="testLine55">
561 path.addRect(0, 0, 20, 20, (SkPath::Direction) 0);
562 path.addRect(6, 6, 18, 18, (SkPath::Direction) 0);
563 path.addRect(4, 4, 13, 13, (SkPath::Direction) 1);
564</div>
565
caryclark@google.com18063442012-07-25 12:05:18 +0000566<div id="testLine56">
567 path.addRect(0, 20, 20, 20, (SkPath::Direction) 0);
568 path.addRect(18, 20, 30, 30, (SkPath::Direction) 0);
569 path.addRect(12, 0, 21, 21, (SkPath::Direction) 1);
570</div>
571
572<div id="testLine57">
573 path.addRect(20, 0, 40, 40, (SkPath::Direction) 0);
574 path.addRect(20, 0, 30, 40, (SkPath::Direction) 0);
575 path.addRect(12, 0, 21, 21, (SkPath::Direction) 1);
576</div>
577
caryclark@google.comcc905052012-07-25 20:59:42 +0000578<div id="testLine58">
579 path.addRect(0, 0, 20, 20, (SkPath::Direction) 0);
580 path.addRect(0, 0, 12, 12, (SkPath::Direction) 1);
581 path.addRect(0, 12, 9, 9, (SkPath::Direction) 1);
582</div>
583
584<div id="testLine59">
585 path.addRect(0, 0, 20, 20, (SkPath::Direction) 0);
586 path.addRect(6, 6, 18, 18, (SkPath::Direction) 1);
587 path.addRect(4, 4, 13, 13, (SkPath::Direction) 1);
588</div>
589
caryclark@google.com27c449a2012-07-27 18:26:38 +0000590<div id="testLine60">
591 path.addRect(0, 0, 20, 20, (SkPath::Direction) 0);
592 path.addRect(6, 12, 18, 18, (SkPath::Direction) 1);
593 path.addRect(4, 12, 13, 13, (SkPath::Direction) 1);
594</div>
595
596<div id="testLine61">
597 path.addRect(0, 0, 20, 20, (SkPath::Direction) 0);
598 path.addRect(12, 0, 24, 24, (SkPath::Direction) 1);
599 path.addRect(12, 0, 21, 21, (SkPath::Direction) 1);
600</div>
601
602<div id="testLine62">
603 path.addRect(0, 0, 60, 60, (SkPath::Direction) 0);
604 path.addRect(0, 0, 20, 20, (SkPath::Direction) 0);
605 path.addRect(0, 12, 12, 12, (SkPath::Direction) 0);
606 path.addRect(4, 12, 13, 13, (SkPath::Direction) 1);
607</div>
608
609<div id="testLine63">
610 path.addRect(0, 0, 60, 60, (SkPath::Direction) 0);
611 path.addRect(0, 10, 20, 20, (SkPath::Direction) 0);
612 path.addRect(0, 6, 12, 12, (SkPath::Direction) 1);
613 path.addRect(0, 32, 9, 36, (SkPath::Direction) 1);
614</div>
615
616<div id="testLine64">
617 path.addRect(0, 0, 60, 60, (SkPath::Direction) 0);
618 path.addRect(10, 40, 30, 30, (SkPath::Direction) 0);
619 path.addRect(18, 6, 30, 30, (SkPath::Direction) 0);
620</div>
621
622<div id="testLine65">
623 path.addRect(0, 0, 60, 60, (SkPath::Direction) 0);
624 path.addRect(10, 0, 30, 30, (SkPath::Direction) 0);
625 path.addRect(24, 0, 36, 36, (SkPath::Direction) 0);
626 path.addRect(32, 6, 36, 41, (SkPath::Direction) 1);
627</div>
628
629<div id="testLine66">
630 path.addRect(0, 0, 60, 60, (SkPath::Direction) 0);
631 path.addRect(0, 30, 20, 20, (SkPath::Direction) 0);
632 path.addRect(12, 20, 24, 30, (SkPath::Direction) 0);
633</div>
634
caryclark@google.com534aa5b2012-08-02 20:08:21 +0000635<div id="testLine67">
636 path.addRect(0, 0, 60, 60, (SkPath::Direction) 0);
637 path.addRect(10, 40, 30, 30, (SkPath::Direction) 0);
638 path.addRect(24, 20, 36, 30, (SkPath::Direction) 0);
639 path.addRect(32, 0, 36, 41, (SkPath::Direction) 0);
640</div>
641
642<div id="testLine68a">
643 path.addRect(0, 0, 8, 8, (SkPath::Direction) 0);
644 path.addRect(2, 2, 6, 6, (SkPath::Direction) 0);
645 path.addRect(1, 2, 4, 2, (SkPath::Direction) 0);
646</div>
647
648<div id="testLine68b">
649 path.addRect(0, 0, 8, 8, (SkPath::Direction) 0);
650 path.addRect(2, 2, 6, 6, (SkPath::Direction) 1);
651 path.addRect(1, 2, 4, 2, (SkPath::Direction) 0);
652</div>
653
654<div id="testLine68c">
655 path.addRect(0, 0, 8, 8, (SkPath::Direction) 1);
656 path.addRect(2, 2, 6, 6, (SkPath::Direction) 0);
657 path.addRect(1, 2, 4, 2, (SkPath::Direction) 0);
658</div>
659
660<div id="testLine68d">
661 path.addRect(0, 0, 8, 8, (SkPath::Direction) 1);
662 path.addRect(2, 2, 6, 6, (SkPath::Direction) 1);
663 path.addRect(1, 2, 4, 2, (SkPath::Direction) 0);
664</div>
665
666<div id="testLine68e">
667 path.addRect(0, 0, 8, 8, (SkPath::Direction) 0);
668 path.addRect(0, 0, 8, 8, (SkPath::Direction) 0);
669 path.addRect(2, 2, 6, 6, (SkPath::Direction) 1);
670 path.addRect(1, 2, 2, 2, (SkPath::Direction) 0);
671</div>
672
673<div id="testLine68f">
674 path.addRect(0, 0, 8, 8, (SkPath::Direction) 0);
675 path.addRect(2, 2, 6, 6, (SkPath::Direction) 1);
676 path.addRect(2, 2, 6, 6, (SkPath::Direction) 1);
677 path.addRect(1, 2, 2, 2, (SkPath::Direction) 0);
678</div>
679
680<div id="testLine69">
681 path.addRect(0, 20, 20, 20, (SkPath::Direction) 0);
682 path.addRect(0, 20, 12, 30, (SkPath::Direction) 0);
683 path.addRect(12, 32, 21, 36, (SkPath::Direction) 0);
684</div>
685
686<div id="testLine70">
687 path.addRect(0, 0, 20, 20, (SkPath::Direction) 0);
688 path.addRect(0, 24, 12, 12, (SkPath::Direction) 0);
689 path.addRect(12, 32, 21, 36, (SkPath::Direction) 1);
690</div>
691
692<div id="testLine71">
693 path.addRect(0, 0, 20, 20, (SkPath::Direction) 0);
694 path.addRect(12, 0, 24, 24, (SkPath::Direction) 0);
695 path.addRect(12, 32, 21, 36, (SkPath::Direction) 0);
696</div>
697
caryclark@google.com200c2112012-08-03 15:05:04 +0000698<div id="testLine72">
699 path.addRect(0, 0, 60, 60, (SkPath::Direction) 0);
700 path.addRect(10, 40, 30, 30, (SkPath::Direction) 0);
701 path.addRect(6, 20, 18, 30, (SkPath::Direction) 0);
702</div>
703
704<div id="testLine73">
705 path.addRect(0, 0, 60, 60, (SkPath::Direction) 0);
706 path.addRect(0, 40, 20, 20, (SkPath::Direction) 0);
707 path.addRect(0, 20, 12, 30, (SkPath::Direction) 0);
708 path.addRect(0, 0, 9, 9, (SkPath::Direction) 1);
709</div>
710
caryclark@google.com0c803d02012-08-06 11:15:47 +0000711<div id="testLine74">
712 path.addRect(20, 30, 40, 40, (SkPath::Direction) 0);
713 path.addRect(24, 20, 36, 30, (SkPath::Direction) 1);
714 path.addRect(32, 24, 36, 41, (SkPath::Direction) 1);
715</div>
716
caryclark@google.com2ddff932012-08-07 21:25:27 +0000717<div id="testLine75">
718 path.addRect(0, 0, 60, 60, (SkPath::Direction) 0);
719 path.addRect(10, 0, 30, 30, (SkPath::Direction) 1);
720 path.addRect(18, 0, 30, 30, (SkPath::Direction) 1);
721 path.addRect(12, 0, 21, 21, (SkPath::Direction) 1);
722</div>
723
724<div id="testLine76">
725 path.addRect(36, 0, 66, 60, (SkPath::Direction) 0);
726 path.addRect(10, 20, 40, 30, (SkPath::Direction) 0);
727 path.addRect(24, 20, 36, 30, (SkPath::Direction) 1);
728 path.addRect(32, 6, 36, 41, (SkPath::Direction) 1);
729</div>
730
731<div id="testLine77">
732 path.addRect(20, 0, 40, 40, (SkPath::Direction) 0);
733 path.addRect(24, 6, 36, 36, (SkPath::Direction) 1);
734 path.addRect(24, 32, 33, 36, (SkPath::Direction) 1);
735</div>
736
737<div id="testLine78">
738 path.addRect(0, 0, 30, 60, (SkPath::Direction) 0);
739 path.addRect(10, 20, 30, 30, (SkPath::Direction) 1);
740 path.addRect(18, 20, 30, 30, (SkPath::Direction) 1);
741 path.addRect(32, 0, 36, 41, (SkPath::Direction) 1);
742</div>
743
744<div id="testLine79">
745 path.addRect(0, 36, 60, 30, (SkPath::Direction) 0);
746 path.addRect(10, 30, 40, 30, (SkPath::Direction) 0);
747 path.addRect(0, 20, 12, 30, (SkPath::Direction) 1);
748 path.addRect(0, 32, 9, 36, (SkPath::Direction) 1);
749</div>
750
caryclark@google.com752b60e2012-03-22 21:11:17 +0000751</div>
752
753<script type="text/javascript">
754
755var testDivs = [
caryclark@google.com2ddff932012-08-07 21:25:27 +0000756 testLine79,
757 testLine78,
758 testLine77,
759 testLine76,
760 testLine75,
caryclark@google.com0c803d02012-08-06 11:15:47 +0000761 testLine74,
caryclark@google.com200c2112012-08-03 15:05:04 +0000762 testLine73,
763 testLine72,
caryclark@google.com534aa5b2012-08-02 20:08:21 +0000764 testLine71,
765 testLine70,
766 testLine69,
767 testLine68f,
768 testLine68e,
769 testLine68d,
770 testLine68c,
771 testLine68b,
772 testLine68a,
773 testLine67,
caryclark@google.com27c449a2012-07-27 18:26:38 +0000774 testLine66,
775 testLine65,
776 testLine64,
777 testLine63,
778 testLine62,
779 testLine61,
780 testLine60,
caryclark@google.comcc905052012-07-25 20:59:42 +0000781 testLine59,
782 testLine58,
caryclark@google.com18063442012-07-25 12:05:18 +0000783 testLine57,
784 testLine56,
caryclark@google.come21cb182012-07-23 21:26:31 +0000785 testLine55,
786 testLine54,
787 testLine53,
788 testLine52,
caryclark@google.com47580692012-07-23 12:14:49 +0000789 testLine51,
790 testLine50,
791 testLine49,
792 testLine48,
793 testLine47,
794 testLine46,
795 testLine45,
796 testLine44,
797 testLine43,
798 testLine42,
799 testLine41,
800 testLine40,
801 testLine39,
802 testLine38,
803 testLine37,
caryclark@google.com0e08a192012-07-13 21:07:52 +0000804 testLine36,
caryclark@google.com210acaf2012-07-12 21:05:13 +0000805 testLine35,
806 testLine34,
caryclark@google.com9764cc62012-07-12 19:29:45 +0000807 testLine33,
caryclark@google.comfa4a6e92012-07-11 17:52:32 +0000808 testLine32,
809 testLine31,
caryclark@google.com534aa5b2012-08-02 20:08:21 +0000810 testLine30,
caryclark@google.comfa4a6e92012-07-11 17:52:32 +0000811 testLine29,
812 testLine28,
caryclark@google.com47580692012-07-23 12:14:49 +0000813 testLine24,
caryclark@google.comcc905052012-07-25 20:59:42 +0000814 testLine22,
caryclark@google.com47580692012-07-23 12:14:49 +0000815 testLine19,
caryclark@google.comfa4a6e92012-07-11 17:52:32 +0000816 testLine17,
caryclark@google.come21cb182012-07-23 21:26:31 +0000817 testLine13,
818 testLine12,
caryclark@google.com47580692012-07-23 12:14:49 +0000819 testLine9,
caryclark@google.comcc905052012-07-25 20:59:42 +0000820 testLine7b,
caryclark@google.com47580692012-07-23 12:14:49 +0000821 testLine7,
caryclark@google.com8dcf1142012-07-02 20:27:02 +0000822 testSimplifyQuadratic21,
823 testSimplifyQuadratic20,
824 testSimplifyQuadratic19,
caryclark@google.comb45a1b42012-05-18 20:50:33 +0000825 testSimplifyQuadratic18,
caryclark@google.comfa0588f2012-04-26 21:01:06 +0000826 testSimplifyQuadratic17,
827 testSimplifyQuadratic16,
828 testSimplifyQuadratic15,
829 testSimplifyQuadratic14,
830 testSimplifyQuadratic13,
831 testSimplifyQuadratic12,
832 testSimplifyQuadratic11,
833 testSimplifyQuadratic10,
834 testSimplifyQuadratic9,
835 testSimplifyQuadratic8,
836 testSimplifyQuadratic7,
837 testSimplifyQuadratic6,
838 testSimplifyQuadratic5,
839 testSimplifyQuadratic4,
840 testSimplifyQuadratic3,
841 testSimplifyQuadratic2,
842 testSimplifyQuadratic1,
caryclark@google.com752b60e2012-03-22 21:11:17 +0000843];
844
845var scale, columns, rows, xStart, yStart;
846
847var ticks = 0.1;
848var at_x = 13 + 0.5;
849var at_y = 13 + 0.5;
caryclark@google.com2ddff932012-08-07 21:25:27 +0000850var decimal_places = 0; // make this 3 to show more precision
caryclark@google.com752b60e2012-03-22 21:11:17 +0000851
852var tests = [];
caryclark@google.com0e08a192012-07-13 21:07:52 +0000853var testTitles = [];
caryclark@google.com752b60e2012-03-22 21:11:17 +0000854var testIndex = 0;
855
856var ctx;
857
caryclark@google.com0e08a192012-07-13 21:07:52 +0000858function parse(test, title) {
caryclark@google.com752b60e2012-03-22 21:11:17 +0000859 var contours = [];
860 var contourStrs = test.split("path.close();");
caryclark@google.comd88e0892012-03-27 13:23:51 +0000861 var pattern = /-?\d+\.*\d*/g;
caryclark@google.com752b60e2012-03-22 21:11:17 +0000862 for (var c in contourStrs) {
caryclark@google.comfb173422012-04-10 18:28:55 +0000863 var contour = contourStrs[c];
864 var verbStrs = contour.split("path");
865 var verbs = [];
866 for (var v in verbStrs) {
867 var verbStr = verbStrs[v];
868 var points = verbStr.match(pattern);
869 var pts = [];
870 for (var wd in points) {
871 var num = parseFloat(points[wd]);
872 if (isNaN(num)) continue;
873 pts.push(num);
874 }
875 if (pts.length > 0)
876 verbs.push(pts);
caryclark@google.com752b60e2012-03-22 21:11:17 +0000877 }
caryclark@google.comfa0588f2012-04-26 21:01:06 +0000878 if (verbs.length > 0) {
879 var lastIndex = verbs.length - 1;
880 var lastVerb = verbs[lastIndex];
881 var lastLen = lastVerb.length;
882 if (verbs[0][0] != lastVerb[lastLen - 2] && verbs[0][1] != lastVerb[lastLen - 1]) {
883 var lastPts = [];
884 lastPts.push(verbs[0][0]);
885 lastPts.push(verbs[0][1]);
886 verbs.push(lastPts);
887 }
caryclark@google.comfb173422012-04-10 18:28:55 +0000888 contours.push(verbs);
caryclark@google.comfa0588f2012-04-26 21:01:06 +0000889 }
caryclark@google.com752b60e2012-03-22 21:11:17 +0000890 }
caryclark@google.com0e08a192012-07-13 21:07:52 +0000891 if (contours.length > 0) {
caryclark@google.comfb173422012-04-10 18:28:55 +0000892 tests.push(contours);
caryclark@google.com0e08a192012-07-13 21:07:52 +0000893 testTitles.push(title);
894 }
caryclark@google.com752b60e2012-03-22 21:11:17 +0000895}
896
caryclark@google.com0e08a192012-07-13 21:07:52 +0000897function parseRect(test, title) {
caryclark@google.comfa4a6e92012-07-11 17:52:32 +0000898 var contours = [];
899 var rectStrs = test.split("path.addRect");
900 var pattern = /-?\d+\.*\d*/g;
901 for (var r in rectStrs) {
902 var rect = rectStrs[r];
903 var sideStrs = rect.match(pattern);
904 var sides = [];
905 for (var wd in sideStrs) {
906 var num = parseFloat(sideStrs[wd]);
907 if (isNaN(num)) continue;
908 sides.push(num);
909 }
910 if (sides.length == 0)
911 continue;
912 var verbs = [];
913 var topLeft = [];
914 topLeft.push(sides[0]); topLeft.push(sides[1]);
915 var topRight = [];
916 topRight.push(sides[2]); topRight.push(sides[1]);
917 var botLeft = [];
918 botLeft.push(sides[0]); botLeft.push(sides[3]);
919 var botRight = [];
920 botRight.push(sides[2]); botRight.push(sides[3]);
921 verbs.push(topLeft);
922 if (sides[4] == 0) {
923 verbs.push(topRight);
924 verbs.push(botRight);
925 verbs.push(botLeft);
926 } else {
927 verbs.push(botLeft);
928 verbs.push(botRight);
929 verbs.push(topRight);
930 }
931 verbs.push(topLeft);
932 contours.push(verbs);
933 }
caryclark@google.com0e08a192012-07-13 21:07:52 +0000934 if (contours.length > 0) {
caryclark@google.comfa4a6e92012-07-11 17:52:32 +0000935 tests.push(contours);
caryclark@google.com0e08a192012-07-13 21:07:52 +0000936 testTitles.push(title);
937 }
caryclark@google.comfa4a6e92012-07-11 17:52:32 +0000938}
939
caryclark@google.com752b60e2012-03-22 21:11:17 +0000940function init(test) {
941 var canvas = document.getElementById('canvas');
942 if (!canvas.getContext) return;
caryclark@google.com534aa5b2012-08-02 20:08:21 +0000943 canvas.width = window.innerWidth - at_x;
944 canvas.height = window.innerHeight - at_y;
caryclark@google.com752b60e2012-03-22 21:11:17 +0000945 ctx = canvas.getContext('2d');
946 var xmin = Infinity;
947 var xmax = -Infinity;
948 var ymin = Infinity;
949 var ymax = -Infinity;
caryclark@google.comfb173422012-04-10 18:28:55 +0000950 for (var contours in test) {
951 var contour = test[contours];
952 for (var verbs in contour) {
953 var verb = contour[verbs];
954 var last = verb.length;
caryclark@google.comb45a1b42012-05-18 20:50:33 +0000955 for (var idx = 0; idx < last; idx += 2) {
956 xmin = Math.min(xmin, verb[idx]);
957 xmax = Math.max(xmax, verb[idx]);
958 ymin = Math.min(ymin, verb[idx + 1]);
959 ymax = Math.max(ymax, verb[idx + 1]);
960 }
caryclark@google.com752b60e2012-03-22 21:11:17 +0000961 }
962 }
963 var subscale = 1;
964 while ((xmax - xmin) * subscale < 0.1 && (ymax - ymin) * subscale < 0.1) {
965 subscale *= 10;
966 }
967 columns = Math.ceil(xmax) - Math.floor(xmin) + 1;
968 rows = Math.ceil(ymax) - Math.floor(ymin) + 1;
969 xStart = Math.floor(xmin);
970 yStart = Math.floor(ymin);
971 var hscale = ctx.canvas.width / columns / ticks;
972 var vscale = ctx.canvas.height / rows / ticks;
973 scale = Math.floor(Math.min(hscale, vscale)) * subscale;
974}
975
976function drawPoint(px, py, xoffset, yoffset, unit) {
caryclark@google.com2ddff932012-08-07 21:25:27 +0000977 var label = px.toFixed(decimal_places) + ", " + py.toFixed(decimal_places);
caryclark@google.com752b60e2012-03-22 21:11:17 +0000978 var _px = px * unit + xoffset;
979 var _py = py * unit + yoffset;
980 ctx.beginPath();
981 ctx.arc(_px, _py, 3, 0, Math.PI*2, true);
982 ctx.closePath();
983 ctx.fill();
984 ctx.fillText(label, _px + 5, _py);
985}
986
caryclark@google.com0e08a192012-07-13 21:07:52 +0000987function draw(test, title, _at_x, _at_y, scale) {
988 ctx.fillStyle = "rgba(0,0,0, 0.1)";
989 ctx.font = "normal 50px Arial";
990 ctx.fillText(title, 50, 50);
991 ctx.font = "normal 10px Arial";
992
caryclark@google.com752b60e2012-03-22 21:11:17 +0000993 var unit = scale * ticks;
994 ctx.lineWidth = 1;
995 var i;
996 for (i = 0; i <= rows * ticks; ++i) {
997 ctx.strokeStyle = (i % ticks) != 0 ? "rgb(160,160,160)" : "black";
998 ctx.beginPath();
999 ctx.moveTo(_at_x + 0, _at_y + i * scale);
1000 ctx.lineTo(_at_x + unit * columns, _at_y + i * scale);
1001 ctx.stroke();
1002 }
1003 for (i = 0; i <= columns * ticks; ++i) {
1004 ctx.strokeStyle = (i % ticks) != 0 ? "rgb(160,160,160)" : "black";
1005 ctx.beginPath();
1006 ctx.moveTo(_at_x + i * scale, _at_y + 0);
1007 ctx.lineTo(_at_x + i * scale, _at_y + unit * rows);
1008 ctx.stroke();
1009 }
1010
1011 var xoffset = xStart * -unit + _at_x;
1012 var yoffset = yStart * -unit + _at_y;
1013
1014 ctx.fillStyle = "rgb(40,80,60)"
1015 for (i = 0; i <= columns; i += (1 / ticks))
1016 {
1017 num = (xoffset - _at_x) / -unit + i;
1018 ctx.fillText(num.toFixed(0), i * unit + _at_y - 5, 10);
1019 }
1020 for (i = 0; i <= rows; i += (1 / ticks))
1021 {
1022 num = (yoffset - _at_x) / -unit + i;
1023 ctx.fillText(num.toFixed(0), 0, i * unit + _at_y + 0);
1024 }
1025 ctx.strokeStyle = "red";
caryclark@google.comfb173422012-04-10 18:28:55 +00001026 var contours, verbs, pts;
caryclark@google.com8dcf1142012-07-02 20:27:02 +00001027 ctx.beginPath();
caryclark@google.comfb173422012-04-10 18:28:55 +00001028 for (contours in test) {
1029 var contour = test[contours];
1030 if (contours == 2) ctx.strokeStyle = "blue";
caryclark@google.comfb173422012-04-10 18:28:55 +00001031 var first = true;
1032 for (verbs in contour) {
1033 var verb = contour[verbs];
1034 switch (verb.length) {
1035 case 2:
1036 if (first) {
1037 ctx.moveTo(xoffset + verb[0] * unit, yoffset + verb[1] * unit);
1038 first = false;
1039 } else
1040 ctx.lineTo(xoffset + verb[0] * unit, yoffset + verb[1] * unit);
1041 break;
1042 case 4:
1043 ctx.quadraticCurveTo(xoffset + verb[0] * unit, yoffset + verb[1] * unit,
1044 xoffset + verb[2] * unit, yoffset + verb[3] * unit);
1045 break;
1046 case 6:
1047 ctx.bezierCurveTo(xoffset + verb[0] * unit, yoffset + verb[1] * unit,
1048 xoffset + verb[2] * unit, yoffset + verb[3] * unit,
1049 xoffset + verb[4] * unit, yoffset + verb[5] * unit);
1050 break;
1051 }
caryclark@google.com752b60e2012-03-22 21:11:17 +00001052 }
caryclark@google.com8dcf1142012-07-02 20:27:02 +00001053 ctx.closePath();
caryclark@google.com752b60e2012-03-22 21:11:17 +00001054 }
caryclark@google.com8dcf1142012-07-02 20:27:02 +00001055 ctx.stroke();
1056 ctx.fillStyle="rgba(192,192,255, 0.3)";
1057 ctx.fill();
caryclark@google.com752b60e2012-03-22 21:11:17 +00001058
1059 ctx.fillStyle="blue";
caryclark@google.comfb173422012-04-10 18:28:55 +00001060 for (contours in test) {
1061 var contour = test[contours];
1062 for (verbs in contour) {
1063 var verb = contour[verbs];
1064 for (i = 0; i < verb.length; i += 2) {
1065 x = verb[i];
1066 y = verb[i + 1];
1067 drawPoint(x, y, xoffset, yoffset, unit);
1068 }
caryclark@google.com752b60e2012-03-22 21:11:17 +00001069 }
1070 }
1071}
1072
1073var mouseX = Infinity, mouseY;
1074
1075function calcXY() {
1076 var e = window.event;
1077 var tgt = e.target || e.srcElement;
1078 var left = tgt.offsetLeft;
1079 var top = tgt.offsetTop;
1080 var unit = scale * ticks;
1081 mouseX = (e.clientX - left - Math.ceil(at_x) + 1) / unit + xStart;
1082 mouseY = (e.clientY - top - Math.ceil(at_y)) / unit + yStart;
1083}
1084
1085function handleMouseOver() {
1086 calcXY();
1087 var num = mouseX.toFixed(3) + ", " + mouseY.toFixed(3);
1088 ctx.beginPath();
1089 ctx.rect(300,100,200,10);
1090 ctx.fillStyle="white";
1091 ctx.fill();
1092 ctx.fillStyle="black";
1093 ctx.fillText(num, 300, 108);
1094}
1095
1096function handleMouseClick() {
1097 calcXY();
1098// drawInset();
1099}
1100
1101function drawTop() {
1102 init(tests[testIndex]);
1103 redraw();
1104}
1105
1106function redraw() {
1107 ctx.beginPath();
1108 ctx.rect(0, 0, ctx.canvas.width, ctx.canvas.height);
1109 ctx.fillStyle="white";
1110 ctx.fill();
caryclark@google.com0e08a192012-07-13 21:07:52 +00001111 draw(tests[testIndex], testTitles[testIndex], at_x, at_y, scale);
caryclark@google.com752b60e2012-03-22 21:11:17 +00001112// if (insetScale != scale && mouseX != Infinity)
1113// drawInset();
1114}
1115
1116function doKeyPress(evt) {
1117 var char = String.fromCharCode(evt.charCode);
1118 switch (char) {
1119 case 'N':
caryclark@google.com534aa5b2012-08-02 20:08:21 +00001120 testIndex += 9;
caryclark@google.com752b60e2012-03-22 21:11:17 +00001121 case 'n':
1122 if (++testIndex >= tests.length)
1123 testIndex = 0;
caryclark@google.comfa0588f2012-04-26 21:01:06 +00001124 mouseX = Infinity;
1125 drawTop();
1126 break;
1127 case 'P':
caryclark@google.com534aa5b2012-08-02 20:08:21 +00001128 testIndex -= 9;
caryclark@google.comfa0588f2012-04-26 21:01:06 +00001129 case 'p':
1130 if (--testIndex < 0)
1131 testIndex = tests.length - 1;
caryclark@google.com752b60e2012-03-22 21:11:17 +00001132 mouseX = Infinity;
1133 drawTop();
1134 break;
1135 case 'T':
1136 case 't':
caryclark@google.com752b60e2012-03-22 21:11:17 +00001137 break;
1138 case '-':
caryclark@google.com534aa5b2012-08-02 20:08:21 +00001139 drawTop();
caryclark@google.com752b60e2012-03-22 21:11:17 +00001140 break;
1141 case '=':
1142 case '+':
caryclark@google.com534aa5b2012-08-02 20:08:21 +00001143 drawTop();
caryclark@google.com752b60e2012-03-22 21:11:17 +00001144 break;
1145 }
1146}
1147
caryclark@google.com534aa5b2012-08-02 20:08:21 +00001148function doResize(evt) {
1149 drawTop();
1150}
1151
caryclark@google.com752b60e2012-03-22 21:11:17 +00001152function start() {
1153 for (i = 0; i < testDivs.length; ++i) {
caryclark@google.com0e08a192012-07-13 21:07:52 +00001154 var title = testDivs[i].id.toString();
caryclark@google.com752b60e2012-03-22 21:11:17 +00001155 var str = testDivs[i].firstChild.data;
caryclark@google.comfa4a6e92012-07-11 17:52:32 +00001156 if (str.split("addRect").length > 1) {
caryclark@google.com0e08a192012-07-13 21:07:52 +00001157 parseRect(str, title);
caryclark@google.comfa4a6e92012-07-11 17:52:32 +00001158 } else {
caryclark@google.com0e08a192012-07-13 21:07:52 +00001159 parse(str, title);
caryclark@google.comfa4a6e92012-07-11 17:52:32 +00001160 }
caryclark@google.com752b60e2012-03-22 21:11:17 +00001161 }
1162 drawTop();
1163 window.addEventListener('keypress', doKeyPress, true);
caryclark@google.com534aa5b2012-08-02 20:08:21 +00001164 window.onresize = function() {
1165 drawTop();
1166 }
caryclark@google.com752b60e2012-03-22 21:11:17 +00001167}
1168
1169</script>
1170</head>
1171
1172<body onLoad="start();">
caryclark@google.comfa4a6e92012-07-11 17:52:32 +00001173<canvas id="canvas" width="750" height="500"
caryclark@google.com752b60e2012-03-22 21:11:17 +00001174 onmousemove="handleMouseOver()"
1175 onclick="handleMouseClick()"
1176 ></canvas >
1177</body>
1178</html>