text-context-state-ref.html 728 B

123456789101112131415161718192021222324252627282930313233
  1. <!DOCTYPE HTML>
  2. <html>
  3. <head>
  4. <title>text to ensure text attributes are saved in the context state</title>
  5. </head>
  6. <body>
  7. <canvas id="c" width="128" height="64" style="direction:ltr"></canvas>
  8. <script type="text/javascript">
  9. var canvas = document.getElementById('c');
  10. var ctx = canvas.getContext('2d');
  11. ctx.textAlign = 'left';
  12. ctx.textBaseline = 'top';
  13. ctx.font = '16px sans-serif';
  14. ctx.fillText('yet another thing', 0, 0);
  15. ctx.textAlign = 'right';
  16. ctx.textBaseline = 'alphabetic';
  17. ctx.font = '24px serif';
  18. ctx.fillText('other thing', 128, 40);
  19. ctx.textAlign = 'center';
  20. ctx.textBaseline = 'bottom';
  21. ctx.font = '10px sans-serif';
  22. ctx.fillText('something', 80, 60);
  23. </script>
  24. </body>
  25. </html>