strokeText-path.html 805 B

12345678910111213141516171819202122232425262728293031323334
  1. <!DOCTYPE html>
  2. <html>
  3. <head>
  4. <script type="text/javascript"><!--
  5. window.onload = function () {
  6. var canvas = document.getElementById('testCanvas'),
  7. context = canvas.getContext('2d');
  8. // draw a path
  9. context.beginPath();
  10. context.moveTo(10, 10);
  11. context.lineTo(200, 10);
  12. context.lineTo(200, 200);
  13. context.stroke();
  14. context.closePath();
  15. context.clearRect(0, 0, canvas.width, canvas.height);
  16. // draw some text
  17. context.font = 'bold 40px sans-serif';
  18. context.strokeText("Hello world!", 10, 50);
  19. };
  20. // --></script>
  21. </head>
  22. <body>
  23. <p>You should see only see "Hello world!" below, without any additional
  24. line. JavaScript is required.</p>
  25. <p><canvas id="testCanvas" width="400" height="300">You need Canvas
  26. support.</canvas></p>
  27. </body>
  28. </html>