Home  >  Article  >  Web Front-end  >  What does stroke mean in HTML?

What does stroke mean in HTML?

青灯夜游
青灯夜游Original
2019-11-21 15:09:546571browse

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:

What does stroke mean in HTML?

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!

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Previous article:HTML

Related articles

See more