simplex-noise实现一个闪电粒子特效动画代码

代码语言:html

所属分类:粒子

代码描述:simplex-noise实现一个闪电粒子特效动画代码

代码标签: 闪电 粒子 特效 动画

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

<!DOCTYPE html>
<html lang="en">

<head>

    <meta charset="UTF-8">



    <style>
        * {
            margin: 0;
            padding: 0;
        }

        html,
        body {
            overflow: hidden;
        }

        body {
            position: relative;
            background-color: #000;
        }
    </style>

</head>

<body translate="no">

    <script type="text/javascript" src="//repo.bfw.wiki/bfwrepo/js/simplex-noise.min.js"></script>

    <script>

        class Tool {
            // random number.
            static randomNumber(min, max) {
                return Math.floor(Math.random() * (max - min + 1) + min);
            }
            // random color rgb.
            static randomColorRGB() {
                return (
                    "rgb(" +
                    this.randomNumber(0, 255) +
                    ", " +
                    this.randomNumber(0, 255) +
                    ", " +
                    this.randomNumber(0, 255) +
                    ")");

            }
            // random color hsl.
            static randomColorHSL(hue, saturation, lightness) {
                return (
                    "hsl(" +
                    hue +
                    ", " +
                    saturation +
                    "%, " +
                    lightness +
                    "%)");

            }
            // gradient color.
            static gradientColor(ctx, cr, cg, cb, ca, x, y, r) {
                const col = cr + "," + cg + "," + cb;
                const g = ctx.createRadialGradient(x, y, 0, x, y, r);
                g.addColorStop(0, "rgba(" + col + ", " + ca * 1 + ")");
        .........完整代码请登录后点击上方下载按钮下载查看

网友评论0