一、管道流动动画
![在这里插入图片描述](https://img-blog.csdnimg.cn/640a9b6638a242669a51ee2deb42d3e4.gif)
var canvas = document.getElementById("canvas");
var ctx = canvas.getContext("2d");
var offset = 0;
function draw() {
ctx.clearRect(0, 0, canvas.width, canvas.height);
ctx.beginPath();
ctx.strokeStyle = "#0000ff";
ctx.lineWidth = 3;
ctx.lineCap = "round";
ctx.moveTo(20, 20);
ctx.lineTo(100, 20);
ctx.arcTo(150, 20, 150, 22, 2);
ctx.lineTo(150, 120);
ctx.setLineDash([8, 8]);
ctx.stroke();
ctx.lineDashOffset = -offset;
}
function march() {
offset++;
if (offset > 200) {
offset = 0;
}
draw();
setTimeout(march, 100);
}
march();