电子雨代码-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>
相关推荐
前端 贾公子21 小时前
从入门到实践:前端 Monorepo 工程化实战(4)
前端
菩提小狗21 小时前
Sqlmap双击运行脚本,双击直接打开。
前端·笔记·安全·web安全
前端工作日常21 小时前
我学习到的AG-UI的概念
前端
韩师傅21 小时前
前端开发消亡史:AI也无法掩盖没有设计创造力的真相
前端·人工智能·后端
XiaoYu200221 小时前
第12章 支付宝SDK
前端
双向331 天前
RAG的下一站:检索增强生成如何重塑企业知识中枢?
前端
拖拉斯旋风1 天前
从零开始:使用 Ollama 在本地部署开源大模型并集成到 React 应用
前端·javascript·ollama
asing1 天前
🤯 为什么我的收银台在鸿蒙系统“第一次返回”死活拦不住?一次差点背锅的排查实录
前端·harmonyos
德育处主任1 天前
『NAS』在群晖部署图片压缩工具-Squoosh
前端·javascript·docker
Hao_Harrision1 天前
50天50个小项目 (React19 + Tailwindcss V4) ✨| ThreeDBackgroundBoxes(3D背景盒子组件)
前端·3d·typescript·react·tailwindcss·vite7