-
Notifications
You must be signed in to change notification settings - Fork 15
/
Copy path粒子.html
57 lines (52 loc) · 1.28 KB
/
粒子.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
<!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>粒子</title>
<style>
/* html, body {
margin: 0;
background: black;
overflow: hidden;
width: 100%;
height: 100%;
} */
#canvas {
background: #000;
}
</style>
</head>
<body>
<canvas id="canvas"></canvas>
<script>
const canvas = document.querySelector('#canvas')
const cvsCtx = canvas.getContext('2d')
console.log(cvsCtx)
// 设置宽高
canvas.width = 500
canvas.height = 500
// 绘制整圆
// cvsCtx.beginPath(); // 开始路径
// cvsCtx.arc(100, 100, 10, 0, Math.PI * 2, true);
// cvsCtx.closePath() // 结束路径
// cvsCtx.fillStyle = '#fff';
// cvsCtx.fill();
// 绘制弧线
// cvsCtx.beginPath();
// cvsCtx.arc(100, 100, 50, 0, Math.PI * 1, false);
// cvsCtx.strokeStyle = '#fff';
// cvsCtx.stroke();
// cvsCtx.closePath();
// 绘制直线
cvsCtx.beginPath();
cvsCtx.moveTo(100, 100);
cvsCtx.lineTo(150, 200);
cvsCtx.lineWidth = 5;
cvsCtx.lineCap = 'round';
cvsCtx.strokeStyle = "#fff";
cvsCtx.stroke();
</script>
</body>
</html>