canvas实现鼠标交互式彩色粒子烟花喷射动画效果代码

代码语言:html

所属分类:粒子

代码描述:canvas实现鼠标交互式彩色粒子烟花喷射动画效果代码

代码标签: canvas 彩色 粒子 烟花 喷射 交互

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

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

<head>
    <meta charset="UTF-8">

</head>

<body>
    <canvas id="c"></canvas>

    <script>
        var b = document.body;
        var c = document.getElementsByTagName("canvas")[0];
        var a = c.getContext("2d");
        h = 400;
        p = [];
        j = 0;
        k = 0;
        u = 0;
        m = Math;
        q = function(g, f) {
            return ~~(m.random() * (f - g + 1) + g)
        };
        d = "Infinity";
        c.width = 400;
        c.height = h;
        document.bgColor = "#111";
        c.style.background = "#000";
        c.addEventListener("mousemove", function(f) {
            j = m.floor(f.pageX - c.offsetLeft - 200);
            k = m.floor(f.pageY - c.offsetTop - h / 2);
            f = -(-k / -j);
            u = m.floor(m.atan(f) * (180 / m.PI));
            0 > j && 0 > k && (u += 180);
            0 > j && 0 < k && (u += 180);
            0 < j && 0 < k && (u += 360);
            0 > k && f == "-" + d && (u = 90);
            0 < k && f == d && (u = 270);
            0 > j && "0" == f && (u = 180);
            isNaN(u) && (u = 0)
.........完整代码请登录后点击上方下载按钮下载查看

网友评论0