css3实现动态心电图折线

css3实现动态心电图折线

 M(moveto):需要两个参数(x轴和y轴坐标,移动到的点的x轴和y轴的坐标
 L(lineto):需要两个参数(x轴和y轴坐标),它会在当前位置和最新的位置(L前面画笔所在的点)之间画一条线段。
 H(horizontal lineto):一个参数,标明在x轴移动到的位置,绘制水平线
 V(vertical lineto):一个参数,标明在y轴移动到的位置,绘制垂直线
 Z( closepath):从当前点画一条直线到路径的起点

折线心电图

在这里插入图片描述

SVG中的坐标系原点通常位于左上角,而Y轴的正方向是向下的,这与一些其他图形系统(例如笛卡尔坐标系)的约定是不同的。因此,如果你在SVG中绘制直线并觉得倒立了,可能是因为你在使用笛卡尔坐标系的思维方式时感到困惑

<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="UTF-8">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <style>
    body {
    
    
      background-color: #f0f0f0;
      display: flex;
      align-items: center;
      justify-content: center;
      height: 100vh;
      margin: 0;
    }

    svg {
    
    
      width: 300px;
      height: 200px;
    }

    .path {
    
    
      fill: none;
      stroke: #ff7f50;
      stroke-width: 2;
      stroke-dasharray: 1000; /* 设置路径的总长度 */
      stroke-dashoffset: 1000; /* 初始偏移量,隐藏路径 */
      animation: dash 10s linear infinite;
    }

    @keyframes dash {
    
    
      to {
    
    
        stroke-dashoffset: 0; 
        /* 将路径偏移量设置为0,显示整个路径 */
      }
    }
  </style>
</head>
<body>
  <svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 300 200">
    <path class="path" d="M0 160 L50 160 L60 200 L70 140 L80 160 L100 0 L120 160 L140 160 L150 130 L160 140 L170 120 L180 130 L200 60 L220 160 L240 160  "/>
  </svg>
</body>
</html>

おすすめ

転載: blog.csdn.net/Start_t/article/details/134977438
おすすめ