Guest User

Untitled

a guest
Jun 24th, 2018
97
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.48 KB | None | 0 0
  1. Chart.prototype.drawTextCentered = function(context, text, x, y, font, color) {
  2. if (context.mozDrawText) {
  3. context.save();
  4. context.fillStyle = color;
  5. context.mozTextStyle = font;
  6. x -= 0.5 * context.mozMeasureText(text);
  7. context.translate(x, y);
  8. context.mozDrawText(text);
  9. context.restore();
  10. }
  11. }
  12.  
  13. <canvas id="canvas"></canvas>
  14. <script>
  15. var context = document.getElementById("canvas").getContext("2d");
  16. context.fillText("Hello, world!", 10, 10);
  17. </script>
Add Comment
Please, Sign In to add comment