<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta http-equiv="X-UA-Compatible" content="ie=edge">
<title>canvas</title>
</head>
<body>
<canvas id="canvas" width="400" height="400"></canvas>
<script>
var canvas = document.getElementById("canvas");
canvas.style.background = "#000";
var context = canvas.getContext("2d");
const { PI } = Math;
context.beginPath();
context.moveTo(50, 50);//画笔放置位置
context.lineTo(100, 100);//收笔位置
context.closePath();
context.strokeStyle = "#fff";
context.stroke();//描边
</script>
</body>
</html>