snipplets.dev/code/JavaScript/Canvas/drawText.js

15 lines
465 B
JavaScript
Raw Permalink Normal View History

2021-11-15 02:50:46 +03:00
function Draw() {
let context = document.getElementById('canvas').getContext('2d');
// Styling text
// font = value
// textAlign = value | *start, end, left, right, center
// textBaseline = value | top, hanging, middle, *alphabetic, ideographic, bottom
// direction = value | ltr, rtl, *inherit
// fillText(text, x, y [, maxWidth])
// strokeText(text, x, y [, maxWidth])
context.font = '48px serif';
context.fillText('Hello world', 10, 50);
}