电子雨代码-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>
相关推荐
槑有老呆6 小时前
Bun:一个让 Node 开发者原地起飞的 JS/TS 运行时
前端
小小小小宇6 小时前
AI Agent 核心流程与底层逻辑
前端
wuhen_n6 小时前
RAG 实战:语义检索 + 大模型生成精准问答
前端·langchain·ai编程
沉尘5886 小时前
ACE-GCM加解密微信小程序
前端
春风得意之时6 小时前
前端安装项目出现代理问题和ssl认证问题
前端·网络协议·ssl
问心无愧05136 小时前
ctf show web入门109
android·前端·笔记
粉末的沉淀6 小时前
vue:Vite项目中高效管理纯色SVG图标的方案
前端·javascript·vue.js
dotnet907 小时前
PDF 页面尺寸上限是 14400。iText 直接加载成功的大图可能超过这个限制,需要在 setPageSize 之前等比缩放。
前端·javascript·html
threelab7 小时前
Three.js 几何图形变换 | 三维可视化 / AI 提示词
开发语言·前端·javascript·人工智能·3d·着色器