canvas爱心粒子动画效果代码

代码语言:html

所属分类:粒子

代码描述:canvas爱心粒子动画效果代码

代码标签: canvas 爱心 粒子

下面为部分代码预览,完整代码请点击下载或在bfwstudio webide中打开

<!DOCTYPE html>

<html lang="en">

<head>

    <meta charset="UTF-8">



    <style>
        body {
          display: grid;
          height: 95vh;
          place-items: center;
          background: linear-gradient(45deg, #212, #221);
        }
        
        svg {
          width: 500px;
          height: 500px;
        }
        
        #heart-canvas {
          box-shadow: 0 0 150px 0px #555 inset;
          background: white;
          animation: 1s pulse infinite ease-in-out;
          mask-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' id='heart' viewBox='0 0 10 10'%3E%3Ctext font-size='9' x='.5' y='8.5'%3E💚%3C/text%3E%3C/svg%3E");
        }
        
        
        @keyframes pulse {
          0% {
            transform: scale(1);
          }
          
          50% {
            transform: scale(1.01);
          }
          
          100% {
            transform: scale(1);
          }
        }
    </style>
    <script type="text/javascript" src="//repo.bfw.wiki/bfwrepo/js/prefixfree.js"></script>


</head>

<body>
    <canvas id="heart-canvas" width=500 height=500></canvas>


    <script>
        const $ = document.querySelector.bind(document);
        
        
        const heartCanvas = $('#heart-canvas');
        const heartCtx = heartCanvas.getContext('2d');
        
        const { width, height } = heartCanvas;
        
        const randRange = range => Math.floor(Math.random() * range);
        
        const randomColor = () => {
 .........完整代码请登录后点击上方下载按钮下载查看

网友评论0