123456789101112131415161718192021 |
- <!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML//EN">
- <html>
- <head>
- <title>Canvas 2d Context Font Property Speed</title>
- </head>
- <body>
- <canvas id='thecanvas' height=100 width=100/>
- <script>
- var canvas = document.getElementById('thecanvas');
- var context = canvas.getContext('2d');
- var t0 = Date.now();
- for (var i = 0; i < 1000; i++) {
- if(i % 2 == 0)
- context.font = 'bold 13px Arial';
- else
- context.font = 'italic 13px Arial';
- }
- alert('Elapsed for 1000 font switches: ' + (Date.now() - t0));
- </script>
- </body>
- </html>
|