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

What does stroke mean in HTML?

青灯夜游
Release: 2019-11-21 15:09:54
Original
6582 people have browsed it

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();
Copy after login

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>
Copy after login

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!

Related labels:
source:php.cn
Statement of this Website
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
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template