canvas 绘制文本

// canvas 简单例子
var canvas = document.getElementById('canvas');
if (canvas.getContext) {
    var context = canvas.getContext('2d');
    // 绘制字体
    context.font = "bold 30px Arial";
    // 字符串,x, y, width
    context.fillText("hello world", 100, 50);
    
    // 使用strokeText 绘制文字
    context.beginPath();
    context.strokeText('Hello World', 100, 50);
}

你可能感兴趣的:(canvas 绘制文本)