Canvas context.fillText()vs context.strokeText()

Hof*_*ann 7 html5 canvas

有什么区别context.fillText()context.strokeText()除此之外的第一次使用的事实context.fillStyle,而后者的用途context.strokeStyle.他们没有添加context.textStyle房产的任何理由?

mar*_*rkE 17

是的,strokeText实际上描绘了字母的轮廓,而fillText填充了字母的内部.

在此输入图像描述

ctx.fillStyle='red';
ctx.strokeStyle='green'
ctx.lineWidth=3;
ctx.font='90px verdana';
ctx.fillText('Q',50,150);
ctx.strokeText('Q',125,150);
ctx.fillText('Q',200,150);
ctx.strokeText('Q',200,150);
Run Code Online (Sandbox Code Playgroud)

  • 啊酷,我想我只是创建太小而无法注意到 strokeText 属性的文本。谢谢。 (2认同)