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

时间:2014-09-12 21:07:38

标签: html5 canvas

context.fillText()context.strokeText()之间是否存在任何差异,除了第一个使用context.fillStyle而后者使用context.strokeStyle这一事实。他们没有添加context.textStyle属性的原因?

1 个答案:

答案 0 :(得分:16)

是的,strokeText实际上会抚摸字母的轮廓,而fillText会填充字母的内部。

enter image description here

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);