Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- Chart.prototype.drawTextCentered = function(context, text, x, y, font, color) {
- if (context.mozDrawText) {
- context.save();
- context.fillStyle = color;
- context.mozTextStyle = font;
- x -= 0.5 * context.mozMeasureText(text);
- context.translate(x, y);
- context.mozDrawText(text);
- context.restore();
- }
- }
- <canvas id="canvas"></canvas>
- <script>
- var context = document.getElementById("canvas").getContext("2d");
- context.fillText("Hello, world!", 10, 10);
- </script>
Add Comment
Please, Sign In to add comment