Home > Article > Web Front-end > What does stroke mean in HTML?
stroke is a method in HTML5 canvas. The stroke() method can be used to draw the current path.
The stroke() method will actually draw the path defined by the moveTo() and lineTo() methods. The default color is black.
Tip: You can use the strokeStyle property to draw another color/gradient.
Grammar:
context.stroke();
Example:
<!DOCTYPE html> <html> <head> <meta charset="UTF-8"> </head> <body> <canvas id="myCanvas" width="300" height="150" style="border:1px solid #d3d3d3;"> Your browser does not support the HTML5 canvas tag. </canvas> <script> var c = document.getElementById("myCanvas"); var ctx = c.getContext("2d"); ctx.beginPath(); ctx.moveTo(20, 20); ctx.lineTo(20, 100); ctx.lineTo(70, 100); ctx.strokeStyle = "green"; ctx.stroke(); </script> </body> </html>
Rendering:
The above is the detailed content of What does stroke mean in HTML?. For more information, please follow other related articles on the PHP Chinese website!