链式反射特效

代码语言:html

所属分类:动画

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

<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">

    <title> chain reaction</title>
    <style>
        body {
            font-family: Arial, Helvetica, "Liberation Sans", FreeSans, sans-serif;
            background-color: #000;
            margin: 0;
            padding: 0;
            border-width: 0;
        }
    </style>

</head>
<body translate="no">

    <script>
        window.addEventListener("load", function () {

            const gridStep = 40; // grid step (distance between atoms - center to center)
            const radiusToStepRatio = 0.3; // radius to step ratio, didn't guess ? < 0.5
            const activity = 3; // maximum number of atoms destroyed by one particle

            const atomRadius = gridStep * radiusToStepRatio;

            let canv, ctx; // canvas and drawing context for atoms
            let canvP, ctxP; // canvas and drawing context for particles

            let maxx, maxy; // canvas size

            let orgx, orgy; // position of the center of top left atom

            let nbx, nby; // nb of atoms horiz. / vert.
            let crystal; // matrix of atoms

            let explosions; // table of disintegrations to come / in progress
            let endsOfExplosion; // list of elements to be removed from explosions
            let requestID; // to cancel animation in progress
            let lRay; // maximum length for particle path
            let nbEff = 0;
            // shortcuts for Math functions

            const mrandom = Math.random;
            const mfloor = Math.floor;
            const mround = Math.round;
            const mceil = Math.ceil;
            const mtrunc = Math.trunc;
            const mabs = Math.abs;
            const mmin = Math.min;
       .........完整代码请登录后点击上方下载按钮下载查看

网友评论0