js实现canvas鼠标跟随彩带飘荡效果代码

代码语言:html

所属分类:动画

代码描述:js实现canvas鼠标跟随彩带飘荡效果代码

代码标签: 鼠标 跟随 彩带 飘荡 效果

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

<html>
<head>
    <style>
        body,
        html {
            margin: 0px;
            padding: 0px;
            position: fixed;
        }
    </style>

</head>
<bod>
    <div></div>
    <script>
        var canvas = document.createElement("canvas"),
        c = canvas.getContext("2d");
        var w = (canvas.width = window.innerWidth),
        h = (canvas.height = window.innerHeight);

        document.body.appendChild(canvas);

        c.fillStyle = "rgba(30,30,30,1)";
        c.fillRect(0, 0, w, h);

        var hi = [],
        count = 6,
        d = 10;

        class rope {
            constructor(n, r) {
                this.n = n;
                this.r = r;
                this.d = 40;
                this.choice = [Math.floor(Math.random() * 50),
                    Math.floor(Math.random() * 20+170)];
                this.col =
                "hsla(" +this.choice[Math.floor(Math.random()*1.1)]+
                ",100%," +
                Math.floor(Math.random() * 25 + 50) +
                "%," +
                Math.random() +
                ")";
                this.tail = new Array(this.n);
                for (v.........完整代码请登录后点击上方下载按钮下载查看

网友评论0