html canvas写字并右对齐
function PaintText(x, y, color, size, text, toLeft) {
if (toLeft == undefined) {
toLeft = true;
}
y += size;
ctx.font = "normal " + size+"px arial";
ctx.fillStyle = color;
if (toLeft) {
ctx.fillText(text, x, y);
}
else {
//使用ctx.measureText计算文本宽度,右对齐
ctx.fillText(text, ActualWidth-ctx.measureText(text).width, y);
}
}