Is there any difference between context.fillText()
and context.strokeText()
besides the fact that the first uses context.fillStyle
while the later uses context.strokeStyle
. Any reason they did not add a context.textStyle
property?
var canvas = document.getElementById("myCanvas");
var ctx = canvas.getContext("2d");
ctx.fillStyle = 'red';
ctx.strokeStyle = 'green'
ctx.lineWidth = 3;
ctx.font = '90px verdana';
ctx.fillText('Q', 50, 100);
ctx.strokeText('Q', 125, 100);
ctx.fillText('Q', 200, 100);
ctx.strokeText('Q', 200, 100);
<canvas id="myCanvas"></canvas>
Yep, strokeText actually strokes the outline of the letters while fillText fills the inside of the letters.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With