电子雨代码-html

电子雨代码

动画效果展示

代码

javascript 复制代码
<!DOCTYPE html>

<html lang="en">

<head>

    <meta charset="UTF-8">

    <title>Code</title>

    <style>
        body {

            margin: 0;

            overflow: hidden;

        }
    </style>

</head>

<body>

    <canvas id="myCanvas"></canvas>

    <script>

        const width = document.getElementById("myCanvas").width = screen.availWidth;

        const height = document.getElementById("myCanvas").height = screen.availHeight;

        const ctx = document.getElementById("myCanvas").getContext("2d");

        const arr = Array(Math.ceil(width / 10)).fill(0);

        const str = "ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789".split("");

        function rain() {

            ctx.fillStyle = "rgba(0,0,0,0.05)";

            ctx.fillRect(0, 0, width, height);

            ctx.fillStyle = "#0f0";

            arr.forEach(function (value, index) {

                ctx.fillText(str[Math.floor(Math.random() * str.length)], index * 10, value + 10);

                arr[index] = value >= height || value > 8888 * Math.random() ? 0 : value + 10;

            });

        }

        setInterval(rain, 30);

    </script>

</body>

</html>
相关推荐
凤山老林1 小时前
防抖与节流:解决Web前段高频事件,性能优化的”YYDS“
前端·防抖节流
KaMeidebaby1 小时前
卡梅德生物技术快报|核酸适配体文库筛选:核酸适配体文库筛选全流程技术解析:NGS与AI辅助方案的设计与实践
前端·人工智能·物联网·算法·百度
Wect1 小时前
TypeScript 完全指南
前端·javascript·typescript
hunterandroid1 小时前
Fragment 事务与状态丢失:从崩溃现场到稳定治理
前端
清风programmer1 小时前
H5与小程序通信
前端·vue.js·uni-app
不一样的少年_2 小时前
原来 AI Agent 的核心循环这么简单:手搓一个 Agent Loop
前端·后端·agent
爱勇宝2 小时前
你以为自己性格不好,其实只是被环境反复训练
前端·后端·程序员
phltxy2 小时前
LangChain_v1_Agent快速开发和更新说明
前端·javascript·langchain
Cobyte2 小时前
通过 Vite 运行手写的模板编译器
前端·javascript·vue.js
Hyyy2 小时前
Agent 工作流
前端